📄 global.php
字号:
<?php
/**
*
* Copyright (c) 2003-06 PHPWind.net. All rights reserved.
* Support : http://www.phpwind.net
* This software is the proprietary information of PHPWind.com.
*
*/
error_reporting(E_ERROR | E_PARSE);
set_magic_quotes_runtime(0);
$t_array = explode(' ',microtime());
$P_S_T = $t_array[0] + $t_array[1];
define('D_P',__FILE__ ? getdirname(__FILE__).'/' : './');
define('R_P',D_P);
unset($_ENV,$HTTP_ENV_VARS,$_REQUEST,$HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_POST_FILES,$HTTP_COOKIE_VARS);
if(!get_magic_quotes_gpc()){
Add_S($_POST);
Add_S($_GET);
Add_S($_COOKIE);
}
Add_S($_FILES);
if($_SERVER['HTTP_X_FORWARDED_FOR']){
$onlineip = $_SERVER['HTTP_X_FORWARDED_FOR'];
$c_agentip=1;
}elseif($_SERVER['HTTP_CLIENT_IP']){
$onlineip = $_SERVER['HTTP_CLIENT_IP'];
$c_agentip=1;
}else{
$onlineip = $_SERVER['REMOTE_ADDR'];
$c_agentip=0;
}
$onlineip = substrs(str_replace("\n",'',addslashes($onlineip)),16);
$db_cp = '';
$timestamp= time();
require_once(R_P.'require/defend.php');
$db_cvtime != 0 && $timestamp += $db_cvtime*60;
if($db_debug){
error_reporting(E_ALL ^ E_NOTICE);
}
$wind_version = "4.3.2";
$db_olsize = 96;
$htmdir = 'htm_data';
!$_SERVER['PHP_SELF'] && $_SERVER['PHP_SELF']=$_SERVER['SCRIPT_NAME'];
$REQUEST_URI = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
if(strpos($_SERVER['PHP_SELF'],$db_dir)!==false){
$tmp=substr($_SERVER['PHP_SELF'],0,strpos($_SERVER['PHP_SELF'],$db_dir));
}else{
$tmp=$_SERVER['PHP_SELF'];
}
$db_bbsurl="http://$_SERVER[HTTP_HOST]".substr($tmp,0,strrpos($tmp,'/'));
$fid = (int)$fid;
$tid = (int)$tid;
$attachname = $js_path = '';
require_once(D_P.'data/bbscache/dbset.php');
$db_obstart == 1 && function_exists('ob_gzhandler') ? ob_start('ob_gzhandler') : ob_start();
$imgpath = $db_http != 'N' ? $db_http : $picpath;
$attachpath = $db_attachurl != 'N' ? $db_attachurl : $attachname;
$imgdir = R_P.$picpath;
$attachdir = R_P.$attachname;
if(D_P != R_P && $db_http != 'N'){
$R_url=substr($db_http,-1)=='/' ? substr($db_http,0,-1) : $db_http;
$R_url=substr($R_url,0,strrpos($R_url,'/'));
}else{
$R_url=$db_bbsurl;
}
if(GetCookie('lastvisit')){
list($c_oltime,$lastvisit,$lastpath) = explode("\t",GetCookie('lastvisit'));
($onbbstime=$timestamp-$lastvisit)<$db_onlinetime && $c_oltime+=$onbbstime;
}else{
$lastvisit=$lastpath='';
$c_oltime=0;
}
$ol_offset = GetCookie('ol_offset');
$skinco = GetCookie('skinco');
if ($db_refreshtime!=0){
if($REQUEST_URI==$lastpath && $onbbstime<$db_refreshtime){
!GetCookie('winduser') && $groupid='guest';
$manager=TRUE;
$skin = $skinco ? $skinco : $db_defaultstyle;
Showmsg("refresh_limit");
}
}
$H_url =& $db_wwwurl;
$B_url =& $db_bbsurl;
require_once(D_P.'data/sql_config.php');
if ($db_bbsifopen==0){
$CK = explode("\t",StrCode(GetCookie('AdminUser'),'DECODE'));
if ($timestamp-$CK[0]>1800 || $CK[1]!=$manager || !SafeCheck($CK,PwdCode($manager_pwd))){
$skin = $skinco ? $skinco : $db_defaultstyle;
$groupid = '';
Showmsg($db_whybbsclose);
}
}
$t = array('hours'=>gmdate('G',$timestamp+$db_timedf*3600));
$tdtime = (floor($timestamp/3600)-$t['hours'])*3600;
$runfc = 'N';
if($timestamp-$lastvisit>$db_onlinetime || ($fid && $fid != GetCookie('lastfid')) || (GetCookie('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",StrCode(GetCookie('winduser'),'DECODE'));
if(is_numeric($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;
$winddb['onlineip']=substr($winddb['onlineip'],0,strpos($winddb['onlineip'],'|'));
$groupid=='-1' && $groupid=$winddb['memberid'];
if($winddb['showsign'] && (!$winddb['starttime'] && $db_signmoney && strpos($db_signgroup,",$groupid,") !== false && $winddb['currency'] > $db_signmoney || $winddb['starttime'] && $winddb['starttime'] != $tdtime)){
require_once(R_P.'require/Signfunc.php');
Signfunc($winddb['showsign'],$winddb['starttime'],$winddb['currency']);
}
} else{
$skin = $db_defaultstyle;
$groupid = 'guest';
$winddb=$windid=$winduid=$_datefm=$_timedf='';
}
$_GET['skinco'] && $skinco=$_GET['skinco'];
$_POST['skinco'] && $skinco=$_POST['skinco'];
if($skinco && file_exists(D_P."data/style/$skinco.php") && strpos($skinco,'..')===false){
$skin=$skinco;
Cookie('skinco',$skinco);
}
Ipban();
Cookie('lastvisit',$c_oltime."\t".$timestamp."\t".$REQUEST_URI);
if($groupid!='guest'){
if(file_exists(D_P."data/groupdb/group_$groupid.php")){
require_once(D_P."data/groupdb/group_$groupid.php");
}else{
require_once(D_P."data/groupdb/group_1.php");
}
} else{
require_once(D_P."data/groupdb/group_2.php");
}
if($db_ads && !$windid && (is_numeric($u) || ($a && strlen($a)<16)) && strpos($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST'])===false){
Cookie('userads',"$u\t$a");
}
if(!defined('SCR')){
define('SCR','other');
}
$SCR = SCR;
$header_ad=$footer_ad='';
if(SCR != 'read'){
$advertdb = AdvertInit(SCR,$fid);
if(is_array($advertdb['header'])){
$header_ad = $advertdb['header'][array_rand($advertdb['header'])]['code'];
}
if(is_array($advertdb['footer'])){
$footer_ad = $advertdb['footer'][array_rand($advertdb['footer'])]['code'];
}
}
if ($_SERVER['REQUEST_METHOD']=='POST' && strpos($REQUEST_URI,'login.php')===false && strpos($REQUEST_URI,'register.php')===false){
$referer_a=parse_url($_SERVER['HTTP_REFERER']);
$s_host=$_SERVER['HTTP_HOST'];
strpos($s_host,':') && $s_host = substr($s_host,0,strpos($s_host,':'));
if($referer_a['host'] && $referer_a['host']!=$s_host){
Showmsg('undefined_action');
}
}
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;
$URL=str_replace('=','=',$URL);
if($db_ifjump && $statime>0){
ob_end_clean();
global $tplpath,$fid,$imgpath,$db_obstart,$db_bbsname,$skin,$B_url;
$index_name =& $db_bbsname;
$index_url =& $B_url;
$db_obstart==1 ? ob_start('ob_gzhandler') : ob_start();
if(file_exists(D_P."data/style/$skin.php") && strpos($skin,'..')===false){
include_once(D_P."data/style/$skin.php");
}else{
include_once(D_P."data/style/wind.php");
}
@extract($GLOBALS, EXTR_SKIP);
require_once GetLang('refreshto');
$lang[$content] && $content=$lang[$content];
@require PrintEot('refreshto');
exit;
} else{
ObHeader($URL);
}
}
function ObHeader($URL){
global $db_obstart,$db_bbsurl,$db_htmifopen;
if($db_htmifopen && strtolower(substr($URL,0,4))!='http'){
$URL="$db_bbsurl/$URL";
}
if($db_obstart){
header("Location: $URL");exit;
}else{
ob_start();
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(R_P.'require/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;
$path=R_P."template/$tplpath/lang_$lang.$EXT";
!file_exists($path) && $path=R_P."template/wind/lang_$lang.$EXT";
return $path;
}
function PrintEot($template,$EXT="htm"){
//Copyright (c) 2003-06 PHPWind
global $tplpath;
if(!$template) $template=N;
$path=R_P."template/$tplpath/$template.$EXT";
!file_exists($path) && $path=R_P."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 GetCookie($Var){
return $_COOKIE[$Var];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -