コード例 #1
0
ファイル: article_controller.php プロジェクト: rainsun/nForum
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (!isset($this->params['name'])) {
         $this->error(ECode::$BOARD_NONE);
     }
     try {
         $boardName = $this->params['name'];
         if (preg_match("/^\\d+\$/", $boardName)) {
             throw new BoardNullException();
         }
         $this->_board = Board::getInstance($boardName);
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     if (isset($this->params['url']['mode'])) {
         $mode = (int) trim($this->params['url']['mode']);
         if (!$this->_board->setMode($mode)) {
             $this->error(ECode::$BOARD_NOPERM);
         }
     }
     if (!$this->_board->hasReadPerm(User::getInstance())) {
         if (!$this->ByrSession->isLogin) {
             $this->requestLogin();
         }
         $this->error(ECode::$BOARD_NOPERM);
     }
     $this->_board->setOnBoard();
     $this->ByrSession->Cookie->write("XWJOKE", "hoho", false);
 }
コード例 #2
0
ファイル: board_controller.php プロジェクト: tilitala/nForum
 public function beforeFilter()
 {
     parent::beforeFilter();
     if (isset($this->params['name'])) {
         $bName = trim($this->params['name']);
     } else {
         $this->error(ECode::$BOARD_NONE);
     }
     try {
         $this->_board = Board::getInstance($bName);
         if ($this->_board->isDir()) {
             throw new BoardNullException();
         }
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_NONE);
     }
     if (isset($this->params['mode'])) {
         $mode = (int) trim($this->params['mode']);
         if (!$this->_board->setMode($mode)) {
             $this->error(ECode::$BOARD_NOPERM);
         }
     }
     if (!$this->_board->hasReadPerm(User::getInstance())) {
         $this->error(ECode::$BOARD_NOPERM);
     }
     $this->_board->setOnBoard();
 }
コード例 #3
0
ファイル: board_controller.php プロジェクト: tilitala/nForum
 public function beforeFilter()
 {
     parent::beforeFilter();
     App::import("vendor", array("model/board", "inc/pagination"));
     if (!isset($this->params['name'])) {
         $this->error(ECode::$BOARD_NONE);
     }
     try {
         $boardName = $this->params['name'];
         if (preg_match("/^\\d+\$/", $boardName)) {
             throw new BoardNullException();
         }
         $this->_board = Board::getInstance($boardName);
         if ($this->_board->isDir()) {
             throw new BoardNullException();
         }
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     if (isset($this->params['url']['mode'])) {
         $mode = (int) trim($this->params['url']['mode']);
         $this->_board->setMode($mode);
     }
     if (!$this->_board->hasReadPerm(User::getInstance())) {
         $this->error(ECode::$BOARD_NOPERM);
     }
     $this->_board->setOnBoard();
 }
コード例 #4
0
 public function delete()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     if (!isset($this->params['form']['dir']) || !isset($this->params['form']['name'])) {
         $this->error();
     }
     $dir = $this->params['form']['dir'] == '1';
     $val = trim($this->params['form']['name']);
     $level = $this->params['num'];
     try {
         $fav = Favor::getInstance($level);
     } catch (FavorNullException $e) {
         $this->error(ECode::$USER_FAVERROR);
     }
     if ($val == "") {
         $this->error();
     }
     if ($dir) {
         if (!$fav->delete($val, Favor::$DIR)) {
             $this->error();
         }
     } else {
         App::import('vendor', 'model/board');
         try {
             $board = Board::getInstance($val);
             if (!$fav->delete($board, Favor::$BOARD)) {
                 $this->error();
             }
         } catch (BoardNullException $e) {
             $this->error();
         }
     }
     try {
         $fav = Favor::getInstance($level);
     } catch (FavorNullException $e) {
         $this->error(ECode::$USER_FAVERROR);
     }
     $this->set('data', $this->_favor($fav));
 }
