Beispiel #1
0
 public function onedaysummaryAction()
 {
     $now = time();
     $onedaybefore = $now - 60 * 60 * 24;
     $threadModel = new ThreadModel();
     $newThread = $threadModel->newThreadsFrom($onedaybefore);
     $topThread = $threadModel->topThreadsFrom(10, $onedaybefore);
     $bbsHero = $threadModel->topBbsHero(10, $onedaybefore);
     $newscenter = new NewscenterModel();
     $news = $newscenter->news(1, 10, "apple");
     $data = array();
     $data["newThread"] = $newThread;
     $data["topThread"] = $topThread;
     $data["bbsHero"] = $bbsHero;
     $data["news"] = $news;
     $mail = new MailModel();
     $userModel = new UserModel();
     $users = $userModel->dailyNewsUser();
     foreach ($users as $user) {
         $data["user"] = $user;
         $page = $this->makePage("MailTemplate", "dailysummary", $data);
         $mail->generateMail($user["email"], "OurCoders社区 <*****@*****.**>", "OurCoders社区每日精选", $page, 0);
     }
     echo "ok";
 }
Beispiel #2
0
function parseattach($aid)
{
    $threadModel = new ThreadModel();
    $attach = $threadModel->attach($aid);
    if ($attach["isimage"] == 1) {
        $return = "<img src='/attachments/{$attach['attachment']}'/>";
    } else {
        $return = "<p>附件:<a href='/attachments/{$attach['attachment']}'>{$attach['filename']}</a></p>";
    }
    return $return;
}
Beispiel #3
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();
 }
Beispiel #4
0
 public function nameAction()
 {
     $tag = urldecode($this->strVal(3));
     $page = $this->intVal(4);
     if ($page == 0) {
         $page = 1;
     }
     $threadModel = new ThreadModel();
     $threadCount = $threadModel->threadsCountByTag($tag);
     $threadPageSize = 40;
     $threads = $threadModel->threadsByTag($tag, $page, $threadPageSize);
     $pageControl = ToolModel::pageControl($page, $threadCount, $threadPageSize, "<a href='/tag/name/{$tag}/#page#/'>", 0);
     $object["threads"] = $threads;
     $object["pageControl"] = $pageControl;
     $content = $this->doTemplate("Module", "thread", $object);
     $this->_mainContent->assign("content", $content);
     $relatedTags = $threadModel->relatedTags($tag);
     $this->_mainContent->assign("relatedTags", $relatedTags);
     $this->_mainContent->assign("tag", $tag);
     $this->display();
 }
Beispiel #5
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();
 }
 public static function insertThread($title, $content, $subcategory, $user)
 {
     $thread = new ThreadModel($title, $content, $subcategory, $user);
     return $thread->addThread();
 }
Beispiel #7
0
 public function banuserAction()
 {
     $userModel = new UserModel();
     $threadModel = new ThreadModel();
     if ($_POST) {
         $userid = $_POST["userid"];
         if ($userid <= 0 || $userid == 2) {
             header('HTTP/1.1 301 Moved Permanently');
             header("location:/home/");
             die;
         }
         $userModel->banUser($userid);
         if ($_POST["delallthread"]) {
             $threadModel->delUserAllThread($userid);
         }
         if ($_POST["delallreply"]) {
             $threadModel->delUserAllReply($userid);
         }
         header('HTTP/1.1 301 Moved Permanently');
         header("location:/user/show/{$userid}/");
         die;
     }
     $id = $this->intVal(3);
     if ($id == 0 || $id == 2 || $this->userid != 2) {
         header('HTTP/1.1 301 Moved Permanently');
         header("location:/home/");
     }
     $userinfo = $userModel->userInfo($id);
     $userinfo["image"] = DiscuzModel::get_avatar($id, "middle");
     $userinfo["threadscreate"] = $threadModel->threadsByUserid($id, 5);
     $this->_mainContent->assign("user", $userinfo);
     $this->display();
 }
Beispiel #8
0
 public function dataAction()
 {
     $id = $this->intVal(3);
     $threadModel = new ThreadModel();
     $userModel = new UserModel();
     $reputation = $userModel->reputation($this->userid);
     $thread = $threadModel->threadById($id);
     if (!$thread || $thread["del"] == 1) {
         header("HTTP/1.1 301 Moved Permanently");
         header("location: /home/");
         die;
     }
     $replys = $threadModel->replysById($id);
     $replysText = "";
     foreach ($replys as $reply) {
         $replysText .= "{$reply['name']}说道:{$reply['content']}\r\n";
     }
     $thread["replysText"] = $replysText;
     $url = "http://" . SEARCHSERVER . ":9200/ourcoders/thread/{$id}/";
     $data = ToolModel::postJSON($url, json_encode($thread));
     echo $data;
 }
 public function delete($id)
 {
     $this->db->trans_start();
     # remove bookmark related employee
     $this->load->model("BookmarkModel");
     $bookmark = new BookmarkModel();
     $bookmark->delete_by_employee($id);
     # remove follower related employee
     $this->load->model("FollowerModel");
     $follower = new FollowerModel();
     $follower->delete_by_employee($id);
     # remove activity related employee
     $this->load->model("EmployeeActivityModel");
     $activity = new EmployeeActivityModel();
     $activity->delete_by_employee($id);
     # remove cv list of experience related employee
     $this->load->model("ExperienceModel");
     $experience = new ExperienceModel();
     $experience->delete_by_employee($id);
     # remove cv list of education related employee
     $this->load->model("PortfolioModel");
     $education = new PortfolioModel();
     $education->delete_by_employee($id);
     # remove thread list related employee
     $this->load->model("ThreadModel");
     $thread = new ThreadModel();
     $thread->delete_by_employee($id);
     # remove application ever sent
     $this->load->model("ApplicationModel");
     $application = new ApplicationModel();
     $application->delete_by_employee($id);
     # remove employee itself
     $condition = array(EmployeeModel::$primary_key => $id);
     $this->db->delete(EmployeeModel::$table_name, $condition);
     $this->db->trans_complete();
     return $this->db->trans_status();
 }