CommonAction.class.php 881 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. class CommonAction extends Action {
  3. public function _initialize( ){
  4. //项目信息
  5. $this->project_id = C('CC_PROJECT_ID');
  6. if(!$this->project_id){
  7. echo 'project_id empty';
  8. return;
  9. }
  10. $this->site_title = C('SITE_TITLE') ? : '用户中心';
  11. $this->site_copyright = C('SITE_COPYRIGHT') ? : '版权所有';
  12. //跳过检查登录的操作
  13. if(in_array(ACTION_NAME,array('login','login2','register','init','set_screen_msg') ))
  14. return;
  15. if(strpos(ACTION_NAME,'api_')===0)
  16. return;
  17. //获取用户信息
  18. $this->userid = \Jiaruan\UcCookie::get();
  19. if(!$this->userid){
  20. header('Location: ?s=uc_manage/login');
  21. exit;
  22. }
  23. $cond = array('ID'=>$this->userid);
  24. $this->userinfo = M('uc_user')->where($cond)->find();
  25. //跳转到登录页面
  26. if(!$this->userinfo){
  27. header('Location: ?s=uc_manage/login');
  28. exit;
  29. }
  30. }
  31. }