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

📄 global.php

📁 网站代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
function GetCookie($Var){
	return $_COOKIE[$Var];
}
function Ipban(){
	global $db_ipban,$onlineip,$imgpath,$stylepath;
	if($db_ipban){
		$baniparray=explode(",",$db_ipban);
		foreach($baniparray as $banip){
			if(!$banip)continue;
			$banip=trim($banip);
			if(strpos(','.$onlineip.'.',','.$banip.'.')!==false){
				Showmsg('ip_ban');
			}
		}
	}
}
function P_unlink($filename){
	strpos($filename,'..')!==false && exit('Forbidden');
	@unlink($filename);
}
function readover($filename,$method="rb"){
	strpos($filename,'..')!==false && exit('Forbidden');
	if($handle=@fopen($filename,$method)){
		flock($handle,LOCK_SH);
		$filedata=@fread($handle,filesize($filename));
		fclose($handle);
	}
	return $filedata;
}
function writeover($filename,$data,$method="rb+",$iflock=1,$check=1,$chmod=1){
	$check && strpos($filename,'..')!==false && exit('Forbidden');
	touch($filename);
	$handle=fopen($filename,$method);
	if($iflock){
		flock($handle,LOCK_EX);
	}
	fwrite($handle,$data);
	if($method=="rb+") ftruncate($handle,strlen($data));
	fclose($handle);
	$chmod && @chmod($filename,0777);
}
function openfile($filename){
	$filedata=readover($filename);
	$filedata=str_replace("\n","\n<:wind:>",$filedata);
	$filedb=explode("<:wind:>",$filedata);
	$count=count($filedb);
	if($filedb[$count-1]==''||$filedb[$count-1]=="\r"){unset($filedb[$count-1]);}
	if(empty($filedb)){$filedb[0]="";}
	return $filedb;
}
function Update_ol(){
	global $runfc;
	if($runfc == 'Y'){
		global $ol_offset,$winduid,$db_ipstates,$isModify;
		if($winduid != ''){
			list($alt_offset,$isModify) = addonlinefile($ol_offset,$winduid);
		}else{
			list($alt_offset,$isModify) = addguestfile($ol_offset);
		}
		if($alt_offset!=$ol_offset)Cookie('ol_offset',$alt_offset,0);
		$runfc='';
		if($db_ipstates && ((!GetCookie('ipstate') && $isModify===1) || (GetCookie('ipstate') && GetCookie('ipstate')<$GLOBALS['tdtime']))){
			require_once(R_P.'require/ipstates.php');
		}
	}
}
function footer(){
	global $db,$db_obstart,$db_footertime,$P_S_T,$mtablewidth,$db_ceoconnect,$wind_version,$imgpath,$stylepath,$footer_ad,$db_union,$timestamp;
	Update_ol();
	if($db){
		$qn=$db->query_num;
	}
	$ft_gzip=($db_obstart==1 ? "Gzip enabled" : "Gzip disabled").$db_union[3];
	if ($db_footertime == 1){
		$t_array	= explode(' ',microtime());
		$totaltime	= number_format(($t_array[0]+$t_array[1]-$P_S_T),6);
		$wind_spend	= "Total $totaltime(s) query $qn,";
	}
	$ft_time=get_date($timestamp,'m-d H:i');
	include PrintEot('footer');
	$output = str_replace(array('<!--<!---->','<!---->'),array('',''),ob_get_contents());

	ob_end_clean();
	$db_obstart == 1 ? ob_start('ob_gzhandler') : ob_start();
	echo $output;
	flush;
	exit;
}
function User_info(){
	global $db,$timestamp,$db_onlinetime,$winduid,$windpwd,$db_ifonlinetime,$c_oltime,$onlineip,$db_ipcheck,$tdtime;
	$ct='';
	$detail =$db->get_one("SELECT m.uid,m.username,m.password,m.email,oicq,m.groupid,m.memberid,m.regdate,m.timedf,m.style,m.datefm,m.t_num,m.p_num,m.yz,m.newpm,m.showsign,m.payemail,md.postnum,md.rvrc,md.money,md.credit,md.currency,md.lastvisit,md.thisvisit,md.onlinetime,md.lastpost,md.todaypost,md.onlineip,md.uploadtime,md.uploadnum,md.editor,md.starttime FROM pw_members m LEFT JOIN pw_memberdata md USING(uid) WHERE m.uid='$winduid'");
	if(strpos($detail['onlineip'],$onlineip)===false){
		$iparray=explode(".",$onlineip);
		if(strpos($detail['onlineip'],$iparray[0].'.'.$iparray[1])===false) $loginout='Y';
	}
	if(!$detail || PwdCode($detail['password']) != $windpwd || ($loginout=='Y' && $db_ipcheck==1)){
		unset($detail);
		$GLOBALS['groupid']='guest';
		require_once(R_P.'require/checkpass.php');
		Loginout();
		Showmsg('ip_change');
	}else{
		unset($detail['password']);
		if($timestamp-$detail['thisvisit']>$db_onlinetime){
			if(!GetCookie('hideid')){
				$ct="lastvisit=thisvisit,thisvisit='$timestamp'";
				$detail['lastvisit'] = $detail['thisvisit'];
				$detail['thisvisit'] = $timestamp;
			}
			if($db_ifonlinetime == 1 && $ct && $c_oltime > 0){
				if($c_oltime > $db_onlinetime*1.2){
					$c_oltime = $db_onlinetime;
				}
				$ct		 .= ",onlinetime=onlinetime+'$c_oltime'";
				$c_oltime = 0;
			}
			$ct && $db->update("UPDATE pw_memberdata SET $ct WHERE uid='$winduid' AND $timestamp-thisvisit>$db_onlinetime");
		}
	}
	return $detail;
}
function PwdCode($pwd){
	return md5($_SERVER["HTTP_USER_AGENT"].$pwd.$GLOBALS['db_hash']);
}
function SafeCheck($CK,$PwdCode,$var='AdminUser',$expire=1800){
	global $timestamp;
	$t	= $timestamp - $CK[0];
	if($t > $expire || $CK[2] != md5($PwdCode.$CK[0])){
		Cookie($var,'',0);
		return false;
	}else{
		$CK[0] = $timestamp;
		$CK[2] = md5($PwdCode.$timestamp);
		$Value = implode("\t",$CK);
		$$var  = StrCode($Value);
		Cookie($var,StrCode($Value));
		return true;
	}
}
function StrCode($string,$action='ENCODE'){
	$key	= substr(md5($_SERVER["HTTP_USER_AGENT"].$GLOBALS['db_hash']),8,18);
	$string	= $action == 'ENCODE' ? $string : base64_decode($string);
	$len	= strlen($key);
	$code	= '';
	for($i=0; $i<strlen($string); $i++){
		$k		= $i % $len;
		$code  .= $string[$i] ^ $key[$k];
	}
	$code = $action == 'DECODE' ? $code : base64_encode($code);
	return $code;
}
function substrs($content,$length){
	if($length && strlen($content)>$length){
		$num=0;
		for($i=0;$i<$length-3;$i++){
			if(ord($content[$i])>127){
				$num++;
			}
		}
		$num%2==1 ? $content=substr($content,0,$length-4):$content=substr($content,0,$length-3);
		$content.='..';
	}
	return $content;
}
function get_date($timestamp,$timeformat=''){
	global $db_datefm,$db_timedf,$_datefm,$_timedf;
	$date_show=$timeformat ? $timeformat : ($_datefm ? $_datefm : $db_datefm);
	if($_timedf){
		$offset = $_timedf=='111' ? 0 : $_timedf;
	}else{
		$offset = $db_timedf=='111' ? 0 : $db_timedf;
	}
	return gmdate($date_show,$timestamp+$offset*3600);
}
function Add_S(&$array){
	foreach($array as $key=>$value){
		if(!is_array($value)){
			$array[$key]=addslashes($value);
		}else{
			Add_S($array[$key]);
		}
	}
}
function Char_cv($msg){
	$msg = str_replace('&amp;','&',$msg);
	$msg = str_replace('&nbsp;',' ',$msg);
	$msg = str_replace('"','&quot;',$msg);
	$msg = str_replace("'",'&#39;',$msg);
	$msg = str_replace("<","&lt;",$msg);
	$msg = str_replace(">","&gt;",$msg);
	$msg = str_replace("\t"," &nbsp; &nbsp;",$msg);
	$msg = str_replace("\r","",$msg);
	$msg = str_replace("   "," &nbsp; ",$msg);
	return $msg;
}
function GdConfirm($code){
	global $gdnum,$db_ckmethod;
	if($db_ckmethod==2){
		Cookie('cknum','',0);
		if(!$code || !SafeCheck(explode("\t",StrCode(GetCookie('cknum'),'DECODE')),$code,'cknum',1800)){
			Showmsg('check_error');
		}
	}else{
		require_once(R_P.'require/gdcheck.php');
		if(!$code || $code != ConcleGd(GetCookie('ol_offset'),'',$code)){//!$code 的必要性
			$gdnum='';
			Showmsg('check_error');
		}else{
			$gdnum=$code;
		}
	}
}
function AdvertInit($SCR,$fid){
	include(D_P.'data/bbscache/advert_data.php');
	$newadvert = array();
	foreach($advertdb as $key=>$val){
		foreach($val as $k=>$v){
			if(!$v['endtime'] || strtotime($v['endtime']) < $timestamp){
				continue;
			}
			if($SCR == 'index' && strpos(",$v[fid],",",-1,")!==false){
				$newadvert[$key][]=$v;
			}elseif($SCR == 'thread' && strpos(",$v[fid],",",-2,")!==false){
				$newadvert[$key][]=$v;
			}elseif($SCR == 'read' && strpos(",$v[fid],",",-3,")!==false){
				$newadvert[$key][]=$v;
			}elseif(strpos(",$v[fid],",",-4,")!==false){
				$newadvert[$key][]=$v;
			}elseif($fid && strpos(",$v[fid],",",$fid,")!==false){
				$newadvert[$key][]=$v;
			}
		}
	}
	return $newadvert;
}
function getdirname($path){
	if(strpos($path,'\\')!==false){
		return substr($path,0,strrpos($path,'\\'));
	}elseif(strpos($path,'/')!==false){
		return substr($path,0,strrpos($path,'/'));
	}else{
		return '/';
	}
}

require_once(D_P."api/passport.config.php");  //phpcms 与 phpwind通行证配置文件
?>

⌨️ 快捷键说明

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