function login_init() { global $currentuinfo; global $loginok; global $currentuser_num; global $currentuinfo_num; global $currentuser; global $utmpnum; global $setboard; global $fromhost; $currentuinfo_tmp = array(); set_fromhost(); $compat_telnet = 0; @($sessionid = $_GET["sid"]); //TODO: add the check of telnet compat if ($sessionid != '' && $_SERVER['PHP_SELF'] == '/bbscon.php') { $utmpnum = decodesessionchar($sessionid[0]) + decodesessionchar($sessionid[1]) * 36 + decodesessionchar($sessionid[2]) * 36 * 36; $utmpkey = decodesessionchar($sessionid[3]) + decodesessionchar($sessionid[4]) * 36 + decodesessionchar($sessionid[5]) * 36 * 36 + decodesessionchar($sessionid[6]) * 36 * 36 * 36 + decodesessionchar($sessionid[7]) * 36 * 36 * 36 * 36 + decodesessionchar($sessionid[8]) * 36 * 36 * 36 * 36 * 36; $userid = ''; $compat_telnet = 1; } else { @($utmpkey = $_COOKIE["UTMPKEY"]); @($utmpnum = $_COOKIE["UTMPNUM"]); @($userid = $_COOKIE["UTMPUSERID"]); } if ($utmpkey != "") { if (($ret = bbs_setonlineuser($userid, intval($utmpnum), intval($utmpkey), $currentuinfo_tmp, $compat_telnet)) == 0) { $loginok = 1; $currentuinfo_num = bbs_getcurrentuinfo(); $currentuser_num = bbs_getcurrentuser($currentuser); } else { $utmpkey = ""; } } // add by stiger, 如果登陆失败就继续用guest登陆 if ($utmpkey == "") { $error = bbs_wwwlogin(0); if ($error == 2 || $error == 0) { $data = array(); $num = bbs_getcurrentuinfo($data); setcookie("UTMPKEY", $data["utmpkey"], 0, "/"); setcookie("UTMPNUM", $num, 0, "/"); setcookie("UTMPUSERID", $data["userid"], 0, "/"); setcookie("LOGINTIME", $data["logintime"], 0, "/"); setcookie("WWWPARAMS", WWW_DEFAULT_PARAMS, 0, "/"); @($utmpkey = $data["utmpkey"]); @($utmpnum = $num); @($userid = $data["userid"]); $compat_telnet = 1; } //guest 登陆成功,设置一下 if ($utmpkey != "") { if (($ret = bbs_setonlineuser($userid, intval($utmpnum), intval($utmpkey), $currentuinfo_tmp, $compat_telnet)) == 0) { $loginok = 1; $currentuinfo_num = bbs_getcurrentuinfo(); $currentuser_num = bbs_getcurrentuser($currentuser); } } } $currentuinfo = $currentuinfo_tmp; settype($utmpnum, "integer"); if ($loginok != 1 && $_SERVER["PHP_SELF"] != "/bbslogin.php") { error_nologin(); return; } if ($loginok == 1 && (isset($setboard) && $setboard == 1)) { bbs_set_onboard(0, 0); } //add end }
$gid = $_GET["gid"]; settype($gid, "integer"); if ($gid < 0) { $gid = 0; } $board = $_GET["board"]; $brdarr = array(); $bid = bbs_getboard($board, $brdarr); if ($bid == 0) { html_error_quit("错误的讨论区"); } $board = $brdarr["NAME"]; $board_desc = $brdarr["DESC"]; $brd_encode = urlencode($board); $isnormalboard = bbs_normalboard($board); bbs_set_onboard($bid, 1); $usernum = $currentuser["index"]; if (!$isnormalboard && bbs_checkreadperm($usernum, $bid) == 0) { html_error_quit("错误的讨论区"); } $haveprev = 0; $num = bbs_get_threads_from_gid($bid, $gid, 0, $articles, $haveprev); if ($num == 0) { html_error_quit("错误的参数"); } if ($isnormalboard) { /* cache 判断索引修改时间 - atppp */ $dotdirname = bbs_get_board_index($board, $dir_modes["NORMAL"]); if (cache_header("public", @filemtime($dotdirname), 300)) { return; }
} else { html_error_quit("错误的讨论区"); } $id = intval($_GET["id"]); if (!$id) { html_error_quit("错误的文章"); } // 检查用户能否阅读该版 $brdarr = array(); $brdnum = bbs_getboard($board, $brdarr); if ($brdnum == 0) { html_error_quit("错误的讨论区"); } $board = $brdarr["NAME"]; $brd_encode = urlencode($board); bbs_set_onboard($brdnum, 1); $usernum = $currentuser["index"]; if (bbs_checkreadperm($usernum, $brdnum) == 0) { html_error_quit("错误的讨论区"); } if (isset($_POST["oldprop"])) { $oldprop = $_POST["oldprop"]; $prop = $oldprop & 070; if (isset($_POST["mailback"]) && $_POST["mailback"] == "on") { $prop |= 04; } if (isset($_POST["innflag"]) && $_POST["innflag"] == "on") { $prop |= 02; } if (isset($_POST["cancelo"]) && $_POST["cancelo"] == "on") { $prop |= 01;
function login_init($sid = FALSE, $no_auto_guest_login = FALSE) { global $currentuinfo; global $loginok; global $currentuser_num; global $currentuinfo_num; global $currentuser; global $utmpnum; global $setboard; global $fromhost; global $fullfromhost; $currentuinfo_tmp = array(); $compat_telnet = 0; $sessionid = ""; if ($sid) { if (is_string($sid)) { $sessionid = $sid; } else { @($sessionid = $_GET["sid"]); if (!$sessionid) { @($sessionid = $_POST["sid"]); } if (!$sessionid) { @($sessionid = $_COOKIE["sid"]); } settype($sessionid, "string"); } } if ($sessionid && strlen($sessionid) == 9) { $utmpnum = decodesessionchar($sessionid[0]) + decodesessionchar($sessionid[1]) * 36 + decodesessionchar($sessionid[2]) * 36 * 36; $utmpkey = decodesessionchar($sessionid[3]) + decodesessionchar($sessionid[4]) * 36 + decodesessionchar($sessionid[5]) * 36 * 36 + decodesessionchar($sessionid[6]) * 36 * 36 * 36 + decodesessionchar($sessionid[7]) * 36 * 36 * 36 * 36 + decodesessionchar($sessionid[8]) * 36 * 36 * 36 * 36 * 36; $userid = ''; $compat_telnet = 1; } else { @($utmpkey = $_COOKIE["UTMPKEY"]); @($utmpnum = $_COOKIE["UTMPNUM"]); @($userid = $_COOKIE["UTMPUSERID"]); } if ($utmpkey) { if (($ret = bbs_setonlineuser($userid, intval($utmpnum), intval($utmpkey), $currentuinfo_tmp, $compat_telnet)) == 0) { $loginok = 1; $currentuinfo_num = bbs_getcurrentuinfo(); $currentuser_num = bbs_getcurrentuser($currentuser); } else { $utmpkey = ""; } } // add by stiger, 如果登录失败就继续用guest登录 if (!$sessionid && !$utmpkey && !$no_auto_guest_login) { set_fromhost(); $error = bbs_wwwlogin(0, $fromhost, $fullfromhost); if ($error == 2 || $error == 0) { $data = array(); $num = bbs_getcurrentuinfo($data); setcookie("UTMPKEY", $data["utmpkey"], 0, "/"); setcookie("UTMPNUM", $num, 0, "/"); setcookie("UTMPUSERID", $data["userid"], 0, "/"); header("Set-KBSRC: /"); @($utmpkey = $data["utmpkey"]); @($utmpnum = $num); @($userid = $data["userid"]); $compat_telnet = 1; } //guest 登录成功,设置一下 if ($utmpkey != "") { if (($ret = bbs_setonlineuser($userid, intval($utmpnum), intval($utmpkey), $currentuinfo_tmp, $compat_telnet)) == 0) { $loginok = 1; $currentuinfo_num = bbs_getcurrentuinfo(); $currentuser_num = bbs_getcurrentuser($currentuser); } } } $currentuinfo = $currentuinfo_tmp; settype($utmpnum, "integer"); if ($loginok != 1 && !$no_auto_guest_login) { delete_all_cookie(); cache_header("nocache"); ?> <html> <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></head> <body>您还没有登录,或者你发呆时间过长被服务器清除。 请重新<a href="index.html" target="_top">登录</a>。</body> </html> <?php exit; } if ($loginok == 1 && (isset($setboard) && $setboard == 1)) { bbs_set_onboard(0, 0); } return $sessionid; }
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(); }
/** * function setOnBoard set current user on this board * * @return null * @access public */ public function setOnBoard() { bbs_set_onboard($this->BID, 1); }