示例#1
0
 protected function parseXml($file)
 {
     if (!file_exists($file)) {
         return $this->_error('该应用数据错误');
     }
     $ret = array();
     $xml = simplexml_load_file($file);
     if ($xml === false) {
         return $this->_error('该应用数据错误');
     }
     foreach ($xml->hotsubject as $v) {
         $title = nforum_fix_gbk(urldecode($v->title));
         $board = $v->o_board == "" ? $v->board : $v->o_board;
         $id = $v->o_groupid == 0 ? $v->groupid : $v->o_groupid;
         $ret[] = array("text" => $title, "url" => "/article/" . $board . "/" . $id);
     }
     if (empty($ret)) {
         return $this->_error('该应用暂无数据');
     }
     return array("s" => parent::$S_LINE, "v" => $ret);
 }
示例#2
0
 public function wGetList()
 {
     if (!file_exists($this->_file)) {
         return $this->_error('十大热门话题不存在');
     }
     $ret = array();
     $xml = simplexml_load_file($this->_file);
     if ($xml === false) {
         return $this->_error('十大热门话题不存在');
     }
     foreach ($xml->hotsubject as $v) {
         $title = nforum_fix_gbk(urldecode($v->title));
         $board = $v->o_board == "" ? $v->board : $v->o_board;
         $id = $v->o_groupid == 0 ? $v->groupid : $v->o_groupid;
         $ret[] = array("text" => $title . "(<span style=\"color:red\">" . $v->number . "</span>)", "url" => "/article/" . rawurldecode($board) . "/" . $id);
     }
     if (empty($ret)) {
         return $this->_error('十大热门话题不存在');
     }
     return array("s" => parent::$S_LINE, "v" => $ret);
 }
示例#3
0
 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));
 }
示例#4
0
 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;
     }
 }
示例#5
0
 public function update()
 {
     if (!$this->RequestHandler->isPost()) {
         $this->error(ECode::$SYS_REQUESTERROR);
     }
     if ($this->_board->isReadOnly()) {
         $this->error(ECode::$BOARD_READONLY);
     }
     if (!$this->_board->hasPostPerm(User::getInstance())) {
         $this->error(ECode::$BOARD_NOPOST);
     }
     if (!isset($this->params['id'])) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     $id = intval($this->params['id']);
     try {
         App::import('vendor', "model/article");
         $article = Article::getInstance($id, $this->_board);
     } catch (ArticleNullException $e) {
         $this->error(ECode::$ARTICLE_NONE);
     }
     $u = User::getInstance();
     if (!$article->hasEditPerm($u)) {
         $this->error(ECode::$ARTICLE_NOEDIT);
     }
     if (!isset($this->params['form']['title'])) {
         $this->error(ECode::$POST_NOSUB);
     }
     if (!isset($this->params['form']['content'])) {
         $this->error(ECode::$POST_NOCON);
     }
     $title = trim($this->params['form']['title']);
     $content = trim($this->params['form']['content']);
     $title = rawurldecode($title);
     $content = rawurldecode($content);
     $title = nforum_iconv($this->encoding, $this->appEncoding, $title);
     $content = nforum_iconv($this->encoding, $this->appEncoding, $content);
     if (strlen($title) > 60) {
         $title = nforum_fix_gbk(substr($title, 0, 60));
     }
     if (!$article->update($title, $content)) {
         $this->error(ECode::$ARTICLE_EDITERROR);
     }
     $new = Article::getInstance($id, $this->_board);
     $wrapper = Wrapper::getInstance();
     $this->set('data', $wrapper->article($new, array('content' => true)));
 }
示例#6
0
 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();
 }