コード例 #5
0
ファイル: index_controller.php プロジェクト: rainsun/nForum
 public function ajax_add()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     $this->requestLogin();
     $db = DB::getInstance();
     $u = User::getInstance();
     if (!$u->isAdmin()) {
         $sql = "select count(*) as num from pl_vote where status=1 and start>=? and uid=?";
         $res = $db->one($sql, array(strtotime(date("Y-m-d", time())), $u->userid));
         if ($res !== false && $res['num'] >= 2) {
             $this->error("每天你最多开启两次投票");
         }
     }
     $subject = @trim($this->params['form']['subject']);
     $desc = @trim($this->params['form']['desc']);
     $end = @trim($this->params['form']['end']);
     $type = @trim($this->params['form']['type']);
     $limit = @trim($this->params['form']['limit']);
     $result_voted = isset($this->params['form']['result_voted']) ? 1 : 0;
     if (empty($subject) || empty($end)) {
         $this->error();
     }
     if ($type != "0" && $type != "1") {
         $type = 0;
     }
     if (empty($limit) || intval($limit) < 2 || intval($limit) > 19) {
         $limit = 0;
     }
     if (strtotime($end) === false || !preg_match("/\\d{4}(-\\d{2}){2}/", $end)) {
         $this->error("截止日期错误");
     }
     $items = array();
     foreach ($this->params['form'] as $k => $v) {
         if (preg_match('/^i\\d+$/', $k) && trim($v) != "") {
             $items[] = nforum_iconv('UTF-8', $this->encoding, trim($v));
         }
     }
     $realNum = count($items);
     if ($realNum < 2 || $realNum > 20) {
         $this->error("选项数量错误,发起投票失败");
     }
     if ($limit > $realNum) {
         $limit = $realNum;
     }
     $subject = nforum_iconv('UTF-8', $this->encoding, $subject);
     $desc = nforum_iconv('UTF-8', $this->encoding, $desc);
     $vid = Vote::add($u->userid, $subject, $desc, strtotime($end), $type, $limit, $items, $result_voted);
     $site = Configure::read("site");
     $a_title = $subject;
     $a_content = "主题:{$subject}\n描述:{$desc}\n发起人:{$u->userid}\n类型:" . ($type == 0 ? '单选' : '多选') . "\n截止日期:{$end}\n链接:[url={$site['domain']}{$site['prefix']}/vote/view/{$vid}]{$site['domain']}{$site['prefix']}/vote/view/{$vid}[/url]\n[vote={$vid}][/vote]";
     App::import("vendor", "model/article");
     $aid = Article::autoPost($this->_board, $a_title, $a_content);
     $db->update("pl_vote", array("aid" => $aid), "where vid=?", array($vid));
     if (isset($this->params['form']['b'])) {
         App::import("vendor", "model/board");
         try {
             $board = Board::getInstance(trim($this->params['form']['b']));
             if ($board->hasPostPerm($u)) {
                 Article::autoPost($board->NAME, '[投票]' . $a_title, $a_content);
             }
         } catch (Exception $e) {
         }
     }
     $ret['ajax_code'] = "发起投票成功";
     $ret['default'] = "/vote?c=list&u=" . $u->userid;
     $ret['list'][] = array("text" => '我的投票', "url" => "/vote?c=list&u=" . $u->userid);
     $ret['list'][] = array("text" => '热门投票', "url" => "/vote?c=hot");
     $this->set('no_html_data', $ret);
 }
