function detail() { session(); if (empty($_GET['aid'])) { exit; } $_user = createModel('UserInfo'); $_reply = createModel('AskReply'); $aid = (int) $_GET['aid']; $ask = createModel('AskSubject')->get($aid); if (empty($ask->_data)) { Swoole\Http::header("HTTP/1.1 404 Not Found"); return Swoole\Error::info("Page not found", ""); } $ask->lcount++; $ask->save(); $timeout['day'] = intval(($ask['expire'] - time()) / 86400); $timeout['hour'] = intval(($ask['expire'] - time() - $timeout['day'] * 86400) / 3600); $user = $_user->get($ask['uid'])->get(); $content = createModel('AskContent')->get($aid)->get(); $gets['aid'] = $aid; $gets['select'] = $_reply->table . '.id as id,uid,sex,best,content,nickname,avatar,addtime'; $gets['order'] = 'best desc,' . $_reply->table . '.id asc'; $gets['leftjoin'] = array($_user->table, $_user->table . '.id=' . $_reply->table . '.uid'); $gets['pagesize'] = 10; $gets['page'] = empty($_GET['page']) ? 1 : (int) $_GET['page']; $replys = $_reply->gets($gets, $pager); $if_vote = true; if ($_SESSION['isLogin']) { $vote = $this->swoole->db->query("select count(*) as c from ask_vote where aid={$aid} and uid={$_SESSION['user_id']} limit 1")->fetch(); if ($vote['c'] > 0) { $if_vote = false; } } $this->swoole->tpl->assign('if_vote', $if_vote); $this->swoole->tpl->assign('if_vote', $if_vote); $this->swoole->tpl->assign('expire', $timeout); $this->swoole->tpl->ref('user', $user); $this->swoole->tpl->ref('ask', $ask->get()); $this->swoole->tpl->ref('content', $content); $this->swoole->tpl->ref('replys', $replys); if ($pager->totalpage > 1) { $this->swoole->tpl->ref('pager', $pager->render()); } $this->swoole->tpl->display(); }
/** * 验证登录 * @return unknown_type */ public static function login_require() { $check = false; if (isset($_SESSION[self::$session_prefix . 'isLogin']) and $_SESSION[self::$session_prefix . 'isLogin'] == '1') { $check = true; } if (!$check) { Swoole\Http::redirect(self::$login_url . 'refer=' . urlencode($_SERVER["REQUEST_URI"])); return false; } return true; }
function delmail() { if (empty($_GET['mid'])) { die; } $id = (int) $_GET['mid']; $_m = model('UserMail'); $ms = $_m->get($id); //发信人 if ($ms->fid == $this->uid) { if ($ms->mstatus == 5) { $ms->delete(); } else { $ms->mstatus = 4; $ms->save(); } return Swoole\JS::js_back('删除成功'); } elseif ($ms->tid == $this->uid) { if ($ms->mstatus == 4) { $ms->delete(); } else { $ms->mstatus = 5; $ms->save(); } return Swoole\JS::js_back('删除成功'); } else { Swoole\Http::response('Error!'); } }