⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atomic.php

📁 linux/unix环境下的建站系统
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/* * 精简版 web,atppp 制造。 * Suppports UTF8. Absolutely NO javascript! * BUG: 没有完善处理版名含有特殊字符的情形 *//* * UTF8SP - TRUE/FALSE  (use UTF8 or GB18030) *        - NULL        (user can switch, default is GB18030) */define('UTF8SP', NULL);define('ARTCNT', 20);define('MAXCHAR', 20000);define('SUPPORT_UPLOAD', TRUE);require("www2-funcs.php");require("www2-board.php");require("www2-bmp.php");login_init();if (is_null(UTF8SP)) {	if (isset($_GET['utf8'])) {		define('UTF8', (bool)$_GET['utf8']);		setcookie("UTF8", (int)UTF8, 0, "/");	} else if (isset($_COOKIE['UTF8'])){		define('UTF8', (bool)$_COOKIE["UTF8"]);	} else {		define('UTF8', FALSE);	}} else {	define('UTF8', UTF8SP);}if (UTF8) {	iconv_set_encoding("internal_encoding", "gb18030");	iconv_set_encoding("output_encoding", "UTF-8//IGNORE");	ob_start("ob_iconv_handler");}$atomic_header_shown = false;$atomic_board = false;$atomic_brdarr = array();$atomic_brdnum = false;$atomic_ftype = 0;$act = @$_GET["act"];switch($act) {	case "post":		atomic_post();		break;	case "article":		atomic_article();		break;	case "board":		atomic_board();		break;	case "mail":		atomic_mail();		break;	case "mailread":		atomic_mailread();		break;	case "mailpost":		atomic_mailpost();		break;	case "ann":		atomic_ann();		break;	case "logout":		bbs_wwwlogoff();		delete_all_cookie();		cache_header("nocache");		header("Location: atomic.php");		exit;	default:		atomic_mainpage();		break;}function atomic_uploadable() {	global $atomic_brdarr;	if (!SUPPORT_UPLOAD) return FALSE;	return bbs_is_attach_board($atomic_brdarr);}function atomic_header() {	global $atomic_header_shown, $cachemode;	if ($atomic_header_shown) return;	if ($cachemode=="") {		cache_header("nocache");	}	$atomic_header_shown = true;	header("Content-Type: text/html; charset=".(UTF8?"UTF-8":"gb2312"));	echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . (UTF8?"UTF-8":"gb2312") . '">'.		 '<title>'.BBS_FULL_NAME.'</title><style>a{text-decoration:none;}</style></head><body>';}function atomic_footer() {	echo "</body></html>";}function atomic_error($msg) {	atomic_header();	echo $msg . " <a href='?'>回首页</a>";	atomic_footer();	exit;}function atomic_get_input($str) {	if (UTF8) return (iconv("UTF-8", "gb18030", $str));	else return $str;}function atomic_show_boardjump() {	global $atomic_board;	if ($atomic_board) $bb = "当前讨论区: " . $atomic_board . ". ";	else $bb = "";		echo <<<END<form action="" method="get"><input type="hidden" name="act" value="board"/>$bb去讨论区: <input type="text" name="board" /> <input type="submit" value="Go"/> <a href='?'>回首页</a></form>END;}function atomic_get_board($checkpost = false) {	global $currentuser, $atomic_board, $atomic_brdarr, $atomic_brdnum, $atomic_ftype, $dir_modes;	if (isset($_GET["board"]))		$atomic_board = $_GET["board"];	else{		atomic_error("错误的讨论区");	}	$brdarr = array();	$atomic_brdnum = bbs_getboard($atomic_board, $brdarr);	$atomic_brdarr = $brdarr;	if ($atomic_brdnum == 0){		$boards = array();		if (bbs_searchboard($atomic_board,0,$boards)) {			if (sizeof($boards)==1) {				cache_header("nocache");				header("Location: atomic.php?act=board&board=" . urlencode($boards[0]['NAME']));				exit;			}			if (sizeof($boards) > 1) {				atomic_header();				$html = "多个匹配的讨论区: ";				foreach ($boards as $board) {					if (!$board['NAME']) continue;					$html .= '<a href="?act=board&board=' . $board['NAME'] . '">' . $board['NAME'] . '</a> ';				}				echo $html;				atomic_footer();				exit;			}		}		atomic_error("错误的讨论区");	}	$atomic_board = $atomic_brdarr["NAME"];	$usernum = $currentuser["index"];	if (bbs_checkreadperm($usernum, $atomic_brdnum) == 0){		atomic_error("错误的讨论区");	}	if ($atomic_brdarr["FLAG"]&BBS_BOARD_GROUP) {		atomic_error("不支持版面组");	}	bbs_set_onboard($atomic_brdnum,1);		if ($checkpost) {		if(bbs_checkpostperm($usernum, $atomic_brdnum) == 0) {			atomic_error("错误的讨论区或者您无权在此讨论区发表文章");		}		if (bbs_is_readonly_board($atomic_brdarr)) {			atomic_error("不能在只读讨论区发表文章");		}	}	if (isset($_GET["ftype"])) {		$atomic_ftype = @intval($_GET["ftype"]);		switch($atomic_ftype) {			case $dir_modes["DIGEST"]:			case $dir_modes["MARK"]:			case $dir_modes["NORMAL"]:				break;			default:				atomic_error("错误的模式");		}	} else {		$atomic_ftype = $dir_modes["NORMAL"];	}}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 atomic_board() {	global $currentuser, $atomic_board, $atomic_brdarr, $atomic_brdnum, $dir_modes, $atomic_ftype;	atomic_get_board();	$isnormalboard = bbs_normalboard($atomic_board);	if ($isnormalboard && (isset($_GET["page"])||$atomic_ftype) ) {		$dotdirname = bbs_get_board_index($atomic_board, $atomic_ftype);		if (cache_header("public",@filemtime($dotdirname),$atomic_ftype?300:10)) return;	}	atomic_header();	atomic_show_boardjump();		$total = bbs_countarticles($atomic_brdnum, $atomic_ftype);	if ($total <= 0) {		atomic_error("本讨论区目前没有文章");	}	$page = isset($_GET["page"]) ? @intval($_GET["page"]) : 0;	if (isset($_GET["start"])) {		$page = (@intval($_GET["start"]) + ARTCNT - 1) / ARTCNT;	}	settype($page, "integer");	$start = ($page > 0) ? ($page - 1) * ARTCNT + 1 : 0;	if ($start == 0 || $start > ($total - ARTCNT + 1))	{		if ($total <= ARTCNT)		{			$start = 1;			$page = 1;		}		else		{			$start = ($total - ARTCNT + 1);			$page = ($start + ARTCNT - 1) / ARTCNT + 1;		}	}	else		$page = ($start + ARTCNT - 1) / ARTCNT;	settype($page, "integer");	$articles = bbs_getarticles($atomic_board, $start, ARTCNT, $atomic_ftype);	if ($articles == FALSE)		atomic_error("读取文章列表失败");		$html = '<form action="?" method="get"><input type="hidden" name="act" value="board"/>';	if ($atomic_ftype) {		$html .= '<input type="hidden" name="ftype" value="' . $atomic_ftype . '"/>';	}	$html .= '<input type="hidden" name="board" value="'.$atomic_board.'"/>';	$html .= '<a href="?act=post&board='.$atomic_board.'">发表</a> ';	if (atomic_uploadable()) $html .= '<a href="?act=post&board='.$atomic_board.'&upload=1">带附件发表</a> ';	$bl = '?act=board&board='.$atomic_board;	if ($atomic_ftype) $bl .= '&ftype=' . $atomic_ftype;	if ($page > 1) {		$html .= '<a href="' . $bl .'&page=1">第一页</a> ';		$html .= '<a href="' . $bl .'&page='.($page - 1).'">上页</a> ';	} else {		$html .= '第一页 上页 ';	}	if ($start <= $total - 20) {		$html .= '<a href="' . $bl .'&page='.($page + 1).'">下页</a> ';		$html .= '<a href="' . $bl .'">最后一页</a> ';	} else {		$html .= '下页 最后一页 ';	}	$html .= '<input type="submit" value="跳转到"/> 第 <input type="text" name="start" size="3" /> 篇 ';	if ($atomic_ftype != $dir_modes["NORMAL"]) {		$html .= "<a href='?act=board&board=".$atomic_board."'>版面</a> ";	} else $html .= "<b>版面</b> ";	if ($atomic_ftype != $dir_modes["DIGEST"]) {		$html .= "<a href='?act=board&board=".$atomic_board."&ftype=".$dir_modes["DIGEST"]."'>文摘</a> ";	} else $html .= "<b>文摘</b> ";	if ($atomic_ftype != $dir_modes["MARK"]) {		$html .= "<a href='?act=board&board=".$atomic_board."&ftype=".$dir_modes["MARK"]."'>保留</a> ";	} else $html .= "<b>保留</b> ";	$ann_path = bbs_getannpath($atomic_board);	if ($ann_path != FALSE)	{		if (!strncmp($ann_path,"0Announce/",10))			$ann_path = substr($ann_path,9);	}	$html .= "<a href='?act=ann&path=".$ann_path."'>精华</a> ";	$html .= "</form>";	$html .= "<pre> 编号   刊 登 者     日  期  文章标题<br/>";	$i = 0;	foreach ($articles as $article)	{		$title = $article["TITLE"];		if (strncmp($title, "Re: ", 4) != 0)			$title = "● " . $title;		$flags = $article["FLAGS"];		if (!strncmp($flags,"D",1)||!strncmp($flags,"d",1)) {			$html .= " [提示] ";		} else {			$html .= sprintf("%5d ", ($start+$i));			if ($flags[0] == 'N' || $flags[0] == '*'){				$html .= " "; //$flags[0];  //不要未读标记 windinsn			} else{				$html .= $flags[0];			}			$html .= " ";		}		$html .= sprintf("%-12.12s ", $article["OWNER"]);		$html .= strftime("%b %e ", $article["POSTTIME"]);		$html .= $flags[3];		$articleurl = "?act=article&board=".$atomic_board."&id=".$article["ID"];		if ($atomic_ftype) {			$articleurl .= "&ftype=" . $atomic_ftype . "&num=" . ($start+$i);		}		$html .= "<a href='".$articleurl."'>".htmlspecialchars($title)." </a><br/>";		$i++;	}	$html .= "</pre>";	echo $html;	atomic_footer();}function atomic_article() {	global $currentuser, $atomic_board, $atomic_brdarr, $atomic_brdnum, $dir_modes, $atomic_ftype;	atomic_get_board();	$id = @intval($_GET["id"]);	if ($id <= 0) atomic_error("错误的文章号");	$url = "?act=article&board=" . $atomic_board . "&id=";	@$ptr=$_GET["p"];	// 同主题的指示在这里处理	if ($ptr == "tn" || $ptr == "tp") {		$articles = bbs_get_threads_from_id($atomic_brdnum, $id, $dir_modes["NORMAL"],($ptr == "tp")?-1:1);		if ($articles == FALSE)			$redirt_id = $id;		else			$redirt_id = $articles[0]["ID"];		header("Location: atomic.php" . $url . $redirt_id);		exit;	}	$total = bbs_countarticles($atomic_brdnum, $atomic_ftype);	if ($total <= 0) {		atomic_error("错误的文章号,原文可能已经被删除");	}	if (!$atomic_ftype) {		$articles = array ();		$num = bbs_get_records_from_id($atomic_board, $id, $atomic_ftype, $articles);		if ($num <= 0) atomic_error("错误的文章号,原文可能已经被删除");		$article = $articles[1];	} else {		$num = @intval($_GET["num"]);		if (($num <= 0) || ($num > $total)) atomic_error("错误的文章号,原文可能已经被删除");		if (($articles = bbs_getarticles($atomic_board, $num, 1, $atomic_ftype)) === false) atomic_error("错误的文章号,原文可能已经被删除");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -