📄 postfunc.php
字号:
<?php
!function_exists('readover') && exit('Forbidden');
function cvipfrom($onlineip){
$d_ip=explode(".",$onlineip);
if (file_exists(R_P.'ipdata/$d_ip[0].txt'))
$f_n=R_P."ipdata/$d_ip[0].txt";
else
$f_n=R_P.'ipdata/0.txt';
for($i=0; $i<=3; $i++){
$d_ip[$i] = sprintf("%03d", $d_ip[$i]);
}
$onlineip=join(".",$d_ip);
$db=fopen($f_n,"rb");
flock($db,LOCK_SH);
$data=fread($db,filesize($f_n));
$s_ip="$d_ip[0].$d_ip[1].$d_ip[2]";
if($windset=strpos($data,$s_ip)){
$ipfrom=ipselect($db,$windset,$onlineip);
}else{
$s_ip="$d_ip[0].$d_ip[1]";
if($windset=strpos($data,$s_ip)){
$ipfrom=ipselect($db,$windset,$onlineip);
}elseif($windset=strpos($data,$d_ip[0])){
$s_ip=$d_ip[0];
$ipfrom=ipselect($db,$windset,$onlineip);
}
}
if(empty($ipfrom)){
$ipfrom='Unkown';
if($windset!==false){
while($windset=strpos($data,$s_ip,$windset+32)){
if($ipfrom=ipselect($db,$windset,$onlineip)) break;
}
}
}
fclose($db);
return $ipfrom;
}
function ipselect($db,$offset,$onlineip){
fseek($db,$offset,SEEK_SET);
$l_d=fgets($db,100);
$ip_a=explode("|",$l_d);
if ($onlineip>=$ip_a[0] && $onlineip<=$ip_a[1]) return $ip_a[2].$ip_a[3];
}
function lastinfo($fid,$allowhtm,$type='',$sys_type=''){
global $db;
$rt=$db->get_one("SELECT tid,author,postdate,subject,lastpost,lastposter FROM pw_threads WHERE fid='$fid' ORDER BY lastpost DESC LIMIT 0,1");
if($rt['postdate']==$rt['lastpost']){
$subject=addslashes(substrs($rt['subject'],21));
$author=$rt['author'];
}else{
$subject='Re:'.addslashes(substrs($rt['subject'],21));
$author=$rt['lastposter'];
}
if($type=='new'){
$topicadd=",tpost=tpost+1,article=article+1,topic=topic+1";
} elseif($type=='reply'){
$topicadd=",tpost=tpost+1,article=article+1";
} else{
$topicadd="";
}
$postdate=$rt['lastpost'];
$toread=$sys_type=='1B' ? '&toread=1' : '';
$htmurl='htm_data/'.$fid.'/'.date('ym',$rt['postdate']).'/'.$rt['tid'].'.html';
$new_url=file_exists($htmurl) && $allowhtm && $sys_type!='1B' ? $htmurl : "read.php?tid=$rt[tid]$toread&page=e#a";
$lastpost=$subject."\t".addslashes($author)."\t".$postdate."\t".$new_url;
$db->update("UPDATE pw_forums SET lastpost='$lastpost' $topicadd WHERE fid='$fid'");
$rt=$db->get_one("SELECT fup,type,password,allowvisit,f_type FROM pw_forums WHERE fid='$fid'");
if($rt['password']!='' || $rt['allowvisit']!='' || $rt['f_type']=='hidden'){
$lastpost='';
} else{
$lastpost="lastpost='$lastpost'";
}
if($rt['type']=='sub'){
$topicadd && $topicadd=" tpost=tpost+1,article=article+1,subtopic=subtopic+1";
if($lastpost && $topicadd){
$lastpost.=', ';
}
if($lastpost || $topicadd){
$db->update("UPDATE pw_forums SET $lastpost $topicadd WHERE fid='$rt[fup]'");
$rt1=$db->get_one("SELECT fup,type FROM pw_forums WHERE fid='$rt[fup]'");
if($rt1['type']=='sub'){
$db->update("UPDATE pw_forums SET $lastpost $topicadd WHERE fid='$rt1[fup]'");
}
}
}
}
function bbspostguide(){
global $db,$gp_uploadmoney,$t_date,$f_score,$db_upgrade,$db_hour,$checkuplode,$groupid,$windid,$winduid,$winddb,$db_dtreplyrvrc,$db_dtreplymoney,$db_dtpostrvrc,$db_dtpostmoney,$timestamp,$top_post,$fatherid,$fid,$tid,$tdtime;
if($f_score!=''){
list($P_Prvrc,$P_Rrvrc,$P_Pmoney,$P_Rmoney,$P_Drvrc,$P_Dmoney)=explode("|",$f_score);
is_numeric($P_Prvrc) && $db_dtpostrvrc=$P_Prvrc;
is_numeric($P_Rrvrc) && $db_dtreplyrvrc=$P_Rrvrc;
is_numeric($P_Pmoney) && $db_dtpostmoney=$P_Pmoney;
is_numeric($P_Rmoney) && $db_dtreplymoney=$P_Rmoney;
}
if(file_exists(R_P."data/bbscache/set_cache.php")){
list($set_fb,$set_control,$set_tdtime,$set_null)=explode("|",readover(R_P."data/bbscache/set_cache.php"));
$dtdirtime=$set_control*$db_hour;
if($dtdirtime>24)$dtdirtime=0;
} else{
$dtdirtime=0;
}
if(($timestamp-$set_tdtime)>$dtdirtime*3600){
require_once(R_P.'require/postconcle.php');
}
if($groupid!='guest'){
if($tdtime>=$winddb['lastpost']){
$winddb['todaypost']=1;
} else{
$winddb['todaypost']++;
}
$winddb['lastpost']=$timestamp;
$winddb['postnum']++;
if($checkuplode==1){
//$winddb['rvrc']-=$gp_uploadrvrc;
$winddb['money']-=$gp_uploadmoney;
}
if($top_post){
$winddb['rvrc']+=$db_dtpostrvrc;
$winddb['money']+=$db_dtpostmoney;
} else{
$winddb['rvrc']+=$db_dtreplyrvrc;
$winddb['money']+=$db_dtreplymoney;
}
/*
* 会员等级提升需要变量$db_upgradeway $postnum $rvrc $money
*/
!$db_upgrade && $db_upgrade=1;
if($db_upgrade==1){
$nums=$winddb['postnum'];
} elseif($db_upgrade==2){
$nums=floor($winddb['rvrc']/10);
} elseif($db_upgrade==3){
$nums=$winddb['money'];
} elseif($db_upgrade==4){
$nums=$winddb['credit'];
} else{
Showmsg('postfunc_upgrade_error');
}
$memberid=getmemberid($nums);
$winddb['memberid']!=$memberid && $db->update("UPDATE pw_members SET memberid='$memberid' WHERE uid='$winduid'");
$db->update("UPDATE pw_memberdata SET postnum='$winddb[postnum]',rvrc='$winddb[rvrc]',money='$winddb[money]',todaypost='$winddb[todaypost]',lastpost='$winddb[lastpost]',uploadtime='$winddb[uploadtime]',uploadnum='$winddb[uploadnum]' WHERE uid='$winduid'");
}else{
Cookie('userlastptime',$timestamp);
}
}
function check_data($type="post"){
global $atc_usesign,$article,$msg_info,$vt_select,$db_postmin,$db_postmax,$atc_money;
$atc_title=trim($_POST['atc_title']);
$atc_content=trim($_POST['atc_content']);
unset($_POST['atc_content']);
if (strlen($atc_content)>=$db_postmax || strlen($atc_content)<$db_postmin){
Showmsg('postfunc_content_limit');
}
if(empty($article) && !$atc_title || strlen($atc_title)>100){
Showmsg('postfunc_subject_limit');
}
if ($atc_money>1000 || $atc_money<0){
Showmsg('postfunc_money_limit');
}
if ($type=="vote" && empty($vt_select)){
Showmsg('postfunc_noempty');
}
$atc_title = Char_cv($atc_title);
$atc_content=$atc_usesign<2 ? Char_cv($atc_content) : preg_replace('/javascript/i','java script',str_replace('.','.',$atc_content));
return array($atc_title,$atc_content);
}
//自动url转变函数
function autourl($message){
global $db_autoimg;
if($db_autoimg==1){
$message= preg_replace(array(
"/(?<=[^\]a-z0-9-=\"'\\/])((https?|ftp):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\│]+\.gif)/i",
"/(?<=[^\]a-z0-9-=\"'\\/])((https?|ftp):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\│]+\.jpg)/i"
), array(
"[img]\\1\\3[/img]",
"[img]\\1\\3[/img]"
), ' '.$message);
}
$message= preg_replace( array(
"/(?<=[^\]a-z0-9-=\"'\\/])((https?|ftp|gopher|news|telnet|mms|rtsp):\/\/|www\.)([a-z0-9\/\-_+=.~!%@?#%&;:$\\│]+)/i",
"/(?<=[^\]a-z0-9\/\-_.~?=:.])([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))/i"
), array(
"[url]\\1\\3[/url]",
"[email]\\0[/email]"
), ' '.$message);
return $message;
}
function html_check($souce){
global $db_bbsurl,$picpath,$attachpath;
if(strpos($souce,$db_bbsurl)!==false){
$souce=str_replace($picpath,'p_w_picpath',$souce);
$souce=str_replace($attachpath,'p_w_upload',$souce);
}
return $souce;
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -