CommonAction.class.php 859 B

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