public function error($code = null) { $code = is_null($code) ? ECode::$SYS_ERROR : $code; $req = str_replace($this->_oabase, '', $this->path); $_error = array('request' => $req, 'code' => $code, 'msg' => ECode::msg($code)); $this->set('data', $_error); $this->name = 'error'; echo $this->render(); $this->_stop(); }
public function index() { $this->js[] = "forum.board.js"; $this->css[] = "board.css"; App::import('Sanitize'); if (!isset($this->params['num'])) { $this->error(ECode::$SEC_NOSECTION); } try { $num = $this->params['num']; $this->_sec = Section::getInstance($num, Section::$NORMAL); } catch (SectionNullException $e) { $this->error(ECode::$SEC_NOSECTION); } catch (BoardNullException $e) { $this->error(ECode::$BOARD_NOBOARD); } $secs = $this->_sec->getAll(); $ret = false; if (!$this->_sec->isNull()) { $u = User::getInstance(); foreach ($secs as $brd) { $last = array(); $last["id"] = ""; $last["title"] = $last["owner"] = $last["date"] = "无"; if ($brd->hasReadPerm($u)) { $threads = $brd->getTypeArticles(0, 1, Board::$ORIGIN); if (!empty($threads)) { $threads = $threads[0]; $last = array("id" => $threads->ID, "title" => Sanitize::html($threads->TITLE), "owner" => $threads->isSubject() ? $threads->OWNER : "原帖已删除", "date" => date("Y-m-d H:i:s", $threads->POSTTIME)); } } $bms = split(" ", $brd->BM); foreach ($bms as &$bm) { if (preg_match("/[^0-9a-zA-Z]/", $bm)) { $bm = array($bm, false); } else { $bm = array($bm, true); } } $ret[] = array("name" => $brd->NAME, "desc" => $brd->DESC, "type" => $brd->isDir() ? "section" : "board", "bms" => $bms, "curNum" => $brd->CURRENTUSERS, "todayNum" => $brd->getTodayNum(), "threadsNum" => $brd->getThreadsNum(), "articleNum" => $brd->ARTCNT, "last" => $last); } } $this->set("sec", $ret); $this->set("noBrd", ECode::msg(ECode::$SEC_NOBOARD)); $this->set("secName", $this->_sec->getDesc()); if (!$this->_sec->isRoot()) { $parent = $this->_sec->getParent(); $this->notice[] = array("url" => "/section/{$parent->getName()}", "text" => $parent->getDesc()); } $this->title = Configure::read('site.name') . '-' . $this->_sec->getDesc(); $this->notice[] = array("url" => "/section/{$this->_sec->getName()}", "text" => $this->_sec->getDesc()); $this->notice[] = array("url" => "", "text" => $this->_sec->isRoot() ? "分区列表" : "目录列表"); }
public function beforeRender() { if ($this->ByrSession->isLogin) { $u = User::getInstance(); $login = true; $id = $u->userid; $isAdmin = $u->isAdmin(); App::import("vendor", "model/mail"); $info = MailBox::getInfo($u); $info['new_mail'] = $info['newmail']; $info['full_mail'] = $info['full']; $info['newAt'] = $info['newReply'] = false; if (Configure::read('refer.enable')) { App::import('vendor', 'model/refer'); try { if ($u->getCustom('userdefine1', 2)) { $refer = new Refer($u, Refer::$AT); $info['newAt'] = $refer->getNewNum(); } if ($u->getCustom('userdefine1', 3)) { $refer = new Refer($u, Refer::$REPLY); $info['newReply'] = $refer->getNewNum(); } } catch (ReferNullException $e) { } } $this->set($info); } else { $login = false; $id = "guest"; $isAdmin = false; } $this->_initAsset(); $site = Configure::read("site"); $this->set("domain", $site['domain']); $this->set("static", $site['static']); $this->set("siteName", $site['name'] . "手机版"); $this->set("webTitle", empty($this->title) ? $site['name'] . "手机版" : $this->title); $this->set("encoding", $this->encoding); $this->set("home", $site['home']); $this->set("base", $this->base); $this->set("mbase", $this->base . $this->_mbase); $this->set("msg", ECode::msg($this->_msg)); $this->set("pos", $this->notice); $this->set("css", $this->css); $this->set("islogin", $login); $this->set("id", $id); $this->set("isAdmin", $isAdmin); }
public function board() { $this->css[] = "board.css"; $this->js[] = "forum.board.js"; $this->notice[] = array("url" => "", "text" => "ËÑË÷½á¹û"); App::import('Sanitize'); $b = isset($this->params['url']['b']) ? $this->params['url']['b'] : ""; $ret = false; $b = trim(rawurldecode($b)); $b = nforum_iconv('utf-8', $this->encoding, $b); $boards = Board::search($b); if (count($boards) == 1) { $this->redirect("/board/" . $boards[0]->NAME); } foreach ($boards as $brd) { $threads = $brd->getTypeArticles(0, 1, Board::$ORIGIN); if (!empty($threads)) { $threads = $threads[0]; $last = array("id" => $threads->ID, "title" => Sanitize::html($threads->TITLE), "owner" => $threads->isSubject() ? $threads->OWNER : "ÔÌûÒÑɾ³ý", "date" => date("Y-m-d H:i:s", $threads->POSTTIME)); } else { $last["id"] = ""; $last["title"] = $last["owner"] = $last["date"] = "ÎÞ"; } $bms = split(" ", $brd->BM); foreach ($bms as &$bm) { if (preg_match("/[^0-9a-zA-Z]/", $bm)) { $bm = array($bm, false); } else { $bm = array($bm, true); } } $ret[] = array("name" => $brd->NAME, "desc" => $brd->DESC, "type" => $brd->isDir() ? "section" : "board", "bms" => $bms, "curNum" => $brd->CURRENTUSERS, "todayNum" => $brd->getTodayNum(), "threadsNum" => $brd->getThreadsNum(), "articleNum" => $brd->ARTCNT, "last" => $last); } $this->set("sec", $ret); $this->set("noBrd", ECode::msg(ECode::$SEC_NOBOARD)); $this->render("index", "section/"); }
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; } }
public function error404($code = null, $args = array(), $other = array()) { if (is_a($this, 'CakeErrorController')) { return; } $msg = ECode::msg($code); if ($msg == strval($code)) { $code = null; } if (!empty($args)) { $msg = vsprintf($msg, $args); } $this->cakeError("error404", array('html' => $this->html, 'code' => $code, 'msg' => $msg)); }
public function wGetList() { App::import('Sanitize'); $ret = array(); $articles = array_reverse($this->getTypeArticles(0, 10, self::$ORIGIN)); if (!empty($articles)) { foreach ($articles as $v) { $ret[] = array("text" => Sanitize::html($v->TITLE), "url" => "/article/{$this->NAME}/{$v->GROUPID}"); } return array("s" => "w-list-line", "v" => $ret); } else { return array("s" => "w-list-line", "v" => array(array("text" => ECode::msg(ECode::$BOARD_NOTHREADS), "url" => ""))); } }