コード例 #6
0
ファイル: favor_controller.php プロジェクト: tilitala/nForum
 public function ajax_change()
 {
     if (!isset($this->params['form']['ac']) || !isset($this->params['form']['v'])) {
         $this->error();
     }
     $action = $this->params['form']['ac'];
     $val = $this->params['form']['v'];
     $level = $this->params['num'];
     try {
         $fav = Favor::getInstance($level);
     } catch (FavorNullException $e) {
         $this->error(ECode::$USER_FAVERROR);
     }
     if ($val == "") {
         $this->error();
     }
     switch ($action) {
         case "ab":
             try {
                 $val = Board::getInstance($val);
                 if (!$fav->add($val, Favor::$BOARD)) {
                     $this->error();
                 }
             } catch (Exception $e) {
                 $this->error(ECode::$BOARD_UNKNOW);
             }
             break;
         case "ad":
             if (!$fav->add(nforum_iconv("utf-8", $this->encoding, $val), Favor::$DIR)) {
                 $this->error();
             }
             break;
         case "db":
             try {
                 $val = Board::getInstance($val);
                 if (!$fav->delete($val, Favor::$BOARD)) {
                     $this->error();
                 }
             } catch (Exception $e) {
                 $this->error(ECode::$BOARD_UNKNOW);
             }
             break;
         case "dd":
             if (!$fav->delete($val, Favor::$DIR)) {
                 $this->error();
             }
             break;
     }
 }
コード例 #7
0
ファイル: search_controller.php プロジェクト: rainsun/nForum
 public function threads()
 {
     App::import('vendor', array('model/board', 'model/threads', 'inc/pagination'));
     $day = 7;
     $title1 = $title2 = $title3 = $author = '';
     if (isset($this->params['url']['title1'])) {
         $title1 = trim($this->params['url']['title1']);
     }
     if (isset($this->params['url']['title2'])) {
         $title2 = trim($this->params['url']['title2']);
     }
     if (isset($this->params['url']['titlen'])) {
         $title3 = trim($this->params['url']['titlen']);
     }
     if (isset($this->params['url']['author'])) {
         $author = trim($this->params['url']['author']);
     }
     if (isset($this->params['url']['day'])) {
         $day = intval($this->params['url']['day']);
     }
     $m = isset($this->params['url']['m']) && $this->params['url']['m'] == '1';
     $a = isset($this->params['url']['a']) && $this->params['url']['a'] == '1';
     $return = Configure::read('search.max');
     $res = array();
     if (!isset($this->params['url']['boards'])) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     $boards = $this->params['url']['boards'];
     foreach (explode('|', $boards) as $b) {
         try {
             $brd = Board::getInstance($b);
             $res = array_merge($res, Threads::search($brd, $title1, $title2, $title3, $author, $day, $m, $a, $return));
         } catch (BoardNullException $e) {
         }
     }
     $count = isset($this->params['url']['count']) ? $this->params['url']['count'] : Configure::read("pagination.threads");
     if (($count = intval($count)) <= 0) {
         $count = Configure::read("pagination.threads");
     }
     if ($count > Configure::read('plugins.api.page_item_limit')) {
         $count = Configure::read("pagination.threads");
     }
     $page = isset($this->params['url']['page']) ? $this->params['url']['page'] : 1;
     $page = intval($page);
     $pagination = new Pagination(new ArrayPageableAdapter($res), $count);
     $articles = $pagination->getPage($page);
     $wrapper = Wrapper::getInstance();
     $data = array();
     $data['pagination'] = $wrapper->page($pagination);
     foreach ($articles as $v) {
         $data['threads'][] = $wrapper->article($v, array('threads' => true));
     }
     $this->set('data', $data);
 }
