📄 admincp.php
字号:
$filedata=str_replace("\n","\n<:wind:>",$filedata);
$filedb=explode("<:wind:>",$filedata);
//array_pop($filedb);
$count=count($filedb);
if($filedb[$count-1]==''||$filedb[$count-1]=="\r"){unset($filedb[$count-1]);}
if(empty($filedb)){$filedb[0]="";}
return $filedb;
}else{
$filedb=file($filename);
return $filedb;
}
}
function adminmsg($msg,$jumpurl='',$t=2)
{
extract($GLOBALS, EXTR_SKIP);
!$basename && $basename=$REQUEST_URI;
if($jumpurl!=''){
$ifjump="<META HTTP-EQUIV='Refresh' CONTENT='$t; URL=$jumpurl'>";
}
require_once GetLang('cpmsg');
$lang[$msg] && $msg=$lang[$msg];
include PrintEot('message');exit;
}
function Char_cv($msg){
$msg = str_replace("\t","",$msg);
$msg = str_replace("<","<",$msg);
$msg = str_replace(">",">",$msg);
$msg = str_replace("\r","",$msg);
$msg = str_replace("\n","<br />",$msg);
$msg = str_replace(" "," ",$msg);#编辑时比较有效
return $msg;
}
function ieconvert($msg){
$msg = str_replace("\t","",$msg);
$msg = str_replace("\r","",$msg);
$msg = str_replace(" "," ",$msg);#编辑时比较有效
return $msg;
}
function Quot_cv($msg){
$msg = str_replace('"','"',$msg);
return $msg;
}
function deldir($path){
if (file_exists($path)){
if(is_file($path)){
P_unlink($path);
} else{
$handle = opendir($path);
while ($file = readdir($handle)) {
if (($file!=".") && ($file!="..") && ($file!="")){
if (is_dir("$path/$file")){
deldir("$path/$file");
} else{
P_unlink("$path/$file");
}
}
}
closedir($handle);
rmdir($path);
}
}
}
function getusergroup($username,$getpostnum=N){
global $db;
include D_P."data/bbscache/level.php";
@extract($db->get_one("SELECT m.groupid,md.postnum FROM pw_members m LEFT JOIN pw_memberdata md ON md.uid=m.uid WHERE m.username='$username'"));
if(ereg("^[0-9]{1,}",$groupid) || $getpostnum==Y){
$count=count($lpost);
for($i=0;$i<$count;$i++){
if($postnum>=$lpost[$i] && $postnum<$lpost[$i+1]){
$groupid=$i;$isalet=1;
break;
}
}
if(!$isalet) $groupid=0;
}
settype($groupid, "string");
return $groupid;
}
function ifadmin($username){
global $db;
$query=$db->query("SELECT forumadmin FROM pw_forums WHERE type<>'category'");
while($forum=$db->fetch_array($query)){
if(strpos($forum['forumadmin'],','.$username.',')!==false){
return true;
}
}
return false;
}
function ifcheck($var,$out){
global ${$out.'_Y'},${$out.'_N'};
if($var) ${$out.'_Y'}="CHECKED"; else ${$out.'_N'}="CHECKED";
}
function F_L_count($filename,$offset)
{
global $onlineip;
$count=0;
if($fp=@fopen($filename,"rb")){
flock($fp,LOCK_SH);
fseek($fp,-$offset,SEEK_END);
$readb=fread($fp,$offset);
fclose($fp);
$readb=trim($readb);
$readb=explode("\n",$readb);
$count=count($readb);$count_F=0;
for($i=$count-1;$i>0;$i--){
if(strpos($readb[$i],"|Logging Failed|$onlineip|")===false){
break;
}
$count_F++;
}
}
return $count_F;
}
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 GetLang($lang,$EXT="php"){
global $tplpath;
if($lang == 'email' || $lang == 'log' || $lang == 'bbscode'){
$path=R_P."template/$tplpath/lang_$lang.$EXT";
!file_exists($path) && $path=R_P."template/wind/lang_$lang.$EXT";
return $path;
} else{
$L_P = eregi('^c_',$lang) ? C_P : R_P;
$adminpath=file_exists($L_P."template/admin_$tplpath") ? "admin_$tplpath" : 'admin'; $path=$L_P."template/$adminpath/cp_lang_$lang.$EXT";
}
return $path;
}
function PrintEot($template,$EXT="htm")
{
global $tplpath;
$L_P = eregi('^c_',$template) ? C_P : R_P;
///cms
if($template=='bbscode' || $template=='c_header' || $template=='c_footer'){
$path=$L_P."template/$tplpath/$template.$EXT";
!file_exists($path) && $path=$L_P."template/wind/$template.$EXT";
return $path;
}
///cms
$adminpath=file_exists($L_P."template/admin_$tplpath") ? "admin_$tplpath" : 'admin';
if(!$template) $template='N';
$path=$L_P."template/$adminpath/$template.$EXT";
return $path;
}
function readlog($filename,$offset=1024000)
{
$readb=array();
if($fp=@fopen($filename,"rb")){
flock($fp,LOCK_SH);
$size=filesize($filename);
$size>$offset ? fseek($fp,-$offset,SEEK_END): $offset=$size;
$readb=fread($fp,$offset);
fclose($fp);
$readb=str_replace("\n","\n<:wind:>",$readb);
$readb=explode("<:wind:>",$readb);
$count=count($readb);
if($readb[$count-1]==''||$readb[$count-1]=="\r"){unset($readb[$count-1]);}
if(empty($readb)){$readb[0]="";}
}
return $readb;
}
function checkselid($selid){
if(is_array($selid)){
$ret='';
foreach($selid as $key => $value){
if(!is_numeric($value)){
return false;
}
$ret .= $ret ? ','.$value : $value;
}
return $ret;
} else{
return '';
}
}
function ObHeader($URL){
echo "<meta http-equiv='refresh' content='0;url=$URL'>";exit;
}
function updateadmin(){
global $db;
$query=$db->query("SELECT forumadmin FROM pw_forums");
while($forum=$db->fetch_array($query)){
$adminarray=explode(",",addslashes($forum['forumadmin']));
foreach($adminarray as $key=>$value){
$value=trim($value);
if($value){
$f_admin[]=$value;
}
}
}
$f_admin=array_unique($f_admin);
$query=$db->query("SELECT uid,username,groupid,groups FROM pw_members WHERE groupid=5 OR groups LIKE '%,5,%'");
while($rt=$db->fetch_array($query)){
if(!in_array($rt['username'],$f_admin)){
if($rt['groupid']=='5'){
$db->update("UPDATE pw_members SET groupid='-1' WHERE uid='$rt[uid]'");
}else{
$groups=str_replace(',5,','',$rt['groups']);
$db->update("UPDATE pw_members SET groups='$groups' WHERE uid='$rt[uid]'");
}
}
}
foreach($f_admin as $key => $value){
$rt=$db->get_one("SELECT uid,username,groupid,groups FROM pw_members WHERE username='$value'");
if($rt['uid']){
if($rt['groupid']=='-1'){
$db->update("UPDATE pw_members SET groupid='5' WHERE uid='$rt[uid]'");
} elseif($rt['groupid']!='5' && strpos($rt['groups'],',5,')===false){
$groups=$rt['groups'] ? $rt['groups'].'5,' : ",5,";
$db->update("UPDATE pw_members SET groups='$groups' WHERE uid='$rt[uid]'");
}
}
}
}
function GetAllowForum($username){
global $db;
$allowfid = '-99';
$forumoption = '';
$query = $db->query("SELECT fid,name,forumadmin FROM pw_forums WHERE type!='category' AND forumadmin LIKE '%,$username,%'");
while($rt = $db->fetch_array($query)){
$allowfid .= ','.$rt['fid'];
$forumoption .= "<option value='$rt[fid]'> >> $rt[name]</option>";
}
return array($allowfid,$forumoption);
}
function GetHiddenForum(){
global $db;
$forumoption = '<option></option>';
$allowfid = '-99';
$query = $db->query("SELECT fid,name FROM pw_forums WHERE f_type='hidden'");
while ($rt = $db->fetch_array($query)){
$allowfid .= $allowfid ? ','.$rt['fid'] : $rt['fid'];
$forumoption .= "<option value=\"$rt[fid]\"> |- $rt[name]</option>";
}
return array($allowfid,$forumoption);
}
function Iplimit(){
global $db_iplimit,$onlineip;
if($db_iplimit){
$ip_a=explode(",",$db_iplimit);
foreach($ip_a as $k=>$v){
if(!$v)continue;
$v=trim($v);
if(strpos(','.$onlineip.'.',','.$v.'.')===false){
adminmsg('ip_ban');
}
}
}
}
function CheckVar($var){
if(is_array($var)){
foreach($var as $key=>$value){
if(!in_array($key,array('module'))){
CheckVar($value);
}
}
}else{
$tar = array('<iframe','<meta','<script');
foreach($tar as $k=>$v){
if(strpos(strtolower($var),$v)!==false){
global $basename;
$basename="javascript:history.go(-1);";
adminmsg('word_error');
}
}
}
}
function PostLog($log){
foreach($log as $key=>$val){
if(is_array($val)){
$data .= "$key=array(".PostLog($val).")";
}else{
$val = str_replace(array("\n","\r","|"),array('','','|'),$val);
$data .= "$key=$val, ";
}
}
return $data;
}
function GdConfirm($code){
Cookie('cknum','',0);
if(!$code || !SafeCheck(explode("\t",StrCode(GetCookie('cknum'),'DECODE')),$code,'cknum',300)){
return false;
}else{
return true;
}
}
function GetModulePath($SCR){
global $db,$timestamp,$fid,$db_cmsper;
if($SCR == 'index'){
$cachefile = D_P.'data/bbscache/c_module_'.$SCR.'php';
}elseif($SCR == 'read'){
$cachefile = D_P.'data/bbscache/c_module_thread_'.(int)$fid.'.php';
}else{
$cachefile = D_P.'data/bbscache/c_module_'.$SCR.'_'.(int)$fid.'.php';
}
if(!file_exists($cachefile) || $timestamp - filemtime($cachefile) > $db_cmsper*60){
require(C_P.'require/c_module_func.php');
}
return $cachefile;
}
function EncodeUrl($url){
global $db_hash,$admin_name,$admin_gid;
$url_a=substr($url,strrpos($url,'?')+1);
substr($url,-1)=='&' && $url=substr($url,0,-1);
parse_str($url_a,$url_a);
$source='';
foreach($url_a as $key=>$val){
$source .= $key.$val;
}
$posthash=substr(md5($source.$admin_name.$admin_gid.$db_hash),0,8);
$url .= "&verify=$posthash";
return $url;
}
function FormCheck($pre,$url,$add){
$pre=stripslashes($pre);
$add=stripslashes($add);
return "<form{$pre} action=\"".EncodeUrl($url)."&\"{$add}>";
}
function PostCheck($verify){
global $db_hash,$admin_name,$admin_gid;
$source='';
foreach($_GET as $key=>$val){
if($key!='verify'){
$source .= $key.$val;
}
}
if($verify!=substr(md5($source.$admin_name.$admin_gid.$db_hash),0,8)){
adminmsg('illegal_request');
}else{
return true;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -