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)); }