public function index() { $this->js[] = "forum.refer.js"; $this->css[] = "mail.css"; $type = Refer::$AT; $pageBar = ""; if (isset($this->params['type'])) { $type = $this->params['type']; } try { $refer = new Refer(User::getInstance(), $type); } catch (ReferNullException $e) { $this->error(ECode::$REFER_NONE); } $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; App::import('vendor', "inc/pagination"); try { $pagination = new Pagination($refer, Configure::read("pagination.mail")); $articles = $pagination->getPage($p); } catch (Exception $e) { $this->error(ECode::$REFER_NONE); } if ($refer->getTotalNum() > 0) { $info = array(); App::import('Sanitize'); foreach ($articles as $v) { $info[] = array("index" => $v['INDEX'], "id" => $v['ID'], "board" => $v['BOARD'], "user" => $v['USER'], "title" => Sanitize::html($v['TITLE']), "time" => date("Y-m-d H:i:s", $v['TIME']), "read" => $v['FLAG'] === Refer::$FLAG_READ); } $this->set("info", $info); } $link = "{$this->base}/refer/{$type}?p=%page%"; $this->set("pageBar", $pagination->getPageBar($p, $link)); $this->set("pagination", $pagination); $this->set("type", $type); }
public function index() { $this->js[] = "forum.adv.js"; $this->css[] = "adv.css"; $p = 1; if (isset($this->params['url']['p'])) { $p = $this->params['url']['p']; } $adv = new Adv(); $adv->type = $this->_type; $search = array(); if (isset($this->params['url']['remark']) && trim($this->params['url']['remark']) != '') { $search['remark'] = $adv->search = trim($this->params['url']['remark']); } if (isset($this->params['url']['sTime']) && trim($this->params['url']['sTime']) != '') { $search['sTime'] = $adv->search_start = trim($this->params['url']['sTime']); } if (isset($this->params['url']['eTime']) && trim($this->params['url']['eTime']) != '') { $search['eTime'] = $adv->search_end = trim($this->params['url']['eTime']); } App::import('vendor', "inc/pagination"); $page = new Pagination($adv, 30); $res = $page->getPage($p); $ret['page'] = $page->getCurPage(); $ret['total'] = $adv->getTotalNum(); $ret['aPath'] = Configure::read("adv.path"); foreach ($res as $v) { $ret['info'][] = $v; } $this->set($ret); $this->set($search); $this->set("dir", Configure::read('adv.path')); $this->set("type", $this->_type == 1 || $this->_type == 2 ? true : false); $this->set("advType", $this->_type); $this->set("hasPrivilege", isset($res[0]['privilege']) && '1' == $res[0]['privilege']); $query = ''; foreach ($search as $k => $v) { $query .= '&' . $k . '=' . $v; } $this->set("pageBar", $page->getPageBar($p, "?p=%page%" . $query)); $this->set("pagination", $page); }
public function index() { $this->js[] = "forum.mail.js"; $this->css[] = "mail.css"; $type = MailBox::$IN; $pageBar = ""; if (isset($this->params['type'])) { $type = $this->params['type']; } try { $mailBox = new MailBox(User::getInstance(), $type); } catch (MailBoxNullException $e) { $this->error(ECode::$MAIL_NOBOX); } $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; App::import('vendor', "inc/pagination"); try { $pagination = new Pagination($mailBox, Configure::read("pagination.mail")); $mails = $pagination->getPage($p); } catch (MailDataNullException $e) { $this->error(ECode::$MAIL_NOMAIL); } if ($mailBox->getTotalNum() > 0) { $info = array(); App::import('Sanitize'); foreach ($mails as $v) { $info[] = array("tag" => $this->_getTag($v), "read" => $v->isRead(), "num" => $v->num, "sender" => $v->OWNER, "title" => Sanitize::html($v->TITLE), "time" => date("Y-m-d H:i:s", $v->POSTTIME), "size" => $v->EFFSIZE); } $this->set("info", $info); } $link = "{$this->base}/mail/{$type}?p=%page%"; $this->set("pageBar", $pagination->getPageBar($p, $link)); $this->set("pagination", $pagination); $this->set("type", $type); $this->set("desc", $mailBox->desc); }
public function index() { $this->js[] = "forum.friend.js"; $this->css[] = "mail.css"; $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; try { $f = new Friend(User::getInstance()); App::import("vendor", "inc/pagination"); $pagination = new Pagination($f, Configure::read("pagination.friend")); $friends = $pagination->getPage($p); } catch (FriendNullException $e) { $this->error(); } if ($f->getTotalNum() > 0) { $info = array(); foreach ($friends as $v) { $info[] = array("fid" => $v->userid, "desc" => $v->exp); } $this->set("friends", $info); } $link = "{$this->base}/friend?p=%page%"; $this->set("pageBar", $pagination->getPageBar($p, $link)); $this->set("pagination", $pagination); }
public function index() { $this->cache(false); $this->css[] = "article.css"; $this->js[] = "forum.share.js"; $this->js[] = "forum.article.js"; $this->_getNotice(); $this->notice[] = array("url" => "", "text" => "阅读文章"); App::import('Sanitize'); App::import('vendor', array("inc/pagination", "inc/astro")); if (!isset($this->params['gid']) || $this->params['gid'] == '0') { $this->error(ECode::$ARTICLE_NONE); } try { $gid = $this->params['gid']; $this->_threads = Threads::getInstance($gid, $this->_board); } catch (ThreadsNullException $e) { $this->error(ECode::$ARTICLE_NONE); } //article jump if (isset($this->params['url']['s'])) { $article = $this->_threads->getArticleById(intval($this->params['url']['s'])); if (null !== $article) { $pos = $article->getPos(); $page = ceil(($pos + 1) / Configure::read("pagination.article")); $this->redirect("/article/{$this->_board->NAME}/{$gid}?p={$page}#a{$pos}"); } $this->redirect("/article/{$this->_board->NAME}/{$gid}"); } //filter author $auF = $au = false; if (isset($this->params['url']['au'])) { $tmp = $this->_threads->getRecord(1, $this->_threads->getTotalNum()); $auF = array(); $au = trim($this->params['url']['au']); foreach ($tmp as $v) { if ($v->OWNER == $au) { $auF[] = $v; } } $auF = new ArrayPageableAdapter($auF); } $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; $pagination = new Pagination(false !== $au ? $auF : $this->_threads, Configure::read("pagination.article")); $articles = $pagination->getPage($p); $u = User::getInstance(); if ($bm = $u->isBM($this->_board) || $u->isAdmin()) { $this->js[] = "forum.manage.js"; } $info = array(); $curTime = strtotime(date("Y-m-d", time())); $isUbb = Configure::read("ubb.parse"); $isSyn = Configure::read("ubb.syntax"); $hasSyn = false; foreach ($articles as $v) { try { $own = User::getInstance($v->OWNER); $astro = Astro::getAstro($own->birthmonth, $own->birthday); if ($own->getCustom("userdefine0", 29) == 0) { $hide = true; $gender = -1; } else { $hide = false; $gender = $own->gender == "77" ? 0 : 1; } $user = array("id" => $own->userid, "name" => Sanitize::html($own->username), "gender" => $gender, "furl" => Sanitize::html($own->getFace()), "width" => $own->userface_width === 0 ? "" : $own->userface_width, "height" => $own->userface_height === 0 ? "" : $own->userface_height, "post" => $own->numposts, "astro" => $astro['name'], "online" => $own->isOnline(), "level" => $own->getLevel(), "time" => date($curTime > $own->lastlogin ? "Y-m-d" : "H:i:s", $own->lastlogin), "first" => date("Y-m-d", $own->firstlogin), "hide" => $hide); } catch (UserNullException $e) { $user = false; } $content = $v->getHtml(true); //hard to match all the format of ip //$pattern = '/<font class="f[0-9]+">※( | )来源:·.+?\[FROM:( | )[0-9a-zA-Z.:*]+\]<\/font><font class="f000">( +<br \/>)+ +<\/font>/'; //preg_match($pattern, $content, $match); //$content = preg_replace($pattern, "", $content); if ($isUbb) { //remove ubb of nickname in first and title second line preg_match("'^(.*?<br \\/>.*?<br \\/>)'", $content, $res); $content = preg_replace("'(^.*?<br \\/>.*?<br \\/>)'", '', $content); $content = XUBB::remove($res[1]) . $content; $content = XUBB::parse($content); //check syntax if (!empty($isSyn) && preg_match("/<pre class=\"brush:/", $content)) { $hasSyn = true; } //parse vote if ($v->OWNER === 'deliver' && in_array('vote', Configure::read('plugins.install'))) { $vid = array(); if (preg_match("'\\[vote=(\\d+)\\]\\[/vote\\]'", $content, $vid)) { $content = preg_replace("'\\[vote=\\d+\\]\\[/vote\\]'", '', $content); App::import("vendor", array("inc/db", "vote.vote")); $vid = $vid[1]; try { $vote = new Vote($vid); if (!$vote->isDeleted()) { $this->css['plugin']['vote'][] = "vote.css"; $this->js['plugin']['vote'][] = "vote.js"; $myres = $vote->getResult($u->userid); $voted = false; if ($myres !== false) { $voted = true; $myres['time'] = date("Y-m-d H:i:s", $myres['time']); $this->set("myres", $myres); } $vinfo = array("vid" => $vote->vid, "title" => Sanitize::html($vote->subject), "desc" => nl2br(Sanitize::html($vote->desc)), "start" => date("Y-m-d H:i:s", $vote->start), "end" => date("Y-m-d", $vote->end), "num" => $vote->num, "type" => $vote->type, "limit" => $vote->limit, "aid" => $vote->aid, "isEnd" => $vote->isEnd(), "isDel" => $vote->isDeleted(), "voted" => $voted, "uid" => $vote->uid); $item = $vote->items; foreach ($item as $kk => $vv) { $item[$kk]["label"] = Sanitize::html($vv["label"]); $item[$kk]["percent"] = $vote->total === 0 ? 0 : round(intval($vv['num']) * 100 / $vote->total); $item[$kk]["on"] = $myres !== false && in_array($vv['viid'], $myres['items']); } $this->set("vinfo", $vinfo); $this->set("vitems", $item); $this->set("result_voted", $vote->result_voted); $this->set("no_result", !($u->userid === $vote->uid || $u->isAdmin()) && $vote->result_voted && !$voted); } } catch (VoteNullException $e) { } } } } $info[] = array("id" => $v->ID, "owner" => $user, "op" => $v->OWNER == $u->userid || $bm ? 1 : 0, "pos" => $v->getPos(), "poster" => $v->OWNER, "content" => $content, "subject" => $v->isSubject(), 'g' => $v->isG(), 'm' => $v->isM(), 'l' => $v->isNoRe(), 'p' => $v->isPercent(), 's' => $v->isSharp(), 'x' => $v->isX()); } $this->title = Sanitize::html($this->_threads->TITLE); $link = "{$this->base}/article/{$this->_board->NAME}/{$gid}?p=%page%"; if (false !== $auF) { $link .= "&au={$au}"; } $this->set("pageBar", $pagination->getPageBar($p, $link)); $this->set("pagination", $pagination); $this->set("bName", $this->_board->NAME); $this->set("gid", $gid); $this->set("anony", $this->_board->isAnony()); $this->set("tmpl", $this->_board->isTmplPost()); $this->set("info", $info); $this->set("title", $this->title); $this->set('hasSyn', $hasSyn); $this->set("au", $au); $this->set("bm", $bm); //for the quick reply, raw encode the space $this->set("reid", $this->_threads->ID); if (!strncmp($this->_threads->TITLE, "Re: ", 4)) { $reTitle = $this->_threads->TITLE; } else { $reTitle = "Re: " . $this->_threads->TITLE; } //hack for post with ajax,need utf-8 encoding $reTitle = nforum_iconv($this->encoding, 'utf-8', $reTitle); $this->set("reTitle", rawurlencode($reTitle)); //for default search day $this->set("searchDay", Configure::read("search.day")); $this->set("searchDay", Configure::read("search.day")); $this->jsr[] = "window.user_post=" . ($this->_board->hasPostPerm($u) && !$this->_board->isDeny($u) ? "true" : "false") . ";"; }
public function index() { $this->css[] = "xwidget.css"; $this->css['plugin']['vote'][] = "vote.css"; $this->js['plugin']['vote'][] = "vote.js"; $this->cache(false); @($category = $this->params['url']['c']); $u = User::getInstance(); $time = time(); $yes = $time - 86400; $search = ''; if (isset($this->params['url']['s'])) { $search = trim(rawurldecode($this->params['url']['s'])); $search = nforum_iconv('utf-8', $this->encoding, $search); if ('' != $search) { App::import('Sanitize'); $this->set('search', Sanitize::html($search)); $search = addslashes($search); $search = " and (uid like '%{$search}%' or subject like '%{$search}%' or `desc` like '%{$search}%')"; } } switch ($category) { case 'hot': $title = "热门投票"; $sql = "select * from pl_vote where status=1 and end>{$yes} {$search} order by num desc, vid desc"; break; case 'list': @($user = $this->params['url']['u']); if ($u->userid != $user) { try { $user = User::getInstance($user); } catch (UserNullException $e) { $this->error(ECode::$USER_NOID); } } else { $user = $u; } $title = $user->userid == $u->userid ? "我的投票" : "{$user->userid}的投票"; $this->set("vote_user", $user->userid); $sql = "select * from pl_vote where status=1 and uid='{$user->userid}' {$search} order by vid desc"; break; case 'all': $title = "全部投票"; $sql = "select * from pl_vote where status=1 {$search} order by vid desc"; break; case 'join': $this->requestLogin(); $title = "我参与的投票"; $sql = "select * from pl_vote where status=1 and vid in (select vid from pl_vote_result where uid='{$u->userid}') {$search} order by vid desc"; break; case 'del': if (!$u->isAdmin()) { $this->error('你无权查看此类投票'); } $title = "已删除的投票"; $sql = "select * from pl_vote where status=0 {$search} order by vid desc"; break; default: $title = "最新投票"; $category = "new"; $sql = "select * from pl_vote where status=1 and end>{$yes} {$search} order by vid desc"; } $list = new VoteList($sql); App::import("vendor", "inc/pagination"); $page = new Pagination($list, 10); $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; $res = $page->getPage($p); if (count($res) == 0) { $info = false; } else { $info = array(); App::import('Sanitize'); foreach ($res as $v) { $info[] = array("vid" => $v->vid, "title" => Sanitize::html($v->subject), "start" => date("Y-m-d H:i:s", $v->start), "end" => date("Y-m-d", $v->end), "num" => $v->num, "isEnd" => $v->isEnd(), "isDel" => $v->isDeleted(), "admin" => $u->userid === $v->uid || $u->isAdmin(), "uid" => $v->uid); } } $query = $this->params['url']; unset($query['url']); unset($query['p']); unset($query['ext']); foreach ($query as $k => &$v) { $v = $k . '=' . rawurlencode($v); } $query[] = "p=%page%"; $link = "{$this->base}/vote?" . join("&", $query); $pageBar = $page->getPageBar($p, $link); $this->set("pageBar", $pageBar); $this->set("totalNum", $list->getTotalNum()); $this->set("info", $info); $this->set("category", $category); $this->set("voteTitle", $title); $this->notice[] = array("url" => "", "text" => $title); /* right rank*/ $week = nforum_cache_read("vote_week"); $month = nforum_cache_read("vote_month"); $year = nforum_cache_read("vote_year"); $this->set("week", $week); $this->set("month", $month); $this->set("year", $year); /* right rank end*/ }
public function online() { $this->requestLogin(); $this->css[] = "mail.css"; $this->notice[] = array("url" => "/online", "text" => "在线用户"); $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; try { App::import("vendor", "inc/pagination"); $f = Forum::getOnlineUser(); $pagination = new Pagination($f, Configure::read("pagination.friend")); $users = $pagination->getPage($p); } catch (FriendNullException $e) { $this->error(); } if ($f->getTotalNum() > 0) { $info = array(); foreach ($users as $v) { $info[] = array("fid" => $v->userid, "from" => $v->userfrom, "mode" => $v->mode, "idle" => sprintf('%02d:%02d', intval($v->idle / 60), $v->idle % 60)); } $this->set("friends", $info); } $link = "{$this->base}/online?p=%page%"; $this->set("pageBar", $pagination->getPageBar($p, $link)); $this->set("pagination", $pagination); }
public function article() { $this->js[] = "forum.board.js"; $this->css[] = "board.css"; $this->notice[] = array("url" => "", "text" => "ËÑË÷½á¹û"); App::import('Sanitize'); $day = $title1 = $title2 = $title3 = $author = $t = ""; if (isset($this->params['url']['t1'])) { $title1 = trim(rawurldecode($this->params['url']['t1'])); } if (isset($this->params['url']['t2'])) { $title2 = trim(rawurldecode($this->params['url']['t2'])); } if (isset($this->params['url']['tn'])) { $title3 = trim(rawurldecode($this->params['url']['tn'])); } if (isset($this->params['url']['au'])) { $author = trim($this->params['url']['au']); } if (isset($this->params['url']['d'])) { $day = intval($this->params['url']['d']); } $title1 = nforum_iconv('utf-8', $this->encoding, $title1); $title2 = nforum_iconv('utf-8', $this->encoding, $title2); $title3 = nforum_iconv('utf-8', $this->encoding, $title3); $m = isset($this->params['url']['m']); $a = isset($this->params['url']['a']); $full = isset($this->params['url']['f']); $site = Configure::read('search.site'); $return = Configure::read("search.max"); $res = array(); $u = User::getInstance(); if ($title1 == '' && $title3 == '' && $author == '' && !$m && !$a) { $res = array(); } else { if ($full && $site && $u->isAdmin()) { App::import('vendor', 'model/section'); $secs = array_keys(Configure::read("section")); foreach ($secs as $v) { $sec = Section::getInstance($v, Section::$ALL); foreach ($sec->getList() as $brd) { if (!$brd->isNormal()) { continue; } $res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return)); } } } else { $b = @$this->params['url']['b']; try { $brd = Board::getInstance($b); } catch (BoardNullException $e) { $this->error(ECode::$BOARD_NONE); } $res = Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return); } } $p = 1; if (isset($this->params['url']['p'])) { $p = $this->params['url']['p']; } App::import("vendor", "inc/pagination"); $page = new Pagination(new ArrayPageableAdapter($res), Configure::read("pagination.search")); $threads = $page->getPage($p); $info = false; $curTime = strtotime(date("Y-m-d", time())); $pageArticle = Configure::read("pagination.article"); foreach ($threads as $v) { $tabs = ceil($v->articleNum / $pageArticle); $last = $v->LAST; $postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . " "; $replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME) . " "; $info[] = array("title" => Sanitize::html($v->TITLE), "poster" => $v->isSubject() ? $v->OWNER : "ÔÌûÒÑɾ³ý", "postTime" => $postTime, "gid" => $v->ID, "last" => $last->OWNER, "replyTime" => $replyTime, "page" => $tabs, "bName" => $v->getBoard()->NAME, "num" => $v->articleNum - 1); } $this->set("info", $info); $query = $this->params['url']; unset($query['url']); unset($query['p']); unset($query['ext']); foreach ($query as $k => &$v) { $v = $k . '=' . rawurlencode($v); } $query[] = "p=%page%"; $link = "{$this->base}/s/article?" . join("&", $query); $this->set("pageBar", $page->getPageBar($p, $link)); $this->set("pagination", $page); }
public function mode() { $this->js[] = "forum.board.js"; $this->css[] = "board.css"; $this->_getNotice(); switch ($this->params['mode']) { case BOARD::$NORMAL: $tmp = '经典模式'; break; case BOARD::$DIGEST: $tmp = '文摘模式'; break; case BOARD::$MARK: $tmp = '保留模式'; break; case BOARD::$DELETED: $tmp = '回收模式'; break; case BOARD::$JUNK: $tmp = '纸篓模式'; break; case BOARD::$ORIGIN: $tmp = '原作模式'; break; default: $tmp = '主题模式'; } $this->notice[] = array("url" => "", "text" => $tmp); $this->cache(false); App::import('Sanitize'); $pageBar = ""; $p = isset($this->params['url']['p']) ? $this->params['url']['p'] : 1; $pagination = new Pagination($this->_board, Configure::read("pagination.threads")); $articles = $pagination->getPage($p); $u = User::getInstance(); if ($bm = $u->isBM($this->_board) || $u->isAdmin()) { $this->js[] = "forum.manage.js"; } $info = false; $curTime = strtotime(date("Y-m-d", time())); $sort = $this->_board->isSortMode(); foreach ($articles as $v) { $postTime = $curTime > $v->POSTTIME ? date("Y-m-d", $v->POSTTIME) : date("H:i:s", $v->POSTTIME) . " "; $info[] = array("tag" => $this->_getTag($v), "title" => Sanitize::html($v->TITLE), "poster" => $v->OWNER, "postTime" => $postTime, "id" => $sort ? $v->ID : $v->getPos(), "gid" => $v->GROUPID, "att" => $v->hasAttach()); } $this->title = Configure::read('site.name') . '-' . $this->_board->DESC; $this->set("info", $info); $link = "{$this->base}/board/{$this->_board->NAME}/mode/{$this->params['mode']}?p=%page%"; $this->set("pageBar", $pagination->getPageBar($p, $link)); $this->set("pagination", $pagination); $bms = split(" ", $this->_board->BM); foreach ($bms as &$v) { if (preg_match("/[^0-9a-zA-Z]/", $v)) { $v = array($v, false); } else { $v = array($v, true); } } $this->set("todayNum", $this->_board->getTodayNum()); $this->set("curNum", $this->_board->CURRENTUSERS); if (isset($this->_board->MAXONLINE)) { $this->set("maxNum", $this->_board->MAXONLINE); $this->set("maxTime", date("Y-m-d H:i:s", $this->_board->MAXTIME)); } $this->set("bms", $bms); $this->set("bName", $this->_board->NAME); $this->set("bm", $u->isBM($this->_board)); $this->set("tmpl", $this->_board->isTmplPost()); $this->set("hasVote", count($this->_board->getVotes()) != 0); $this->set("mode", (int) $this->params['mode']); //for default search day $this->set("searchDay", Configure::read("search.day")); //for elite path $this->set("elitePath", urlencode($this->_board->getElitePath())); $this->jsr[] = "window.user_post=" . ($this->_board->hasPostPerm($u) && !$this->_board->isDeny($u) ? "true" : "false") . ";"; }