コード例 #8
0
ファイル: elite_controller.php プロジェクト: tilitala/nForum
 public function file()
 {
     if (!isset($this->params['url']['pos']) && !preg_match("/ajax_file.json\$/", $this->here) && !$this->spider) {
         $this->redirect('elite/path?v=' . preg_replace("|/([^/]+)/*\$|", "&f=", trim($this->params['url']['v'])) . trim($this->params['url']['v']));
     }
     $path = Configure::read("elite.root") . "/";
     $boardName = "";
     $articles = array();
     if (isset($this->params['url']['v'])) {
         $path .= preg_replace("/^\\//", "", trim($this->params['url']['v']));
     }
     $u = User::getInstance();
     if (bbs_ann_traverse_check($path, $u->userid) < 0) {
         if (!$this->ByrSession->isLogin) {
             $this->requestLogin();
         }
         $this->error(ECode::$ELITE_NODIR);
     }
     $up_dirs = array();
     $up_cnt = $this->_getUpdir($path, $boardName, $up_dirs);
     if ($boardName) {
         try {
             $brd = Board::getInstance($boardName);
         } catch (BoardNullException $e) {
             $this->error(ECode::$ELITE_NODIR);
         }
         if (!$brd->hasReadPerm($u)) {
             if (!$this->ByrSession->isLogin) {
                 $this->requestLogin();
             }
             $this->error(ECode::$ELITE_NODIR);
         }
         if ($brd->isNormal()) {
             $this->cache(true, @filemtime($path));
         }
     }
     $e = new Elite($path);
     if (isset($this->params['url']['pos'])) {
         $pos = intval($this->params['url']['pos']);
         if ($pos == 0) {
             $this->_stop();
         }
         $e->getAttach($pos);
         $this->_stop();
     }
     $content = $e->getHtml(true);
     $subject = '';
     if (preg_match("|标&nbsp;&nbsp;题: ([\\s\\S]*?)<br|", $content, $subject)) {
         $subject = trim($subject[1]);
     }
     if (Configure::read("ubb.parse")) {
         App::import("vendor", "inc/ubb");
         $content = preg_replace("'^(.*?<br \\/>.*?<br \\/>)'e", "XUBB::remove('\\1')", $content);
         $content = XUBB::parse($content);
     }
     $this->set(array('subject' => $subject, 'content' => $content));
 }
コード例 #9
0
ファイル: search_controller.php プロジェクト: tilitala/nForum
 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) . "&emsp;";
         $replyTime = $curTime > $last->POSTTIME ? date("Y-m-d", $last->POSTTIME) : date("H:i:s", $last->POSTTIME) . "&emsp;";
         $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);
 }
コード例 #10
0
ファイル: section.php プロジェクト: tilitala/nForum
 public function wGetList()
 {
     $arr = array();
     $brds = $this->getList();
     if (empty($brds)) {
         $arr[] = array("text" => ECode::msg(ECode::$SEC_NOBOARD), "url" => "");
         $arr = array("s" => "w-list-line", "v" => $arr);
     } else {
         foreach ($brds as $v) {
             $arr[] = array("text" => $v->DESC, "url" => "/board/{$v->NAME}");
         }
         $arr = array("s" => "w-list-float", "v" => $arr);
     }
     if ($this->isRoot()) {
         $file = BBS_HOME . "/xml/day_sec{$this->_num}.xml";
         $ret = array();
         if (file_exists($file)) {
             $xml = simplexml_load_file($file);
             if ($xml !== false) {
                 foreach ($xml->hotsubject as $v) {
                     $title = nforum_fix_gbk(urldecode($v->title));
                     try {
                         $brd = Board::getInstance(urldecode($v->board));
                         $ret[] = array("text" => '[<a style="color:blue" href="' . Configure::read("site.prefix") . "/board/" . $brd->NAME . '">' . $brd->DESC . '</a>] <a title="' . $title . '" href="' . Configure::read("site.prefix") . '/article/' . $v->board . "/" . $v->groupid . '">' . $title . '</a>', "url" => "");
                     } catch (BoardNullException $e) {
                     }
                 }
             }
         }
         if (empty($ret)) {
             $ret[] = array("text" => ECode::msg(ECode::$SEC_NOHOT), "url" => "");
         }
         $ret = array("s" => "w-list-line", "v" => $ret);
         return array(array("t" => "热门话题", "v" => $ret), array("t" => "版面列表", "v" => $arr));
     } else {
         return $arr;
     }
 }
