function detail() { $id = (int) $_GET['id']; $_blog = createModel('UserLogs'); $blog = $_blog->get($id); if (empty($_COOKIE['look']) and $_COOKIE['look'] != $id) { $blog->look_count++; $blog->save(); Swoole\Cookie::set('look', $id, time() + 3600); } $uid = $blog['uid']; $this->userinfo($uid); $_c = createModel('UserComment'); $comments = $_c->getByAid('blog', $id); $this->swoole->tpl->assign('comments', $comments); $this->swoole->tpl->assign('blog', $blog->get()); return $this->swoole->tpl->fetch('blog_detail.html'); }
private function ifDeny() { $owners = explode(',', $this->project['owner']); if (!in_array($_SESSION['user_id'], $owners)) { return true; } else { if (!isset($_COOKIE['wiki_admin'])) { Swoole\Cookie::set('wiki_admin', '1', 86400 * 30); } return false; } }
/** * 注销登录 * @return unknown_type */ static function logout() { /** * 如果设置为true,退出登录时,销毁所有Session */ if (self::$session_destroy) { session_destroy(); return true; } unset($_SESSION[self::$session_prefix . 'isLogin']); unset($_SESSION[self::$session_prefix . 'user_id']); if (!empty($_SESSION[self::$session_prefix . 'save_key'])) { foreach ($_SESSION[self::$session_prefix . 'save_key'] as $sk) { unset($_SESSION[$sk]); } } unset($_SESSION[self::$session_prefix . 'save_key']); if (isset($_COOKIE[self::$session_prefix . 'password'])) { Swoole\Cookie::set(self::$session_prefix . 'password', '', 0, '/'); } }
private function setLoginStat() { $tm = time(); Swoole\Cookie::set('uname', $_SESSION['user']['nickname'], $tm + 86400 * 30, '/'); Swoole\Cookie::set('uid', $_SESSION['user_id'], $tm + 86400 * 30, '/'); }