public function show() { 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 { $box = new MailBox(User::getInstance(), $type); $mail = Mail::getInstance($num, $box); } catch (Exception $e) { $this->error(ECode::$MAIL_NOMAIL); } $this->notice = $box->desc . "-阅读邮件"; $mail->setRead(); $content = $mail->getHtml(); preg_match("|来 源:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $f); $f = empty($f) ? "" : "<br />FROM {$f[1]}"; $s = ($pos = strpos($content, "<br/><br/>")) === false ? 0 : $pos + 10; $e = ($pos = strpos($content, "<br/>--<br/>")) === false ? strlen($content) : $pos + 7; $content = substr($content, $s, $e - $s) . $f; if (Configure::read("ubb.parse")) { $content = XUBB::parse($content); } App::import("Sanitize"); $this->set("type", $type); $this->set("num", $mail->num); $this->set("title", Sanitize::html($mail->TITLE)); $this->set("sender", $mail->OWNER); $this->set("time", date("Y-m-d H:i:s", $mail->POSTTIME)); $this->set("content", $content); }
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)); }
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); }
public function single() { $this->notice = "版面-{$this->_board->DESC}({$this->_board->NAME})"; if ($this->_board->getMode() == BOARD::$THREAD) { $this->_board->setMode(BOARD::$NORMAL); } App::import('Sanitize'); try { $gid = $this->params['gid']; $article = Article::getInstance($gid, $this->_board); } catch (ArticleNullException $e) { $this->error(ECode::$ARTICLE_NONE); } $u = User::getInstance(); $bm = $u->isBM($this->_board) || $u->isAdmin(); $info = array(); $content = $article->getPlant(); $content = preg_replace("/ /", " ", $content); $content = preg_replace("/ /", " ", $content); preg_match("|※ 修改:·([\\S]+) .*?FROM:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $m); preg_match("|※ 来源:.*FROM:[\\s]*([0-9a-zA-Z.:*]+)|", $content, $f); $m = empty($m) ? "" : "<br />修改:{$m[1]} FROM {$m[2]}"; $f = empty($f) ? "" : "<br />FROM {$f[1]}"; $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("", "<br>--"), substr($content, $s, $e - $s)) . $m . $f; $content = $article->parseAtt($content, 'middle'); if (Configure::read("ubb.parse")) { $content = XUBB::parse($content); } $info = array("aid" => $article->ID, "gid" => $article->GROUPID, "rid" => $article->REID, "op" => $article->OWNER == $u->userid || $bm ? 1 : 0, "time" => date("Y-m-d H:i:s", $article->POSTTIME), "poster" => $article->OWNER, "content" => $content, "subject" => $article->isSubject(), "pre" => ($a = $article->pre()) ? $a->ID : false, "next" => ($a = $article->next()) ? $a->ID : false, "tPre" => ($a = $article->tPre()) ? $a->ID : false, "tNext" => ($a = $article->tNext()) ? $a->ID : false); $this->set("bName", $this->_board->NAME); $this->set("mode", $this->_board->getMode()); $this->set("canPost", $this->_board->hasPostPerm($u)); $this->set("title", Sanitize::html($article->TITLE)); $this->set($info); }
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("|标 题: ([\\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)); }
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("/ /", " ", $content); $content = preg_replace("/ /", " ", $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); } }
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(); }