コード例 #11
0
ファイル: widget_controller.php プロジェクト: tilitala/nForum
 public function index()
 {
     if (!isset($this->params['name'])) {
         $this->error();
     }
     $name = $this->params['name'];
     App::import('vendor', 'model/widget');
     try {
         $widget = Widget::getInstance($name);
     } catch (WidgetNullException $e) {
         $this->error($e->getMessage());
     }
     $wrapper = Wrapper::getInstance();
     $data = $wrapper->widget($widget);
     $list = $widget->wGetList();
     switch (array_shift(split('-', $name))) {
         case 'topten':
         case 'recommend':
             if (!is_array($list['v'])) {
                 break;
             }
             App::import('vendor', array('model/board', 'model/threads'));
             $article = array();
             foreach ($list['v'] as $v) {
                 if (isset($v['url'])) {
                     $ret = array();
                     preg_match("|^/article/(.*?)/(.*?)\$|", $v['url'], $ret);
                     if (empty($ret[1]) || empty($ret[2])) {
                         continue;
                     }
                     $board = rawurldecode($ret[1]);
                     $id = (int) $ret[2];
                     if ($widget->wGetName() == 'topten') {
                         $text = $v['text'];
                         $text = preg_replace("|<[^>]*?>|", '', $text);
                         if (preg_match("/\\((\\d+)\\)\$/", $text, $c)) {
                             $c = $c[1];
                         } else {
                             $c = 0;
                         }
                     }
                     try {
                         $t = $wrapper->article(Threads::getInstance($id, Board::getInstance($board)), array('threads' => true));
                         if ($widget->wGetName() == 'topten') {
                             $t['id_count'] = $c;
                             $t['title'] .= "({$c})";
                         }
                         $article[] = $t;
                     } catch (Exception $e) {
                         continue;
                     }
                 }
             }
             $data['article'] = $article;
             break;
         case 'section':
             if (!is_array($list[0]['v']['v'])) {
                 break;
             }
             App::import('vendor', array('model/board', 'model/threads'));
             $article = array();
             foreach ($list[0]['v']['v'] as $v) {
                 if (isset($v['text'])) {
                     $ret = array();
                     preg_match("|/article/(.+?)/(\\d+)|", $v['text'], $ret);
                     if (empty($ret[1]) || empty($ret[2])) {
                         continue;
                     }
                     $board = rawurldecode($ret[1]);
                     $id = (int) $ret[2];
                     try {
                         $article[] = $wrapper->article(Threads::getInstance($id, Board::getInstance($board)), array('threads' => true));
                     } catch (Exception $e) {
                         continue;
                     }
                 }
             }
             $data['article'] = $article;
             break;
         default:
             $this->error('no such widget');
     }
     $this->set('data', $data);
 }
コード例 #12
0
 private function _attOpInit()
 {
     $this->cache(false);
     if (!isset($this->params['name'])) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     $name = $this->params['name'];
     $u = User::getInstance();
     try {
         $brd = Board::getInstance($name);
         if (!$brd->hasPostPerm($u) || !$brd->isAttach()) {
             $this->error(ECode::$BOARD_NOPERM);
         }
     } catch (Exception $e) {
         $this->error(ECode::$BOARD_UNKNOW);
     }
     $this->_board = $brd;
     $this->set("bName", $this->_board->NAME);
 }
