Example #1
0
 public function indexAction()
 {
     header('Pragma: ');
     header("cache-control: s-maxage=600");
     $allModel = new AllModel();
     $page = $this->intVal(3);
     if ($page == 0) {
         $page = 1;
     }
     $size = 30;
     $cacheModel = new FilecacheModel();
     $thread = new ThreadModel();
     $threadCount = $thread->threadCount();
     $threadPageSize = 40;
     $threads = $thread->threads(1, $threadPageSize);
     $pageControl = ToolModel::pageControl(1, $threadCount, $threadPageSize, "<a href='/thread/index/#page#/'>", 0);
     $object["threads"] = $threads;
     $object["pageControl"] = $pageControl;
     $content = $this->doTemplate("Module", "thread", $object);
     $this->_mainContent->assign("content", $content);
     $users = $cacheModel->getCache("topusers", "home");
     if (!$users) {
         $userModel = new UserModel();
         $users = $userModel->users(1, 10);
         $cacheModel->createCache("topusers", "home", $users);
     }
     $this->_mainContent->assign("users", $users);
     $threadModel = new ThreadModel();
     $this->_mainContent->assign("pageControl", $pageControl);
     $this->_mainContent->assign("threads", $threads);
     $this->_mainContent->assign("userid", $this->userid);
     //experiment02
     $isBot = ToolModel::isBot();
     if ($this->userid == 0 && !$isBot) {
         if (rand(0, 1) == 0) {
             $experiment002 = "origin";
         } else {
             $experiment002 = "_blank";
         }
         $this->_view->assign("experiment002", $experiment002);
         $this->_mainContent->assign("experiment002", $experiment002);
     }
     $this->viewFile = "Home/index.html";
     if ($page > 1) {
         $this->setTitle("本站新闻 第" . $page . "页");
     }
     $this->display();
 }
Example #2
0
 public function showAction()
 {
     header('Pragma: ');
     header("cache-control: s-maxage=600");
     $id = $this->intVal(3);
     if ($id == 0) {
         header('HTTP/1.1 301 Moved Permanently');
         header("location:/user/show/0/");
     }
     $userModel = new UserModel();
     $threadModel = new ThreadModel();
     $cacheModel = new FilecacheModel();
     $userinfo = $cacheModel->getCache("userinfo", "{$id}");
     if (!$userinfo) {
         $userinfo = $userModel->userInfo($id);
         $userinfo["image"] = DiscuzModel::get_avatar($id, "middle");
         $userinfo["threadscreate"] = $threadModel->threadsByUserid($id);
         $userinfo["threadsreply"] = $threadModel->threadsReplyByUserid($id);
         $cacheModel->createCache("userinfo", "{$id}", $userinfo);
     }
     $this->_mainContent->assign("user", $userinfo);
     $this->setTitle($userinfo["username"]);
     $this->display();
 }
Example #3
0
 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();
 }