📄 superdel.php
字号:
<?php
!function_exists('adminmsg') && exit('Forbidden');
require_once(R_P.'require/forum.php');
if($a_type=='article'){
require_once(R_P.'require/updateforum.php');
$basename="$admin_file?adminjob=superdel&a_type=article";
if ($admin_gid == 5){
list($allowfid,$forumcache) = GetAllowForum($admin_name);
$sql = "fid IN($allowfid)";
} else {
include D_P.'data/bbscache/forumcache.php';
list($hidefid,$hideforum) = GetHiddenForum();
if($admin_gid == 3){
$forumcache .= $hideforum;
$sql = '1';
} else{
$sql = "fid NOT IN($hidefid)";
}
}
if(empty($action)){
include PrintEot('superdel');exit;
} elseif($action=='deltpc'){
if(empty($_POST['step'])){
if($fid=='-1' && !$postdate && !$tcounts && !$counts && !$lastpost && !$hits && !$replies && !$author && !$keyword && !$userip){
adminmsg('noenough_condition');
} else{
if(is_numeric($fid) && $fid > 0){
$sql .= " AND t.fid='$fid'";
}
if($ifkeep){
$sql.=" AND t.topped=0 AND t.digest=0";
}
if($postdate){
$schtime=$timestamp-$postdate*24*3600;
$sql.=" AND t.postdate<$schtime";
}
if($lastpost){
$schtime=$timestamp-$lastpost*24*3600;
$sql.=" AND t.lastpost<$schtime";
}
$hits && $sql.=" AND t.hits<".(int)$hits;
$replies && $sql.=" AND t.replies<".(int)$replies;
if($tcounts){
$sql.=" AND char_length(tm.content)>".(int)$tcounts;
}elseif($counts){
$sql.=" AND char_length(tm.content)<".(int)$counts;
}
if($author){
$authorarray=explode(",",$author);
foreach($authorarray as $value){
$value=addslashes(str_replace('*','%',$value));
$authorwhere.=" OR t.author LIKE '$value'";
}
$authorwhere=substr_replace($authorwhere,"",0,3);
$sql.=" AND ($authorwhere)";
}
if($keyword){
$keyword=trim($keyword);
$keywordarray=explode(",",$keyword);
foreach($keywordarray as $value){
$value=str_replace('*','%',$value);
$keywhere.='OR';
$keywhere.=" tm.content LIKE '%$value%' OR t.subject LIKE '%$value%' ";
}
$keywhere=substr_replace($keywhere,"",0,3);
$sql.=" AND ($keywhere) ";
}
if($userip){
$userip=str_replace('*','%',$userip);
$sql.=" AND (tm.userip LIKE '$userip') ";
$ip_add=',tm.userip';
}
$rs=$db->get_one("SELECT COUNT(*) AS count FROM pw_threads t LEFT JOIN pw_tmsgs tm ON tm.tid=t.tid WHERE $sql");
$count=$rs['count'];
if(!is_numeric($lines))$lines=100;
(!is_numeric($page) || $page < 1) && $page=1;
$numofpage=ceil($count/$lines);
if($numofpage&&$page>$numofpage){
$page=$numofpage;
}
$pages=numofpage($count,$page,$numofpage,"$admin_file?adminjob=superdel&a_type=article&action=$action&fid=$fid&ifkeep=$ifkeep&postdate=$postdate&lastpost=$lastpost&hits=$hits&replies=$replies&author=".rawurlencode($author)."&keyword=".rawurlencode($keyword)."&userip=$userip&lines=$lines&");
$start=($page-1)*$lines;
$limit="LIMIT $start,$lines";
$topicdb=array();
include D_P.'data/bbscache/forum_cache.php';
$query=$db->query("SELECT t.*,tm.userip FROM pw_threads t LEFT JOIN pw_tmsgs tm ON tm.tid=t.tid WHERE $sql $limit");
while($topic=$db->fetch_array($query)){
if($_POST['direct']){
$delid[$topic['tid']]=$topic['fid'];
} else{
$topic['forumname'] = $forum[$topic['fid']]['name'];
$topic['postdate'] = get_date($topic['postdate']);
$topic['lastpost'] = get_date($topic['lastpost']);
$topicdb[]=$topic;
}
}
if(!$_POST['direct']){
include PrintEot('superdel');exit;
}
}
}
if($_POST['step']==2 || $_POST['direct']){
!$delid && adminmsg('operate_error');
$delids=$delaids=$pollids='';
$fidarray=array();
foreach($delid as $key=>$value){
is_numeric($key) && $delids.=$key.',';
if(!in_array($value,$fidarray)){
$fidarray[]=$value;
}
}
$delids=substr($delids,0,-1);
/**
* 删除帖子
*/
$query=$db->query("SELECT t.tid,t.fid,t.postdate,tm.aid,t.ifupload,t.pollid FROM pw_threads t LEFT JOIN pw_tmsgs tm ON tm.tid=t.tid WHERE $sql AND t.tid IN($delids)");
while(@extract($db->fetch_array($query))){
if($aid){
$attachs= unserialize(stripslashes($aid));
foreach($attachs as $key=>$value){
is_numeric($key) && $delaids.=$key.',';
P_unlink("$attachdir/$value[attachurl]");
}
}
is_numeric($pollid) && $pollids.=$pollid.',';
if($ifupload){
$query2=$db->query("SELECT aid FROM pw_posts WHERE tid='$tid'");
while(@extract($db->fetch_array($query2))){
if($aid){
$attachs= unserialize(stripslashes($aid));
foreach($attachs as $key=>$value){
is_numeric($key) && $delaids.=$key.',';
P_unlink("$attachdir/$value[attachurl]");
}
}
}
}
$htmurl=$htmdir.'/'.$fid.'/'.date('ym',$postdate).'/'.$tid.'.html';
if(file_exists(R_P.$htmurl)){
P_unlink(R_P.$htmurl);
}
}
if($pollids){
$pollids=substr($pollids,0,-1);
$db->update("DELETE FROM pw_polls WHERE pollid IN($pollids)");
}
if($delaids){
$delaids=substr($delaids,0,-1);
$db->update("DELETE FROM pw_attachs WHERE aid IN($delaids)");
}
$db->update("DELETE FROM pw_threads WHERE tid IN ($delids)");
$db->update("DELETE FROM pw_posts WHERE tid IN ($delids)");
$db->update("DELETE FROM pw_tmsgs WHERE tid IN ($delids)");
/**
* 数据更新
*/
foreach($fidarray as $fid){
updateforum($fid);
}
P_unlink(D_P.'data/bbscache/c_cache.php');
adminmsg('operate_success');
}
} elseif($action=='delrpl'){
if(empty($_POST['step'])){
if(!$counts && !$tcounts && $fid=='-1' && !$keyword && !$tid && !$author && !$userip){
adminmsg('noenough_condition');
}
if(is_numeric($fid) && $fid > 0){
$sql .= " AND fid='$fid'";
}
if($tid){
$tids = 0;
$tid_array=explode(",",$tid);
foreach($tid_array as $value){
if(is_numeric($value)){
$tids.=','.$value;
}
}
$tids && $sql.=" AND tid IN($tids)";
}
if($author){
$authorarray=explode(",",$author);
foreach($authorarray as $value){
$value=addslashes(str_replace('*','%',$value));
$authorwhere.=" OR author LIKE '$value'";
}
$authorwhere=substr_replace($authorwhere,"",0,3);
$sql.=" AND ($authorwhere)";
}
if($keyword){
$keyword=trim($keyword);
$keywordarray=explode(",",$keyword);
foreach($keywordarray as $value){
$value=str_replace('*','%',$value);
$keywhere.=" OR content LIKE '%$value%' ";
}
$keywhere=substr_replace($keywhere,"",0,3);
$sql.=" AND ($keywhere) ";
}
if($userip){
$userip=str_replace('*','%',$userip);
$sql.=" AND (userip LIKE '$userip') ";
}
if($tcounts){
$sql.=" AND char_length(content)>".(int)$tcounts;
}elseif($counts){
$sql.=" AND char_length(content)<".(int)$counts;
}
$nums=is_numeric($nums) ? $nums : 20;
(!is_numeric($page) || $page < 1) && $page = 1;
$limit = " LIMIT ".($page-1)*$nums.",$nums";
$rt = $db->get_one("SELECT COUNT(*) AS sum FROM pw_posts WHERE $sql");
$pages = numofpage($rt['sum'],$page,ceil($rt['sum']/$nums),"$admin_file?adminjob=superdel&a_type=article&action=$action&fid=$fid&tid=$tid&author=".rawurlencode($author)."&keyword=".rawurlencode($keyword)."&userip=$userip&tcounts=$tcounts&counts=$counts&nums=$nums&");
$sql .= $_POST['direct'] ? " LIMIT $nums" : $limit;
$query=$db->query("SELECT fid,pid,tid,subject,author,authorid,content,postdate,userip FROM pw_posts WHERE $sql");
while($post=$db->fetch_array($query)){
if($_POST['direct']){
$delid[$post['pid']]=$post['fid'].'_'.$post['tid'];
} else{
$post['delid']=$post['fid'].'_'.$post['tid'];
$post['forumname'] = $forum[$post['fid']]['name'];
$post['postdate'] = get_date($post['postdate']);
$post['content']=substrs($post['content'],30);
$postdb[]=$post;
}
}
if(!$_POST['direct']){
include PrintEot('superdel');exit;
}
}
if($_POST['step']==2 || $_POST['direct']){
!$delid && adminmsg('operate_error');
$delids=$dtids='';
$fidarray=$tidarray=array();
foreach($delid as $key=>$value){
is_numeric($key) && $delids.=$key.',';
list($dfid,$dtid)=explode('_',$value);
$tidarray[]=$dtid;
$dtids.=$dtid.',';
if(!in_array($value,$fidarray)){
$fidarray[]=$dfid;
}
}
$delids=substr($delids,0,-1);
$dtids=substr($dtids,0,-1);
/**
* 删除帖子
*/
$query=$db->query("SELECT t.tid,t.fid,t.postdate,tm.aid,t.ifupload,t.pollid FROM pw_threads t LEFT JOIN pw_tmsgs tm ON tm.tid=t.tid WHERE t.tid IN($dtids) AND $sql");
while(@extract($db->fetch_array($query))){
$htmurl=$htmdir.'/'.$fid.'/'.date('ym',$postdate).'/'.$tid.'.html';
if(file_exists(R_P.$htmurl)){
P_unlink(R_P.$htmurl);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -