function _initialize() { forceHttp(); $this->pre = C('DB_PREFIX'); !isset($this->justlogin) ? $this->justlogin = false : ($this->justlogin = $this->justlogin); $this->saveRule = date("YmdHis", time()) . rand(0, 1000); if (strtolower(MODULE_NAME) == 'index' && (strtolower(ACTION_NAME) == 'login' || strtolower(ACTION_NAME) == 'index' && !session('admin')) && $_SERVER['PATH_INFO'] != '/' . SAFE_ADMIN) { echo 'The page can\'t been found'; header('HTTP/1.0 404 Not Found'); exit; } if (session('admin')) { $this->admin_id = session("admin_id"); $this->assign('adminname', session('adminname')); } elseif (strtolower(ACTION_NAME) != 'verify' && strtolower(ACTION_NAME) != 'login' && strtolower(ACTION_NAME) != 'getsmscode') { if ($_SERVER['PATH_INFO'] != '/' . SAFE_ADMIN) { echo 'The page can\'t been found.'; header('HTTP/1.0 404 Not Found'); } else { redirect(__ROOT__ . '/' . SAFE_ADMIN); } exit; } if (!get_user_acl(session('admin')) && !$this->justlogin) { $this->error('对不起,权限不足'); exit; } if (method_exists($this, '_MyInit')) { $this->_MyInit(); } $this->logOpType = C("LOG_OPERATION_TYPE"); $this->assign("logOpType", $this->logOpType); $this->logUserType = C("LOG_USER_TYPE"); $datag = get_global_setting(); $this->glo = $datag; //供PHP里面使用 $this->assign("glo", $datag); }
function judgeHttps($isAjax = false) { if ($isAjax) { return; } $need_https_urls = C('NEED_HTTPS_URLS'); $no_need_https_urls = C('NO_NEED_HTTPS_URLS'); $disabled_ssl_urls = C('DISABLED_SSL_URLS'); if (in_array(strtolower($_SERVER["HTTP_HOST"]), $disabled_ssl_urls)) { return; } if (in_array(strtolower($_SERVER["REQUEST_URI"]), $no_need_https_urls)) { return; } foreach ($need_https_urls as $myurl) { if (strpos(strtolower($_SERVER["REQUEST_URI"]), $myurl) !== false) { // forceHttps(); forceHttp(); return; } } if ($_SERVER["HTTPS"] == "on") { $xredir = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; header("Location: " . $xredir); exit; } }