function atomic_ann() { global $currentuser; $file = false; $path = @trim($_GET['path']); if (isset($_GET['file'])) { $path = trim($_GET['file']); if ($path[0] == '/') { $path = "0Announce" . $path; } else { $path = "0Announce/" . $path; } $file = $path; $modfile = $file; } else { if ($path[0] == '/') { $path1 = "0Announce" . $path; } else { $path1 = "0Announce/" . $path; } $modfile = $path1 . "/.Names"; } if (strstr($path, '.Names') || strstr($path, '..') || strstr($path, 'SYSHome')) { atomic_error('不存在该目录'); } $boardName = ''; $articles = array(); $path_tmp = ''; if ($file === false) { $ret = bbs_read_ann_dir($path, $boardName, $path_tmp, $articles); switch ($ret) { case -1: atomic_error('精华区目录不存在'); case -2: atomic_error('无法加载目录文件'); case -3: break; case -9: atomic_error('系统错误'); default: } $path = $path_tmp; } else { if (bbs_ann_traverse_check($path, $currentuser["userid"]) < 0) { atomic_error("错误的目录"); } } $parent = ''; $up_dirs = array(); $up_cnt = bbs_ann_updirs($path, $boardName, $up_dirs); $cacheit = true; if ($up_cnt >= 2) { $parent = $up_dirs[$up_cnt - 2]; } if ($boardName) { $brdArr = array(); $boardID = bbs_getboard($boardName, $brdArr); $boardArr = $brdArr; if ($boardID) { $boardName = $boardArr['NAME']; $usernum = $currentuser['index']; if (bbs_checkreadperm($usernum, $boardID) == 0) { foundErr('不存在该目录'); } bbs_set_onboard($boardID, 1); if (!bbs_normalboard($boardName)) { $cacheit = false; } } else { $boardName = ''; } } else { $boardID = 0; } if ($cacheit) { if (cache_header('public', @filemtime($modfile), 300)) { return; } } atomic_header(); $html = "<p>"; if ($boardID) { $html .= "<a href='?act=board&board=" . $boardName . "'>回 " . $boardName . " 版面</a> "; } if ($parent) { $html .= "<a href='?act=ann&path=" . $parent . "'>回上级目录</a> "; } $html .= "<a href='?'>回首页</a></p>"; if ($file !== false) { echo $html; echo bbs2_readfile_text($file, MAXCHAR, 2); } else { $html .= "<pre> 编号 [类别] 标 题 整 理 编辑日期\n"; if (count($articles) >= 0) { $i = 1; foreach ($articles as $article) { switch ($article['FLAG']) { case 0: continue 2; case 1: $alt = '目录'; $url = '?act=ann&path=' . urlencode($article['PATH']); break; case 2: case 3: default: $alt = '文件'; $url = '?act=ann&file=' . urlencode($article['PATH']); } $html .= sprintf("%5d ", $i) . "[" . $alt . "]"; $html .= $article['FLAG'] == 3 ? "@" : " "; $title = sprintf("%-37.37s", trim($article['TITLE'])); $html .= '<a href="' . $url . '">' . htmlspecialchars($title) . ' </a>'; $bm = explode(' ', trim($article['BM'])); $html .= sprintf(" %-12.12s ", $bm[0]); $html .= date('Y-m-d', $article['TIME']) . "\n"; $i++; } } $html .= "</pre>"; echo $html; } atomic_footer(); }
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)); }
$up_cnt = bbs_ann_updirs($filename, $board, $up_dirs); } else { if (isset($_GET["path"])) { $path = $_GET["path"]; } else { html_error_quit("╢МнС╣дндуб"); } if (strstr($path, ".Names") || strstr($path, "..") || strstr($path, "SYSHome")) { html_error_quit("╢МнС╣дндуб"); } if ($path[0] == '/') { $filename = "0Announce" . $path; } else { $filename = "0Announce/" . $path; } if (bbs_ann_traverse_check($filename, $currentuser["userid"]) < 0) { html_error_quit("╢МнС╣дд©б╪"); } if (!file_exists($filename)) { html_error_quit("╢МнС╣дндуб╨е..."); } $board = ''; $up_dirs = array(); $up_cnt = bbs_ann_updirs($filename, $board, $up_dirs); if ($board) { $brdarr = array(); $bid = bbs_getboard($board, $brdarr); if ($bid) { $board = $brdarr['NAME']; $usernum = $currentuser['index']; if (bbs_checkreadperm($usernum, $bid) == 0) {