Пример #1
0
 public function _initialize()
 {
     parent::_initialize();
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
     $bconf = get_bconf_setting();
     $this->gloconf = $bconf;
     //供PHP里面使用
     $this->assign("gloconf", $bconf);
     if (session("u_user_name")) {
         $this->uid = session("u_id");
         $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
         $this->assign('unread', $unread);
         $this->assign('UID', $this->uid);
     } else {
         $loginconfig = FS("Webconfig/loginconfig");
         $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
         if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
             $vo = M('members')->field("id,user_name")->find($de_val);
             if (is_array($vo)) {
                 foreach ($vo as $key => $v) {
                     session("u_{$key}", $v);
                 }
                 $this->uid = session("u_id");
                 $this->assign('UID', $this->uid);
                 $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                 $this->assign('unread', $unread);
             } else {
                 cookie("Ukey", NULL);
                 cookie("Ukey2", NULL);
             }
         }
     }
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
 }
Пример #2
0
 public function _initialize()
 {
     if (!ListMobile()) {
         if ($_SERVER["HTTPS"] != "on" && 'login' == ACTION_NAME) {
             $xredir = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
             header("Location: " . $xredir);
         } else {
             if ('on' == $_SERVER['HTTPS'] && 'index' == ACTION_NAME) {
                 $xredir = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
                 redirect($xredir);
             }
         }
     }
     parent::_initialize();
     $loginconfig = FS("Webconfig/loginconfig");
     //判断快捷登录是否开启
     $this->assign("loginconfig", $loginconfig);
     $datag = get_global_setting();
     $this->glo = $datag;
     //供PHP里面使用
     $this->assign("glo", $datag);
     //公共参数
     $bconf = get_bconf_setting();
     $this->gloconf = $bconf;
     //供PHP里面使用
     $this->assign("gloconf", $bconf);
     if (isset($_POST['PHPSESSID'])) {
         session_id($_POST['PHPSESSID']);
     } else {
         if ($this->notneedlogin === true) {
             if (session("u_id")) {
                 $this->uid = session("u_id");
                 $this->assign('UID', $this->uid);
                 $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                 $this->assign('unread', $unread);
                 if (!in_array(strtolower(ACTION_NAME), array('agreement', 'ajaxredbag', 'redbag', 'setpassword', 'validatephonev2', 'getpassword2', 'getpassword3', "actlogout", 'sendpswphone', 'regsuccess', 'submitrealname', 'regrealname', 'verphonev', 'emailverify', 'register2', 'register3', 'regtemp2', 'sendphone', 'sendphone_reg', 'validatephonev', 'verify'))) {
                     redirect(__APP__ . "/member/");
                 }
             } else {
                 $loginconfig = FS("Webconfig/loginconfig");
                 $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
                 if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
                     $vo = M('members')->field("id,user_name")->find($de_val);
                     if (is_array($vo)) {
                         foreach ($vo as $key => $v) {
                             session("u_{$key}", $v);
                         }
                         $this->uid = session("u_id");
                         $this->assign('UID', $this->uid);
                         $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                         $this->assign('unread', $unread);
                         if (!in_array(strtolower(ACTION_NAME), array("actlogout", 'regsuccess', 'emailverify', 'verify'))) {
                             redirect(__APP__ . "/member/");
                         }
                     } else {
                         cookie("Ukey", NULL);
                         cookie("Ukey2", NULL);
                     }
                 }
             }
         } elseif (session("u_user_name")) {
             $this->uid = session("u_id");
             $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
             $this->assign('unread', $unread);
             $this->assign('UID', $this->uid);
         } else {
             $loginconfig = FS("Webconfig/loginconfig");
             $de_val = $this->_authcode(cookie('UKey'), 'DECODE', $loginconfig['cookie']['key']);
             if (substr(md5($loginconfig['cookie']['key'] . $de_val), 14, 10) == cookie('Ukey2')) {
                 $vo = M('members')->field("id,user_name")->find($de_val);
                 if (is_array($vo)) {
                     foreach ($vo as $key => $v) {
                         session("u_{$key}", $v);
                     }
                     $this->uid = session("u_id");
                     $this->assign('UID', $this->uid);
                     $unread = M("inner_msg")->where("uid={$this->uid} AND status=0")->count('id');
                     $this->assign('unread', $unread);
                 } else {
                     cookie("Ukey", NULL);
                     cookie("Ukey2", NULL);
                 }
             } else {
                 redirect(__APP__ . "/member/common/login/");
                 exit;
             }
         }
         //否则就在这里正常验证
     }
     if (method_exists($this, '_MyInit')) {
         $this->_MyInit();
     }
 }