コード例 #13
0
ファイル: mail_controller.php プロジェクト: tilitala/nForum
 public function send()
 {
     if (!Mail::canSend()) {
         $this->error(ECode::$MAIL_SENDERROR);
     }
     $u = User::getInstance();
     $mail = false;
     if (isset($this->params['type']) && isset($this->params['num'])) {
         $type = $this->params['type'];
         $num = $this->params['num'];
         try {
             $mail = MAIL::getInstance($num, new MailBox($u, $type));
         } catch (Exception $e) {
         }
     }
     if ($this->RequestHandler->isPost()) {
         $title = $content = '';
         $sig = User::getInstance()->signature;
         if (isset($this->params['form']['title'])) {
             $title = trim($this->params['form']['title']);
         }
         if (isset($this->params['form']['content'])) {
             $content = $this->params['form']['content'];
         }
         $sig = 0;
         $bak = isset($this->params['form']['backup']) ? 1 : 0;
         $title = nforum_iconv($this->encoding, $this->appEncoding, $title);
         $content = nforum_iconv($this->encoding, $this->appEncoding, $content);
         try {
             if (false === $mail) {
                 //send new
                 if (!isset($this->params['form']['id'])) {
                     $this->error(ECode::$POST_NOID);
                 }
                 $id = trim($this->params['form']['id']);
                 Mail::send($id, $title, $content, $sig, $bak);
                 $this->redirect($this->_mbase . "/mail?m=" . ECode::$MAIL_SENDOK);
             } else {
                 //reply
                 $mail->reply($title, $content, $sig, $bak);
                 $this->redirect($this->_mbase . "/mail/{$type}?m=" . ECode::$MAIL_SENDOK);
             }
         } catch (MailSendException $e) {
             $this->error($e->getMessage());
         }
     }
     $uid = $title = $content = "";
     if (isset($this->params['type']) && isset($this->params['num'])) {
         $this->notice = "邮件-回复邮件";
         if (false === $mail) {
             //reply article
             try {
                 $b = Board::getInstance($type);
                 if (!$b->hasReadPerm($u)) {
                     $this->error(ECode::$BOARD_NOPERM);
                 }
                 $mail = Article::getInstance($num, $b);
             } catch (Exception $e) {
                 $this->error(ECode::$MAIL_NOMAIL);
             }
         }
         if (!strncmp($mail->TITLE, "Re: ", 4)) {
             $title = $mail->TITLE;
         } else {
             $title = "Re: " . $mail->TITLE;
         }
         $content = "\n" . $mail->getRef();
         //remove ref ubb tag
         $content = XUBB::remove($content);
         $uid = $mail->OWNER;
     } else {
         $this->notice = "邮件-新邮件";
     }
     $this->set("uid", $uid);
     $this->set("title", $title);
     $this->set("content", $content);
     $this->set("bak", $u->getCustom("mailbox_prop", 0));
 }
コード例 #14
0
 private function _attOpInit()
 {
     $this->requestLogin();
     $name = $this->params['name'];
     $u = User::getInstance();
     try {
         $brd = Board::getInstance($name);
         if (!$brd->hasPostPerm($u) || !$brd->isAttach()) {
             $this->error(ECode::$ARTICLE_NOEDIT);
         }
     } catch (BoardNullException $e) {
         $this->error(ECode::$BOARD_NONE);
     }
     $this->_board = $brd;
     App::import("vendor", "model/forum");
 }
コード例 #15
0
ファイル: board.php プロジェクト: tilitala/nForum
 /**
  * function search match with board name
  *
  * @param $name
  * @return array
  * @static
  * @access public
  */
 public static function search($name)
 {
     $boards = array();
     if (!bbs_searchboard(trim($name), 0, $boards)) {
         return array();
     }
     $ret = array();
     foreach ($boards as $v) {
         try {
             $ret[] = Board::getInstance($v['NAME']);
         } catch (BoardNullException $e) {
         }
     }
     return $ret;
 }
コード例 #16
0
ファイル: index_controller.php プロジェクト: tilitala/nForum
 public function view()
 {
     $this->css[] = "xwidget.css";
     $this->css['plugin']['vote'][] = "vote.css";
     $this->js['plugin']['vote'][] = "vote.js";
     $this->js[] = "forum.share.js";
     $this->notice[] = array("url" => "", "text" => "查看投票");
     $this->cache(false);
     if (!isset($this->params['vid'])) {
         $this->error("未知的投票");
     }
     $vid = intval($this->params['vid']);
     try {
         $vote = new Vote($vid);
     } catch (VoteNullException $e) {
         $this->error("未知的投票");
     }
     $u = User::getInstance();
     if ($vote->isDeleted() && !$u->isAdmin()) {
         $this->error("此投票已删除");
     }
     $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);
     }
     App::import('Sanitize');
     $info = 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 $k => $v) {
         $item[$k]["label"] = Sanitize::html($v["label"]);
         $item[$k]["percent"] = $vote->total === 0 ? 0 : round(intval($v['num']) * 100 / $vote->total);
         $item[$k]["on"] = $myres !== false && in_array($v['viid'], $myres['items']);
     }
     $this->set("board", $this->_board);
     $this->set("admin", $u->userid === $vote->uid || $u->isAdmin());
     $this->set("result_voted", $vote->result_voted);
     $this->set("no_result", !$vote->isEnd() && !$this->get('admin') && $vote->result_voted && !$voted);
     $this->set("vinfo", $info);
     $this->set("vitems", $item);
     try {
         $u = User::getInstance($vote->uid);
         $furl = $u->getFace();
     } catch (UserNullException $e) {
         $furl = false;
     }
     $this->set("furl", Sanitize::html($furl));
     $this->set("fwidth", $u->userface_width === 0 ? "" : $u->userface_width);
     $this->set("fheight", $u->userface_height === 0 ? "" : $u->userface_height);
     App::import('vendor', array('model/board', 'model/threads', 'inc/ubb'));
     try {
         $threads = Threads::getInstance($vote->aid, Board::getInstance($this->_board));
         $s = $threads->getTotalNum() - $this->_commentNum + 1;
         $articles = $threads->getRecord($s > 1 ? $s : 1, $this->_commentNum);
         $info = array();
         foreach ($articles as $v) {
             if ($v->OWNER === 'deliver') {
                 continue;
             }
             $tmp = array();
             try {
                 $own = User::getInstance($v->OWNER);
                 $tmp['uid'] = $own->userid;
                 $tmp['furl'] = Sanitize::html($own->getFace());
             } catch (UserNullException $e) {
                 $tmp['uid'] = $v->OWNER;
                 $tmp['furl'] = false;
             }
             $tmp['time'] = date("Y-m-d H:i:s", $v->POSTTIME);
             $content = $v->getPlant();
             $content = preg_replace("|<br/>【 在 deliver[\\s\\S]+<br/>: \\.{5,}<br/>|", '', $content);
             $content = preg_replace("/&nbsp;/", " ", $content);
             $content = preg_replace("/  /", "&nbsp;&nbsp;", $content);
             $content = preg_replace("|※ 修改:·([\\S]+) .*?FROM:[\\s]*([0-9a-zA-Z.:*]+)|", '', $content);
             $content = preg_replace("|※ 来源:.*FROM:[\\s]*([0-9a-zA-Z.:*]+)|", '', $content);
             $s = ($pos = strpos($content, "<br/><br/>")) === false ? 0 : $pos + 10;
             $e = ($pos = strpos($content, "<br/>--<br/>")) === false ? strlen($content) : $pos + 7;
             $content = preg_replace(array("'^(<br/>)+'", "|(<br/>)+--\$|"), array("", ""), substr($content, $s, $e - $s));
             if (Configure::read("ubb.parse")) {
                 $content = XUBB::parse($content);
             }
             $tmp['content'] = $content;
             $info[] = $tmp;
         }
         if (!strncmp($threads->TITLE, "Re: ", 4)) {
             $this->set("title", $threads->TITLE);
         } else {
             $this->set("title", 'Re: ' . $threads->TITLE);
         }
         $this->set("ajax_title", urlencode('投票:' . $threads->TITLE));
         $this->set("reid", $threads->ID);
         $this->set("more", $threads->getTotalNum() > $this->_commentNum + 1);
         $this->set("comments", $info);
     } catch (ThreadsNullException $e) {
         $this->set("comments", false);
     }
 }
