📄 global.php
字号:
<?php
/**
*
* Copyright (c) 2003-05 PHPWind.net. All rights reserved.
* Support : http://www.phpwind.net
* This software is the proprietary information of PHPWind.net.
*
*/
error_reporting(0);
set_magic_quotes_runtime(0);
define('R_P','./');
require_once(R_P.'data/bbscache/config.php');
if($db_debug){
error_reporting(E_ALL ^ E_NOTICE);
}
$t_array=explode(' ',microtime());
$P_S_T=$t_array[0]+$t_array[1];
$timestamp=time();
$wind_version="3.0.1";
$db_olsize=96;
$REQUEST_URI=$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
if($_SERVER['HTTP_X_FORWARDED_FOR']){
$onlineip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}elseif($_SERVER['HTTP_CLIENT_IP']){
$onlineip=$_SERVER['HTTP_CLIENT_IP'];
}else{
$onlineip=$_SERVER['REMOTE_ADDR'];
}
$onlineip =substrs($onlineip,16);
if(!get_magic_quotes_gpc()){
Add_S($_POST);
Add_S($_GET);
Add_S($_COOKIE);
}
if(!ini_get('register_globals')){
@extract($_COOKIE,EXTR_SKIP);
@extract($_FILES,EXTR_SKIP);
}
foreach($_POST as $_key=>$_value){
!ereg("^\_",$_key) && $$_key=$_POST[$_key];
}
foreach($_GET as $_key=>$_value){
!ereg("^\_",$_key) && $$_key=$_GET[$_key];
}
$fid=(int)$fid;
$tid=(int)$tid;
require_once(R_P.'data/bbscache/dbset.php');
$db_obstart==1 ? ob_start('ob_gzhandler') : ob_start();
$imgpath=$db_http!='N' ? $db_http : $picpath;
if($db_cvtime!=0) $timestamp+=$db_cvtime*60;
if($lastvisit){
list($c_oltime,$lastvisit,$lastpath)=explode("\t",$lastvisit);
($onbbstime=$timestamp-$lastvisit)<$db_onlinetime && $c_oltime+=$onbbstime;
}else{
$c_oltime=0;
}
if ($db_refreshtime!=0){
if($REQUEST_URI==$lastpath && $onbbstime<$db_refreshtime){
!$_COOKIE['winduser'] && $groupid='guest'; $manager=TRUE;
$skin=$skinco ? $skinco : $db_defaultstyle;
Showmsg("refresh_limit");
}
}
$H_url =& $db_wwwurl;
$B_url =& $db_bbsurl;
require_once(R_P.'data/sql_config.php');
list($db_moneyname,$db_moneyunit,$db_rvrcname,$db_rvrcunit,$db_creditname,$db_creditunit)=explode("\t",$db_credits);
if ($db_bbsifopen==0){
session_name('S'); session_save_path(R_P.'data/bbscache'); session_start();
if (!$_SESSION['_admin_name']){
$skin=$skinco ? $skinco : $db_defaultstyle; $groupid='';
Showmsg($db_whybbsclose);
}
}
$td=floor($timestamp/3600);
$t=getdate($timestamp);
$tdtime=$td*3600-$t['hours']*3600;
$runfc='N';
if($timestamp-$lastvisit>$db_onlinetime || ($fid && $fid!=$_COOKIE['lastfid'])||($_COOKIE['lastfid'] && $wind_in=='hm')){
Cookie('lastfid',$fid);
$runfc='Y';
require_once(R_P.'require/userglobal.php');
}
require_once(R_P.'require/db_'.$database.'.php');
$db = new DB($dbhost, $dbuser, $dbpw, $dbname, $pconnect);
unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect,$manager_pwd);
list($winduid,$windpwd)=explode("\t",$_COOKIE['winduser']);
if($winduid && strlen($windpwd)>=16){
$winddb=User_info();
$winduid=$winddb['uid'];
$groupid=$winddb['groupid'];
$userrvrc=(int)($winddb['rvrc']/10);
$windid=$winddb['username'];
$_datefm=$winddb['datefm'];
$_timedf=$winddb['timedf'];
$skin=$winddb['style'] ? $winddb['style'] : $db_defaultstyle;
} else{
$skin=$db_defaultstyle;
$groupid='guest';unset($winddb);
$windid=$winduid=$_datefm=$_timedf='';
}
if($skinco && file_exists(R_P."data/style/$skinco.php") && strpos($skinco,'..')===false){
Cookie('skinco',$skinco);
}
$skinco && $skin=$skinco;
Ipban();
Cookie('lastvisit',$c_oltime."\t".$timestamp."\t".$REQUEST_URI);
if(isset($_COOKIE['pwdcheck']) && $groupid=='guest') Cookie('pwdcheck','',0);
if($groupid=='-1'){
$groupid=$winddb['memberid'];
}
if($groupid!='guest'){
if(file_exists(R_P."data/groupdb/group_$groupid.php")){
require_once(R_P."data/groupdb/group_$groupid.php");
}else{
require_once(R_P."data/groupdb/group_1.php");
}
} else{
require_once(R_P."data/groupdb/group_2.php");
}
if($db_ads && (is_numeric($u) || ($a && strlen($a)<16))){
require_once(R_P.'require/userads.php');
}
function headguide($guidename=array(),$guide=''){
global $fid,$jinhua;
if(is_array($guidename)){
foreach($guidename as $key=>$value){
if($key){
$headguide.=$value ? " -> <a href='$value'>$key</a>" : " -> $key";
}
}
} else{
$headguide.=" -> ".$guidename;
}
return $headguide;
}
function refreshto($URL,$content,$statime=1){
global $db_ifjump;
if($db_ifjump && $statime>0){
ob_end_clean();
global $tplpath,$fid,$db_http,$picpath,$db_obstart,$db_bbsname,$skin,$B_url;
$index_name =& $db_bbsname;
$index_url =& $B_url;
$db_obstart==1 ? ob_start('ob_gzhandler') : ob_start();
$db_http!='N' ? $imgpath=$db_http : $imgpath=$picpath;
if(file_exists(R_P."data/style/$skin.php") && strpos($skin,'..')===false){
include_once(R_P."data/style/$skin.php");
}else{
include_once(R_P."data/style/wind.php");
}
require_once GetLang('refreshto');
$lang[$content] && $content=$lang[$content];
@require PrintEot('refreshto');
exit;
} else{
ObHeader($URL);
}
}
function ObHeader($URL){
if($GLOBALS[db_obstart]==1){
header("Location: $URL");
}else{
echo "<meta http-equiv='refresh' content='0;url=$URL'>";
}
exit;
}
function Showmsg($msg_info,$dejump=0){
@extract($GLOBALS, EXTR_SKIP);
global $stylepath,$tablewidth,$mtablewidth,$tplpath,$runfc;
$runfc='';
if(defined('SIMPLE')){
echo "<base href=\"$db_bbsurl/\">";
}
require_once("./header.php");
require_once GetLang('msg');
$lang[$msg_info] && $msg_info=$lang[$msg_info];
require_once PrintEot('showmsg');
exit;
}
function GetLang($lang,$EXT="php"){
global $tplpath;
file_exists("./template/$tplpath/lang_$lang.$EXT") ? $path="./template/$tplpath/lang_$lang.$EXT" : $path="./template/wind/lang_$lang.$EXT";
return $path;
}
function PrintEot($template,$EXT="htm"){
global $tplpath;
if(!$template) $template=N;
file_exists("./template/$tplpath/$template.$EXT") ? $path="./template/$tplpath/$template.$EXT" : $path="./template/wind/$template.$EXT";
return $path;
}
function Cookie($ck_Var,$ck_Value,$ck_Time='F'){
global $db_ckpath,$db_ckdomain,$timestamp;
$ck_Time = $ck_Time=='F' ? $timestamp+31536000 : ($ck_Value=='' && $ck_Time==0 ? $timestamp-31536000 : $ck_Time);
$S=$_SERVER['SERVER_PORT']=='443' ? 1:0;
!$db_ckpath && $db_ckpath='/';
setCookie($ck_Var,$ck_Value,$ck_Time,$db_ckpath,$db_ckdomain,$S);
}
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 readover($filename,$method="rb"){
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){
touch($filename);
$handle=fopen($filename,$method);
if($iflock){
flock($handle,LOCK_EX);
}
fputs($handle,$data);
if($method=="rb+") ftruncate($handle,strlen($data));
fclose($handle);
}
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,$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='';
}
}
function footer(){
global $db,$db_obstart,$db_footertime,$P_S_T,$mtablewidth,$db_ceoconnect,$wind_version,$imgpath;
Update_ol();
if($db){
$qn=$db->query_num;
}
$db_obstart==1 ? $ft_gzip="Gzip enabled":$ft_gzip="Gzip disabled";
if ($db_footertime==1){
$t_array=explode(' ',microtime());
$totaltime=number_format(($t_array[0]+$t_array[1]-$P_S_T),6);
$wind_spend="Time $totaltime second(s),query:$qn";
}
include PrintEot('footer');
flush;
exit;
}
function dtchange($user,$wwz,$postn,$money){
global $db;
$db->update("UPDATE pw_memberdata SET postnum=postnum+'$postn',rvrc=rvrc+'$wwz',money=money+'$money' WHERE uid='$user'");
}
function User_info(){
global $db,$timestamp,$db_onlinetime,$winduid,$windpwd,$db_ifonlinetime,$c_oltime,$onlineip,$db_ipcheck;
$ct='';
$detail =$db->get_one("SELECT m.uid,m.username,m.password,m.email,m.groupid,m.memberid,m.regdate,m.timedf,m.style,m.datefm,m.t_num,m.p_num,m.yz,m.newpm,md.postnum,md.rvrc,md.money,md.credit,md.lastvisit,md.thisvisit,md.lastpost,md.todaypost,md.onlineip,md.uploadtime,md.uploadnum,md.editor 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 || md5($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(!$_COOKIE['hideid']){
$ct="lastvisit=thisvisit,thisvisit='$timestamp'";
$detail['lastvisit']=$detail['thisvisit'];
$detail['thisvisit']=$timestamp;
}
if($db_ifonlinetime==1 && $ct){
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 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 getmemberid($nums){
global $db,$lneed;
arsort($lneed);
$gid=array_pop(array_flip($lneed));
reset($lneed);
foreach($lneed as $key=>$lowneed){
if($nums>=$lowneed){
$gid=$key;
break;
}
}
return $gid;
}
function get_date($timestamp,$timeformat=''){
global $db_datefm,$_datefm,$_timedf;
$date_show=$timeformat ? $timeformat : ($_datefm ? $_datefm : $db_datefm);
return date($date_show,$timestamp+$_timedf*60);
}
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('&','&',$msg);
$msg = str_replace(' ',' ',$msg);
$msg = str_replace('"','"',$msg);
$msg = str_replace("'",''',$msg);
$msg = str_replace("<","<",$msg);
$msg = str_replace(">",">",$msg);
$msg = str_replace("\t"," ",$msg);
$msg = str_replace("\r","",$msg);
$msg = str_replace(" "," ",$msg);
return $msg;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -