public function showAction() { $id = $this->intVal(3); $threadModel = new ThreadModel(); $userModel = new UserModel(); $reputation = $userModel->reputation($this->userid); if ($_POST) { if (!$this->isEmailValidated) { header("location: /home/"); die; } if ($reputation < 0) { header("location: /home/"); die; } if ($this->userid > 0) { if (strlen($_POST["content"]) > 0) { $data = array(); $time = time(); $data["threadid"] = $id; $data["name"] = $this->username; $data["userid"] = $this->userid; $data["content"] = $_POST["content"]; $data["createdate"] = $time; $data["updatedate"] = $time; $replys = $threadModel->newReply($data); if ($replys) { $thread = array(); $thread["id"] = $id; $thread["replys"] = $replys; $thread["updatedate"] = $time; $thread["lastreply"] = $data["name"]; $thread["lastreplyid"] = $data["userid"]; $threadModel->updateThread($thread); } header("location: /thread/show/{$id}/"); die; } } } header('Pragma: '); header("cache-control: s-maxage=600"); $cacheModel = new FilecacheModel(); $thread = $threadModel->threadById($id); if (!$thread || $thread["del"] == 1) { header("HTTP/1.1 301 Moved Permanently"); header("location: /home/"); die; } $replysCount = $threadModel->replysCountById($id); $replys = $threadModel->replysById($id); $voteInfo = $threadModel->voteInfo($id); $userVote = $threadModel->userVote($id, $this->userid); //limit10replys $isBot = ToolModel::isBot(); if ($this->userid == 0 && !$isBot && $replysCount > 10) { $replys = array_slice($replys, 0, 10); } if (!$this->userid) { $this->_mainContent->assign("userid", 0); } else { $this->_mainContent->assign("userid", $this->userid); } if ($this->userid) { $userModel = new UserModel(); $userInfo = $userModel->userInfo($this->userid); $reputation = $userInfo["reputation"]; } else { $reputation = 0; } $this->_mainContent->assign("reputation", $reputation); $this->_mainContent->assign("thread", $thread); $this->_mainContent->assign("replysCount", $replysCount); $this->_mainContent->assign("replys", $replys); $this->_mainContent->assign("voteInfo", $voteInfo); $this->_mainContent->assign("userVote", $userVote); $searchModel = new SearchModel(); $ret = $searchModel->search($thread["title"], 0, 11); $relativeThread = json_decode($ret, true); $this->_mainContent->assign("relativeThread", $relativeThread["hits"]["hits"]); $toplist = $cacheModel->getCache("toplist", "toplist"); if (!$toplist) { $toplistModel = new ToplistModel(); $toplist = $toplistModel->toplist(); $cacheModel->createCache("toplist", "toplist", $toplist); } $this->_mainContent->assign("toplist", $toplist); if (isset($this->isEmailValidated)) { $this->_mainContent->assign("isEmailValidated", $this->isEmailValidated); } $this->_mainContent->assign("reputation", $reputation); $this->setTitle($thread["title"]); $this->display(); }