/** * 检查是否登录 */ function check_auth() { // 如果配置中管理员用户名密码为空则说明不用验证 if (Config\Config::$adminName == '' && Config\Config::$adminPassword == '') { return true; } // 进入验证流程 $response = \Core\Response::getInstance()->response(); $session = \Core\Session::getInstance($response); $session->start(); if (!isset($_SESSION['admin'])) { if (!isset($_POST['admin_name']) || !isset($_POST['admin_password'])) { include ST_ROOT . '/Views/login.tpl.php'; return _exit(); } else { $admin_name = $_POST['admin_name']; $admin_password = $_POST['admin_password']; if ($admin_name != Config\Config::$adminName || $admin_password != Config\Config::$adminPassword) { $msg = "用户名或者密码不正确"; include ST_ROOT . '/Views/login.tpl.php'; return _exit(); } $_SESSION['admin'] = $admin_name; $_GET['fn'] = 'main'; } } $session->save(); return true; }
/** * 当request时调用 * @param unknown $request * @param unknown $response */ public function onRequest($request, $response) { // var_dump($request, $response); $_GET = $_POST = $_COOKIE = array(); $resp = \Core\Response::getInstance($response); $resp->setResponse($response); if (isset($request->get)) { $_GET = $request->get; } if (isset($request->post)) { $_POST = $request->post; } if (isset($request->cookie)) { $_COOKIE = $request->cookie; } try { ob_start(); include APPLICATION_PATH . '/Web/index.php'; $result = ob_get_contents(); ob_end_clean(); $response->header("Content-Type", "text/html;charset=utf-8"); $result = empty($result) ? 'No message' : $result; $response->end($result); unset($result); } catch (Exception $e) { var_dump($e); } }
function logout($module, $interface, $date, $start_time, $offset, $count) { $response = \Core\Response::getInstance()->response(); $session = \Core\Session::getInstance($response); $session->delete(); include ST_ROOT . '/Views/login.tpl.php'; }