Example #1
0
 function tagThreads($tagname, $size = 1000)
 {
     $sql = "SELECT *\n      FROM `cocoabbs_threadtags`\n      LEFT JOIN `cocoabbs_threads`\n      ON `cocoabbs_threadtags`.`tid` = `cocoabbs_threads`.`tid`\n      WHERE `tagname` = '{$tagname}' \n      ORDER BY `lastpost` DESC\n      LIMIT 0,{$size};";
     $result = $this->fetchArray($sql);
     $ret = array();
     if (count($result) == 0) {
         return $ret;
     }
     foreach ($result as $item) {
         $item["id"] = $item["tid"];
         $item["createtime"] = ToolModel::countTime($item["dateline"]);
         $item["updatetime"] = ToolModel::countTime($item["lastpost"]);
         $item["image"] = DiscuzModel::get_avatar($item["authorid"], "small");
         $item["title"] = stripslashes($item["subject"]);
         $item["createby"] = $item["author"];
         $item["createbyid"] = $item["authorid"];
         $item["lastreply"] = $item["lastposter"];
         $item["replys"] = $item["replies"];
         $ret[] = $item;
     }
     return $ret;
 }
Example #2
0
 private function saveAvatar()
 {
     $discuzPath = dirname(dirname(dirname(dirname(__FILE__))));
     $uploaderModel = new UploaderModel();
     $filename = $discuzPath . $_POST["fileurl"];
     $image = ToolModel::createImageFromFile($filename);
     unlink($filename);
     $imagex = imagesx($image);
     $imagey = imagesy($image);
     $cx = $_POST["cx"] * $imagex / $_POST["iw"];
     $cy = $_POST["cy"] * $imagey / $_POST["ih"];
     $cw = $_POST["cw"] * $imagex / $_POST["iw"];
     $ch = $_POST["ch"] * $imagey / $_POST["ih"];
     $image1 = $uploaderModel->crop($image, $cx, $cy, $cw, $ch, 180, 180);
     $image2 = $uploaderModel->crop($image, $cx, $cy, $cw, $ch, 80, 80);
     $image3 = $uploaderModel->crop($image, $cx, $cy, $cw, $ch, 48, 48);
     $userModel = new UserModel();
     $userid = $userModel->checklogin();
     $avpath = DiscuzModel::get_avatar_path($userid, "big");
     $path = dirname($avpath);
     ToolModel::makeDeepDir($path);
     imagejpeg($image1, $avpath, 85);
     $avpath = DiscuzModel::get_avatar_path($userid, "middle");
     imagejpeg($image2, $avpath, 85);
     $avpath = DiscuzModel::get_avatar_path($userid, "small");
     imagejpeg($image3, $avpath, 85);
 }
Example #3
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();
 }
Example #4
0
 public function users($page, $size, $order = "reputation")
 {
     $start = ($page - 1) * $size;
     $users = $this->select("cocoabbs_uc_members");
     if ($order == "date") {
         $this->orderby("regdate DESC");
     } else {
         if ($order == "money") {
             $this->orderby("money DESC");
         } else {
             if ($order == "shui") {
                 $this->fields("*,(posts*5+replys) as shui")->orderby("shui DESC");
             } else {
                 $this->orderby("reputation DESC");
             }
         }
     }
     $this->where("`validated` = 1")->limit("{$start},{$size}");
     $users = $this->fetchAll();
     $ret = array();
     if (count($users) == 0) {
         return $ret;
     }
     foreach ($users as $item) {
         $item["regdate"] = ToolModel::countTime($item["regdate"]);
         if ($item["lastlogintime"] != 0) {
             $item["lastlogintime"] = ToolModel::countTime($item["lastlogintime"]);
         } else {
             $item["lastlogintime"] = "没有记录";
         }
         $item["image"] = DiscuzModel::get_avatar($item["uid"], "small");
         $ret[] = $item;
     }
     return $ret;
 }
Example #5
0
 public function threadsByTag($tag, $page, $pageSize)
 {
     $start = ($page - 1) * $pageSize;
     $countSql = "SELECT count(*) FROM `threads`\n      LEFT JOIN `threadtags` ON `threads`.`id` = `threadtags`.`tid` \n      WHERE `del` = 0 AND `tagname`='{$tag}'";
     $sql = "SELECT * FROM `threads`\n      LEFT JOIN `threadtags` ON `threads`.`id` = `threadtags`.`tid` \n      WHERE `del` = 0 AND `tagname`='{$tag}'\n      ORDER BY `id` DESC  \n      limit {$start},{$pageSize};";
     $result = $this->fetchArray($sql);
     $ret = array();
     if (count($result) == 0) {
         return $ret;
     }
     foreach ($result as $item) {
         $item["createtime"] = ToolModel::countTime($item["createdate"]);
         $item["updatetime"] = ToolModel::countTime($item["updatedate"]);
         $item["image"] = DiscuzModel::get_avatar($item["createbyid"], "small");
         $item["title"] = stripslashes($item["title"]);
         $item["tagArray"] = explode(",", $item["tags"]);
         $ret[] = $item;
     }
     return $ret;
 }