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

📄 pcfuncs.php

📁 KBS的BBS源码
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php/*** this file define some functions used in personal corp.** @id:windinsn Nov 19,2003*/require("funcs.php");login_init();require("pcconf.php");//blog配置文件require("pctbp.php");//引用通告相关函数$db["HOST"]=bbs_sysconf_str("MYSQLBLOGHOST");$db["USER"]=bbs_sysconf_str("MYSQLBLOGUSER");$db["PASS"]=bbs_sysconf_str("MYSQLBLOGPASSWORD");$db["NAME"]=bbs_sysconf_str("MYSQLBLOGDATABASE");$brdarr = array();$pcconfig["BRDNUM"] = bbs_getboard($pcconfig["BOARD"], $brdarr);if(!$currentuser["userid"])		$currentuser["userid"] = "guest";$pcconfig["NOWRAPSTR"] = "<!--NoWrap-->";$pcconfig["EDITORALERT"] = "<!--Loading HTMLArea Editor , Please Wait/正在加载 HTML编辑器 , 请稍候 ……-->";function pc_html_init($charset,$title="",$otherheader="",$cssfile="",$bkimg="",$htmlEditor=0){	global $_COOKIE;	global $cachemode;	global $currentuser;	bbs_session_modify_user_mode(BBS_MODE_BLOG);	if ($cachemode=="") 	{		cache_header("nocache");    }    echo '<?xml version="1.0" encoding="'.$charset.'"?>'."\n";?><!DOCTYPE html     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>"/><script src="pc.js"></script><?php        if ( func_num_args() > 1) {?><title><?php echo $title; ?> </title><?php   }	if($cssfile!="" )	{?><link rel="stylesheet" type="text/css" href="<?php echo $cssfile; ?>"/><?php			}	else	{?><link rel="stylesheet" type="text/css" href="default.css"/><?php	}	if($htmlEditor==3)//use htmlarea editor rc1	{?><script type="text/javascript">var _editor_url = "htmlarea/";var editor = null;</script><!-- load the main HTMLArea files --><script type="text/javascript" src="htmlarea/htmlarea.js"></script><style type="text/css">textarea { background-color: #fff; border: 1px solid 00f; }</style><?php	} else if ($htmlEditor==1) //htmlarea beta	{?><script type="text/javascript">var _editor_url = "htmlarea-beta/";var editor = null;</script><!-- load the main HTMLArea files --><script type="text/javascript" src="htmlarea-beta/htmlarea.js"></script><script type="text/javascript" src="htmlarea-beta/lang/en.js"></script><script type="text/javascript" src="htmlarea-beta/dialog.js"></script><script type="text/javascript" src="htmlarea-beta/popupwin.js"></script><style type="text/css">@import url(htmlarea/htmlarea.css);textarea { background-color: #fff; border: 1px solid 00f; }</style><?php	}?></head><body TOPMARGIN="0" leftmargin="0"<?php	if($htmlEditor==1 || $htmlEditor==3)	{?> onload="initEditor()"<?php	}	if($bkimg)		echo " background = \"".$bkimg."\" ";?>><textarea id="holdtext" style="display:none;"></textarea><?php}function undo_html_format($str){	$str = str_replace("&nbsp;"," ",$str);	$str = str_replace("<br />","\n",$str);	$str = str_replace("&gt;", ">", $str);	$str = str_replace("&lt;", "<", $str);	$str = str_replace("&quot;", "\"", $str);	$str = str_replace("&amp;", "&", $str);	$str = str_replace("&apos;", "'", $str);	return $str;}function html_editorstr_format($str){	global $pcconfig;	$str = str_replace($pcconfig["EDITORALERT"],"",$str);	if(strstr($str,$pcconfig["NOWRAPSTR"]))		$str = $pcconfig["NOWRAPSTR"].str_replace($pcconfig["NOWRAPSTR"],"",$str);	return $str;}function html_format($str,$multi=FALSE,$useHtmlTag = FALSE,$defaultfg = "#000000" , $defaultbg = "#FFFFFF"){	global $pcconfig;	$str = trim($str);	if($multi)	{		if(strstr($str,$pcconfig["NOWRAPSTR"]) || $useHtmlTag )			$str = str_replace("<?","&lt;?",$str);		else			$str = nl2br(str_replace(" ","&nbsp;",htmlspecialchars($str)));			//$str = nl2br(ansi_convert(stripslashes($str) , $defaultfg, $defaultbg));		}	else		$str = str_replace(" ","&nbsp;",htmlspecialchars($str));		return $str;	}function time_is_old($t){	return ($t[4] != '-');}function time_mysql($t){	if (time_is_old($t)) return $t;	else return $t[0].$t[1].$t[2].$t[3].$t[5].$t[6].$t[8].$t[9].$t[11].$t[12].$t[14].$t[15].$t[17].$t[18];}function time_format($t){	$t=time_mysql($t);	$t= $t[0].$t[1].$t[2].$t[3]."-".$t[4].$t[5]."-".$t[6].$t[7]." ".$t[8].$t[9].":".$t[10].$t[11].":".$t[12].$t[13];	return $t;}function time_format_date($t){	$t=time_mysql($t);	$t= "<font class='date'>".$t[0].$t[1].$t[2].$t[3]."-".$t[4].$t[5]."-".$t[6].$t[7]."</font>";	return $t;}function time_format_date1($t){	$t=time_mysql($t);	$t= $t[0].$t[1].$t[2].$t[3]."-".$t[4].$t[5]."-".$t[6].$t[7];	return $t;}function rss_time_format($t){	$t=time_mysql($t);	$t= $t[0].$t[1].$t[2].$t[3]."-".$t[4].$t[5]."-".$t[6].$t[7]."T".$t[8].$t[9].":".$t[10].$t[11].":".$t[12].$t[13]."+08:00";	return $t;}function pc_get_links($linkstr){	if(!$linkstr)		return NULL;	$linkarrays = explode("|",$linkstr);		$links = array();	for($i = 0 ; $i < count($linkarrays) ; $i ++ )	{		$linkarray = explode("#",$linkarrays[$i]);		$links[$i] = array("LINK" => base64_decode($linkarray[0]) , "URL" => base64_decode($linkarray[1]) , "IMAGE" => $linkarray[2]?TRUE:FALSE);	}	return $links ;}function pc_friend_file_open($id,$write="r"){	global $pcconfig;	if(!$id || !stristr("ABCDEFGHIJKLMNOPQRSTUVWXYZ",$id[0]))	{		return FALSE;	}	else	{		$file = $pcconfig["HOME"]."/home/".strtoupper($id[0])."/".$id."/pc_friend";		if($write=="w")			$fp = fopen($file,"w");		elseif($write=="a+")			$fp = fopen($file,"a+");		else		{			if(file_exists($file))				$fp = fopen($file,"r");			else			{				return FALSE;				exit();			}		}		$filesize = filesize($file);		$file = array(			"FP" => $fp,			"SIZE" => $filesize			);		return $file;	}}function pc_friend_file_close($fp){	fclose($fp);}function pc_is_friend($userid,$uid){	if(!$file = pc_friend_file_open($uid))		return FALSE;	else	{		$fp = $file["FP"];		while(!feof($fp))		{			$line = trim(fgets($fp,13));				if(strtolower($line)==strtolower($userid))			{				pc_friend_file_close($fp);				return $line;			}			}		pc_friend_file_close($fp);		return FALSE;	}}function pc_is_member($pc,$userid){	global $currentuser;	if(pc_is_manager($currentuser))		return TRUE;		if(!$pc || !is_array($pc))		return FALSE;		$query = "SELECT uid FROM members WHERE uid = ".intval($pc["UID"])." AND username = '".addslashes($userid)."' LIMIT 0 , 1;";	$result = mysql_query($query);	$rows = mysql_fetch_array($result);	mysql_free_result($result);	if(!$rows)		return FALSE;	else		return TRUE;}function pc_get_members($link,$pc){	if(!$pc || !is_array($pc))		return FALSE;	if(!pc_is_groupwork($pc))		return FALSE;	$members = array();	$query = "SELECT username FROM members WHERE uid = '".intval($pc["UID"])."';";		$result = mysql_query($query,$link);	while($rows = mysql_fetch_array($result))		$members[] = $rows[username];	mysql_free_result($result);	return $members;}function pc_add_member($link,$pc,$userid){	global $currentuser,$pcconfig;	if(!$pc || !is_array($pc))		return FALSE;	if(!pc_is_groupwork($pc))		return FALSE;	$lookupuser = array();	if(bbs_getuser($userid,$lookupuser)==0)		return FALSE;		$userid = $lookupuser["userid"];	$query = "INSERT INTO `members` ( `uid` , `username` ) ".	         "VALUES ( '".intval($pc["UID"])."', '".addslashes($userid)."' );";	if(!mysql_query($query,$link))		return FALSE;		$action = "ADD MEMBER: ".$userid; 	if(!pc_group_logs($link,$pc,$action))		exit("群体BLOG LOG错误");		$title = $userid . " 由 " . $currentuser["userid"] . " 授予 " . $pc["USER"] . " 群体BLOG的权利";	$content = "    欢迎加入 ".$pc["USER"]."/".undo_html_format($pc["NAME"])." 大家庭";	// post announcement	bbs_postarticle($pcconfig["APPBOARD"], preg_replace("/\\\(['|\"|\\\])/","$1",$title), preg_replace("/\\\(['|\"|\\\])/","$1",$content), 0 , 0 , 0 , 0);	// post mail	bbs_postmail($userid,preg_replace("/\\\(['|\"|\\\])/","$1",$title), preg_replace("/\\\(['|\"|\\\])/","$1",$content),0,0);	return TRUE;}function pc_del_member($link,$pc,$userid){	global $currentuser;	if(!$pc || !is_array($pc))		return FALSE;	if(!pc_is_groupwork($pc))		return FALSE;	$query = "DELETE FROM members WHERE uid = '".$pc["UID"]."' AND username = '".addslashes($userid)."' LIMIT 1;";	if(!mysql_query($query,$link))		return FALSE;		$action = "DEL MEMBER: ".$userid; 	if(!pc_group_logs($link,$pc,$action))		exit("群体BLOG LOG错误");	$title = $userid . " 由 " . $currentuser["userid"] . " 取消 " . $pc["USER"] . " 群体BLOG的权利";	$content = "    欢迎下次再来 ";	// post announcement	//bbs_postarticle($pcconfig["APPBOARD"], preg_replace("/\\\(['|\"|\\\])/","$1",$title), preg_replace("/\\\(['|\"|\\\])/","$1",$content), 0 , 0 , 0 , 0);	// post mail	$lookupuser = array();	if(bbs_getuser($userid,$lookupuser)!=0) {    	$userid = $lookupuser["userid"];    	bbs_postmail($userid,preg_replace("/\\\(['|\"|\\\])/","$1",$title), preg_replace("/\\\(['|\"|\\\])/","$1",$content),0,0);	}	return TRUE;}function pc_is_admin($currentuser,$pc){	global $pcconfig;	if(pc_is_groupwork($pc))	{		return pc_is_member($pc,$currentuser["userid"]);	}	if(strtolower($pc["USER"]) == strtolower($currentuser["userid"]) && $pc["TS_TIME"] > $currentuser["firstlogin"] && $currentuser["firstlogin"])		return TRUE;	else		return FALSE;}function pc_is_manager($currentuser){	global $pcconfig;	if(!$currentuser || !$currentuser["index"] ) return FALSE;	$ret = 	bbs_is_bm($pcconfig["BRDNUM"], $currentuser["index"]);	return $ret ;}function pc_in_blacklist($link , $userid , $pcuid = 0){	$query = "SELECT * FROM blacklist WHERE userid = '".addslashes($userid)."' AND ( uid = ".intval($pcuid)." OR uid = 0 );";	$result = mysql_query( $query , $link);	$rows = mysql_fetch_array($result);	mysql_free_result($result);	if($rows)		return $rows[manager];	else		return FALSE;}function pc_add_blacklist($link , $userid , $pcuid = 0){	global $currentuser;	$query = "INSERT INTO `blacklist` ( `userid` , `uid` , `manager` , `hostname` , `addtime` ) ".		" VALUES ('".addslashes($userid)."', '".intval($pcuid)."', '".addslashes($currentuser["userid"])."', '".addslashes($_SERVER["REMOTE_ADDR"])."', NOW( ));";		mysql_query($query,$link);}function pc_del_blacklist($link , $userid , $pcuid = 0){	$query = "DELETE FROM blacklist WHERE userid = '".addslashes($userid)."' AND uid = '".intval($pcuid)."';";	mysql_query($query,$link);}function pc_friend_list($uid){	$file = pc_friend_file_open($uid,"r");	if(!$file)		return NULL;	$fp = $file["FP"];	$i = 0;	while(!feof($fp))	{		$line = trim(fgets($fp,14));		if(!$line)			continue;		$friendlist[$i] = $line;		$i ++ ;	}	pc_friend_file_close($fp);	@sort($friendlist);	return $friendlist;}function pc_add_friend($id,$uid){	if(!$file = pc_friend_file_open($uid,"a+"))		return FALSE;	else	{		$fp = $file["FP"];

⌨️ 快捷键说明

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