コード例 #1
0
ファイル: mail_controller.php プロジェクト: tilitala/nForum
 public function ajax_preview()
 {
     App::import('Sanitize');
     if (!isset($this->params['form']['title']) || !isset($this->params['form']['content'])) {
         $this->error();
     }
     $subject = rawurldecode(trim($this->params['form']['title']));
     $subject = nforum_iconv('utf-8', $this->encoding, $subject);
     if (strlen($subject) > 60) {
         $subject = nforum_fix_gbk(substr($subject, 0, 60));
     }
     $subject = Sanitize::html($subject);
     $content = $this->params['form']['content'];
     $content = nforum_iconv('utf-8', $this->encoding, $content);
     $content = preg_replace("/\n/", "<br />", Sanitize::html($content));
     if (Configure::read("ubb.parse")) {
         $content = XUBB::parse($content);
     }
     $this->set('no_html_data', array("subject" => $subject, "content" => $content));
 }
コード例 #2
0
ファイル: article_controller.php プロジェクト: rainsun/nForum
 public function post()
 {
     if ($this->_board->isReadOnly()) {
         $this->error(ECode::$BOARD_READONLY);
     }
     if (!$this->_board->hasPostPerm(User::getInstance())) {
         $this->error(ECode::$BOARD_NOPOST);
     }
     $article = false;
     if (isset($this->params['gid'])) {
         $reID = (int) $this->params['gid'];
         if ($this->_board->isNoReply()) {
             $this->error(ECode::$BOARD_NOREPLY);
         }
         try {
             $article = Article::getInstance($reID, $this->_board);
         } catch (ArticleNullException $e) {
             $this->error(ECode::$ARTICLE_NOREID);
         }
         if ($article->isNoRe()) {
             $this->error(ECode::$ARTICLE_NOREPLY);
         }
     } else {
         if ($this->_board->isTmplPost()) {
             $this->error(ECode::$TMPL_ERROR);
         }
         $reID = 0;
     }
     $single = isset($this->params['url']['s']) || isset($this->params['form']['s']);
     if ($this->RequestHandler->isPost()) {
         if (!isset($this->params['form']['subject'])) {
             $this->error(ECode::$POST_NOSUB);
         }
         if (!isset($this->params['form']['content'])) {
             $this->error(ECode::$POST_NOCON);
         }
         $subject = trim($this->params['form']['subject']);
         $content = trim($this->params['form']['content']);
         $subject = nforum_iconv($this->encoding, $this->appEncoding, $subject);
         $content = nforum_iconv($this->encoding, $this->appEncoding, $content);
         $subject = rawurldecode($subject);
         $sig = User::getInstance()->signature;
         $email = 0;
         $anony = null;
         $outgo = 0;
         if (isset($this->params['form']['email'])) {
             $email = 1;
         }
         if (isset($this->params['form']['anony']) && $this->_board->isAnony()) {
             $anony = 1;
         }
         if (isset($this->params['form']['outgo']) && $this->_board->isOutgo()) {
             $outgo = 1;
         }
         try {
             if (false === $article) {
                 Article::post($this->_board, $subject, $content, $sig, $email, $anony, $outgo);
             } else {
                 $article->reply($subject, $content, $sig, $email, $anony, $outgo);
             }
         } catch (ArticlePostException $e) {
             $this->error($e->getMessage());
         }
         $this->redirect($this->_mbase . "/board/" . $this->_board->NAME . ($single ? "/0" : "") . "?m=" . ECode::$POST_OK);
     } else {
         $reTitle = $reContent = "";
         if ($reID != 0) {
             $this->notice = "{$this->_board->DESC}-回复";
             $reContent = "\n" . $article->getRef();
             //remove ref ubb tag
             $reContent = XUBB::remove($reContent);
             if (!strncmp($article->TITLE, "Re: ", 4)) {
                 $reTitle = $article->TITLE;
             } else {
                 $reTitle = "Re: " . $article->TITLE;
             }
         } else {
             $this->notice = "{$this->_board->DESC}-发表";
         }
     }
     $this->set("single", $single);
     $this->set("bName", $this->_board->NAME);
     $this->set("email", true);
     $this->set("anony", $this->_board->isAnony());
     $this->set("outgo", $this->_board->isOutgo());
     $this->set("title", (string) $reTitle);
     $this->set("content", (string) $reContent);
     $this->set("reid", $reID);
 }
コード例 #3
0
ファイル: article_controller.php プロジェクト: rainsun/nForum
 public function ajax_single()
 {
     if (!isset($this->params['id'])) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     $id = $this->params['id'];
     try {
         $article = Article::getInstance($id, $this->_board);
     } catch (ArticleNullException $e) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     App::import('vendor', 'inc/wrapper');
     $wrapper = Wrapper::getInstance();
     $ret = $wrapper->article($article, array('single' => true, 'content' => false));
     $u = User::getInstance();
     $ret['allow_post'] = $this->_board->hasPostPerm($u);
     $ret['is_bm'] = $u->isBM($this->_board) || $u->isAdmin();
     $content = $article->getHtml(true);
     if (Configure::read("ubb.parse")) {
         //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);
     }
     $ret['content'] = $content;
     $this->set('no_html_data', $ret);
 }
コード例 #4
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));
 }
コード例 #5
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);
     }
 }
コード例 #6
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));
 }
コード例 #7
0
ファイル: user.php プロジェクト: tilitala/nForum
 public function setSignature($signature)
 {
     App::import("vendor", "inc/ubb");
     $fileName = $this->getHome("signatures");
     $fp = @fopen($fileName, "w+");
     if ($fp != false) {
         fwrite($fp, str_replace("\r\n", "\n", XUBB::remove($signature)));
         fclose($fp);
         bbs_recalc_sig();
     }
 }
コード例 #8
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();
 }