コード例 #17
0
ファイル: mail_controller.php プロジェクト: tilitala/nForum
 public function reply()
 {
     $mail = $this->_sendInit();
     $this->js[] = "forum.post.js";
     $this->css[] = "post.css";
     $this->notice[] = array("url" => "/mail/send", "text" => "回复邮件");
     $u = User::getInstance();
     if (false === $mail) {
         //reply article
         if (!isset($this->params['type'])) {
             $this->error(ECode::$MAIL_NOBOX);
         }
         if (!isset($this->params['num'])) {
             $this->error(ECode::$MAIL_NOMAIL);
         }
         $type = $this->params['type'];
         $num = $this->params['num'];
         try {
             $b = Board::getInstance($type);
             if (!$b->hasReadPerm($u)) {
                 $this->error(ECode::$BOARD_NOPERM);
             }
             $mail = Article::getInstance($num, $b);
         } catch (Exception $e) {
             $this->error(ECode::$MAIL_NOMAIL);
         }
     }
     if (!strncmp($mail->TITLE, "Re: ", 4)) {
         $title = $mail->TITLE;
     } else {
         $title = "Re: " . $mail->TITLE;
     }
     $content = "\n" . $mail->getRef();
     //remove ref ubb tag
     $content = XUBB::remove($content);
     $this->set("rid", $mail->OWNER);
     $sigOption = array();
     foreach (range(0, $u->signum) as $v) {
         if ($v == 0) {
             $sigOption["{$v}"] = "不使用签名档";
         } else {
             $sigOption["{$v}"] = "使用第{$v}个";
         }
     }
     $sigOption["-1"] = "使用随机签名档";
     App::import('Sanitize');
     $title = Sanitize::html($title);
     $content = Sanitize::html($content);
     $this->set("title", $title);
     $this->set("content", $content);
     $this->set("sigOption", $sigOption);
     $this->set("sigNow", $u->signature);
     $this->set("bak", $u->getCustom("mailbox_prop", 0));
     $this->render('send');
 }
コード例 #18
0
ファイル: rss_controller.php プロジェクト: tilitala/nForum
 public function classic()
 {
     $map = array("recommend" => array("commend.xml", "近期热点活动", "/board/recommend"), "bless" => array("bless.xml", "十大祝福", "/board/Blessing"));
     if (!isset($this->params['file'])) {
         $this->_stop();
     }
     $key = strtolower(trim($this->params['file']));
     if (!array_key_exists($key, $map)) {
         $this->_stop();
     }
     $file = BBS_HOME . "/xml/" . $map[$key][0];
     if (!file_exists($file)) {
         $this->_stop();
     }
     $mTime = @filemtime($file);
     $this->cache(true, $mTime);
     $this->header("Content-Type: text/xml; charset=" . $this->encoding);
     $this->header("Content-Disposition: inline;filename={$key}.xml");
     $this->_cache_read($key, $mTime);
     $channel = $items = array();
     $channel['title'] = $map[$key][1];
     $channel['description'] = $this->_siteName . $map[$key][1];
     $channel['link'] = $this->_domain . $this->base . $map[$key][2];
     $channel['language'] = "zh-cn";
     $channel['generator'] = "nForum RSS Generator By xw";
     if ($mTime > 0) {
         $channel['lastBuildDate'] = $mTime;
     }
     $ret = array();
     $xml = simplexml_load_file($file);
     if ($xml == false) {
         return $ret;
     }
     foreach ($xml->hotsubject as $v) {
         $board = $v->o_board == "" ? $v->board : $v->o_board;
         $id = $v->o_groupid == 0 ? $v->groupid : $v->o_groupid;
         $link = $this->_domain . $this->base . '/article/' . $board . '/' . $id;
         $item = array("title" => nforum_fix_gbk(urldecode($v->title)), "link" => $link, "author" => $v->owner, "pubDate" => intval($v->time), "guid" => $link, "comments" => $link);
         try {
             $article = Article::getInstance(intval($v->groupid), Board::getInstance($v->board));
             $item['description'] = "<![CDATA[" . XUBB::parse($article->getHtml()) . "]]>";
         } catch (Exception $e) {
         }
         $items[] = $item;
     }
     $rss = new Rss($channel, $items);
     $out = $rss->getRss();
     $this->_cache_write($key, $mTime, $out);
     echo $out;
     $this->_stop();
 }