public static function clear() { $session = Factory::make('session'); $user_login_key_old = $session->get("_login_cookie_key"); setCookie($user_login_key_old, '', time() - 1, '/'); $session->clear(); }
public function __Construct() { $this->response = Factory::make("response"); $this->request = Factory::make("request"); $this->get = new \stdClass(); $this->post = new \stdClass(); $this->server = new \stdClass(); $this->header = new \stdClass(); $this->cookie = new \stdClass(); foreach ($this->request->query as $k => $v) { $this->get->{$k} = $v; } foreach ($this->request->request as $p => $v) { $this->post->{$p} = $v; } foreach ($this->request->server as $s => $v) { $this->server->{$s} = $v; } foreach ($this->request->headers as $k => $v) { $this->header->{$k} = $v; } foreach ($this->request->cookies as $k => $v) { $this->cookie->{$k} = $v; } if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest") { $this->AjaxRequest = true; } }
public function __construct() { parent::__construct(); $this->session = Factory::make("session"); $this->CateModel = Model::make("Category"); $this->PostModel = Model::make("Post"); }
/** * 按分类显示文章 * @param string $category * @return void */ public function categoryPost($category) { $CateModel = Model::make("Category"); $cate = $CateModel->getCategoryByCid($category); $post_array = explode(",", $cate->postList); $pageNum = 10; $totalPage = ceil($cate->postNum / $pageNum); $request = Factory::make("session"); if (!($page = $request->get("page"))) { $page = 1; } if ($page > $totalPage) { $page = $totalPage; } if ($page <= 0) { $page = 1; } $skip = ($page - 1) * $pageNum; $PostModel = Model::make("Post"); $posts = $PostModel->whereIn("id", $post_array)->skip($skip)->orderby("created_at", "DESC")->limit($pageNum)->get(); $post_return = []; foreach ($posts as $post) { $time = strtotime($post->created_at); $post->postTime = date("F d, Y", $time); $post_return[] = $post; } $this->assign("posts", $post_return); $this->display("index.html"); }
public static function panic(\exception $e) { $response = Factory::make("response"); $vars = []; $vars['message'] = $e->getMessage(); $vars['file_line'] = $e->getFile() . " " . $e->getLine(); $response->renderHtml("exception.html", $vars); }
public function sign() { $sess = Factory::make("session"); $request_come_from = isset($this->cookie->hl_http_referer) ? $this->cookie->hl_http_referer : ''; if ($request_come_from != '' && stripos($request_come_from, "entrance") === false && stripos($request_come_from, "logout") === false && stripos($request_come_from, "login") === false) { $this->assign("httpReferer", $request_come_from); } $this->assign("site", $this->getSiteInfo()); $this->display("sign.html"); }
protected function falseHandler() { tSession::clear(); $req = Factory::make("request"); if (HTTP_METHOD == "GET") { setCookie("hl_http_referer", Route::get_currentUri(), time() + 3600, "/"); } if (isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) == "xmlhttprequest") { exit(json_encode(["code" => 503, "errmsg" => "登陆已过期,请重新登陆", "go_url" => "/admin/entrance.html"])); } else { Route::redirect("sign"); exit; } }
public function __construct() { $this->Sess = Factory::make("session"); $this->Req = Factory::make("request"); }
public function __Construct() { $engine = Config::get("TEMPLATE-ENGINE"); $this->engine = Factory::make($engine); }