function DelClassTranFile($classid) { global $empire, $class_r, $dbtbpre, $emod_r; //删除存文本 $mid = $class_r[$classid][modid]; $savetxtf = $emod_r[$mid]['savetxtf']; if ($savetxtf) { $txtsql = $empire->query("select " . $savetxtf . " from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where classid='{$classid}'"); while ($txtr = $empire->fetch($txtsql)) { $newstextfile = $txtr[$savetxtf]; $txtr[$savetxtf] = GetTxtFieldText($txtr[$savetxtf]); DelTxtFieldText($newstextfile); //删除文件 } } //删除附件 $filesql = $empire->query("select id from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where classid='{$classid}'"); while ($filer = $empire->fetch($filesql)) { DelNewsTheFile($filer[id], $classid); //删除附件 } }
function DelInfoData($start, $classid, $from, $retype, $startday, $endday, $startid, $endid, $tbname, $add, $userid, $username) { global $empire, $public_r, $class_r, $fun_r, $dbtbpre, $emod_r; //验证权限 CheckLevel($userid, $username, $classid, "delinfodata"); $search = ''; $start = (int) $start; $tbname = RepPostVar($tbname); if (empty($tbname)) { printerror("ErrorUrl", "history.go(-1)"); } $search .= "&tbname={$tbname}"; //按栏目 $classid = (int) $classid; if ($classid) { if (empty($class_r[$classid][islast])) { $where = ReturnClass($class_r[$classid][sonclass]); } else { $where = "classid='{$classid}'"; } $add1 = " and (" . $where . ")"; $search .= "&classid={$classid}"; } //按ID刷新 $search .= "&retype={$retype}"; if ($retype) { $startid = (int) $startid; $endid = (int) $endid; if ($endid) { $add1 .= " and id>={$startid} and id<={$endid}"; } $search .= "&startid={$startid}&endid={$endid}"; } else { $startday = RepPostVar($startday); $endday = RepPostVar($endday); if ($startday && $endday) { $add1 .= " and truetime>=" . to_time($startday . " 00:00:00") . " and truetime<=" . to_time($endday . " 23:59:59"); } $search .= "&startday={$startday}&endday={$endday}"; } //信息类型 $infost = (int) $add['infost']; if ($infost) { if ($infost == 1) { $add1 .= " and checked=1"; } else { $add1 .= " and checked=0"; } $search .= "&infost={$infost}"; } //用户发布 $ismember = (int) $add['ismember']; if ($ismember) { if ($ismember == 1) { $add1 .= " and userid=0"; } elseif ($ismember == 2) { $add1 .= " and userid>0"; } elseif ($ismember == 3) { $add1 .= " and userid>0 and ismember=1"; } elseif ($ismember == 4) { $add1 .= " and userid>0 and ismember=0"; } $search .= "&ismember={$ismember}"; } //是否外部链接 $isurl = (int) $add['isurl']; if ($isurl) { if ($isurl == 1) { $add1 .= " and titleurl<>''"; } else { $add1 .= " and titleurl=''"; } $search .= "&isurl={$isurl}"; } //评论数 $plnum = (int) $add['plnum']; if ($plnum) { $add1 .= " and plnum<" . $plnum; $search .= "&plnum={$plnum}"; } //点击数 $onclick = (int) $add['onclick']; if ($onclick) { $add1 .= " and onclick<" . $onclick; $search .= "&onclick={$onclick}"; } //下载数 $totaldown = (int) $add['totaldown']; if ($totaldown) { $add1 .= " and totaldown<" . $totaldown; $search .= "&totaldown={$totaldown}"; } //用户ID $userids = RepPostVar($add['userids']); $usertype = (int) $add['usertype']; if ($userids) { $uidsr = explode(',', $userids); $uidscount = count($uidsr); $uids = ''; $udh = ''; for ($ui = 0; $ui < $uidscount; $ui++) { $uids .= $udh . intval($uidsr[$ui]); $udh = ','; } if ($usertype == 1) { $add1 .= " and userid in (" . $uids . ") and ismember=0"; } else { $add1 .= " and userid in (" . $uids . ") and ismember=1"; } $search .= "&userids={$userids}&usertype={$usertype}"; } //标题 $title = RepPostStr($add['title']); if ($title) { $titler = explode('|', $title); $titlecount = count($titler); $titlewhere = ''; $titleor = ''; for ($ti = 0; $ti < $titlecount; $ti++) { $titlewhere .= $titleor . "title like '%" . $titler[$ti] . "%'"; $titleor = ' or '; } $add1 .= " and (" . $titlewhere . ")"; $search .= "&title={$title}"; } $b = 0; $sql = $empire->query("select * from {$dbtbpre}ecms_" . $tbname . " where id>{$start}" . $add1 . " order by id limit " . $public_r[delnewsnum]); while ($r = $empire->fetch($sql)) { $b = 1; $new_start = $r[id]; $mid = $emod_r[$r[classid]]['modid']; $pf = $emod_r[$mid]['pagef']; $stf = $emod_r[$mid]['savetxtf']; //分页字段 if ($pf) { if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) { $finfor = $empire->fetch1("select " . $pf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$r['id']}'"); $r[$pf] = $finfor[$pf]; } } //存文本 if ($stf) { $newstextfile = $r[$stf]; $r[$stf] = GetTxtFieldText($r[$stf]); DelTxtFieldText($newstextfile); //删除文件 } //删除信息文件 if ($add['delhtml'] != 1) { DelNewsFile($r[filename], $r[newspath], $r[classid], $r[$pf], $r[groupid]); } $empire->query("delete from {$dbtbpre}ecms_" . $tbname . " where id='{$r['id']}'"); $empire->query("delete from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$r['id']}'"); //删除其它表记录 $empire->query("delete from {$dbtbpre}enewswfinfo where id='{$r['id']}' and classid='{$r['classid']}'"); $empire->query("delete from {$dbtbpre}enewswfinfolog where id='{$r['id']}' and classid='{$r['classid']}'"); $empire->query("delete from {$dbtbpre}enewsinfovote where id='{$r['id']}' and classid='{$r['classid']}'"); $empire->query("delete from {$dbtbpre}enewsdiggips where id='{$r['id']}' and classid='{$r['classid']}'"); //删除附件 DelNewsTheFile($r['id'], $r['classid']); } if (empty($b)) { //操作日志 insert_dolog(""); printerror("DelNewsAllSuccess", "db/DelData.php"); } echo $fun_r[OneDelDataSuccess] . "(ID:<font color=red><b>" . $new_start . "</b></font>)<script>self.location.href='ecmsinfo.php?enews=DelInfoData&start={$new_start}&from={$from}&delhtml={$add['delhtml']}" . $search . "';</script>"; exit; }
function DelDataTable($add, $userid, $username) { global $empire, $dbtbpre, $emod_r, $class_r; //操作权限 CheckLevel($userid, $username, $classid, "table"); $tid = (int) $add['tid']; $tbname = RepPostVar($add['tbname']); $datatb = (int) $add['datatb']; if (!$tid || !$tbname || !$datatb) { printerror("NotChangeDataTable", "history.go(-1)"); } $tr = $empire->fetch1("select tid,tbname,datatbs,deftb from {$dbtbpre}enewstable where tid='{$tid}'"); if (!$tr['tid']) { printerror("NotChangeDataTable", "history.go(-1)"); } if (!strstr($tr['datatbs'], ',' . $datatb . ',')) { printerror("NotChangeDataTable", "history.go(-1)"); } if ($tr['deftb'] == $datatb || $datatb == 1) { printerror("NotDelDefDataTable", "history.go(-1)"); } $newdatatbs = str_replace(',' . $datatb . ',', ',', $tr['datatbs']); $sql = $empire->query("update {$dbtbpre}enewstable set datatbs='{$newdatatbs}' where tid='{$tid}'"); //删除信息 $infosql = $empire->query("select * from {$dbtbpre}ecms_" . $tr[tbname] . " where stb='{$datatb}'"); while ($infor = $empire->fetch($infosql)) { $mid = $class_r[$infor[classid]]['modid']; $pf = $emod_r[$mid]['pagef']; $stf = $emod_r[$mid]['savetxtf']; //分页字段 if ($pf) { if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) { $finfor = $empire->fetch1("select " . $pf . " from {$dbtbpre}ecms_" . $tr[tbname] . "_data_" . $datatb . " where id='{$infor['id']}'"); $infor[$pf] = $finfor[$pf]; } } //存文本 if ($stf) { $newstextfile = $infor[$stf]; $infor[$stf] = GetTxtFieldText($infor[$stf]); DelTxtFieldText($newstextfile); //删除文件 } //删除信息文件 DelNewsFile($infor[filename], $infor[newspath], $infor[classid], $infor[$pf], $infor[groupid]); //删除其它表记录 $empire->query("delete from {$dbtbpre}enewswfinfo where id='{$infor['id']}' and classid='{$infor['classid']}'"); $empire->query("delete from {$dbtbpre}enewswfinfolog where id='{$infor['id']}' and classid='{$infor['classid']}'"); $empire->query("delete from {$dbtbpre}enewsinfovote where id='{$infor['id']}' and classid='{$infor['classid']}'"); $empire->query("delete from {$dbtbpre}enewsdiggips where id='{$infor['id']}' and classid='{$infor['classid']}'"); //删除附件 DelNewsTheFile($infor['id'], $infor['classid']); } $deltb = $empire->query("delete from {$dbtbpre}ecms_" . $tr[tbname] . " where stb='{$datatb}'"); //删除表 $deltb = $empire->query("DROP TABLE IF EXISTS {$dbtbpre}ecms_" . $tr[tbname] . "_data_" . $datatb . ";"); GetConfig(1); //更新缓存 if ($sql) { //操作日志 insert_dolog("tid=" . $tid . "<br>tbname=" . $tr[tbname] . "&datatb={$datatb}"); printerror("DelDataTableSuccess", "db/ListDataTable.php?tid={$tid}&tbname={$tr['tbname']}"); } else { printerror("DbError", "history.go(-1)"); } }
function DelSingleInfoOtherData($classid, $id, $r, $delfile = 0, $delpl = 0) { global $empire, $dbtbpre, $public_r, $class_r, $emod_r; $pubid = ReturnInfoPubid($classid, $id); //删除其它表记录 $empire->query("delete from {$dbtbpre}enewswfinfo where id='{$id}' and classid='{$classid}'"); $empire->query("delete from {$dbtbpre}enewswfinfolog where id='{$id}' and classid='{$classid}'"); $empire->query("delete from {$dbtbpre}enewsinfovote where pubid='{$pubid}'"); $empire->query("delete from {$dbtbpre}enewsdiggips where id='{$id}' and classid='{$classid}'"); $empire->query("delete from {$dbtbpre}enewsztinfo where id='{$id}' and classid='{$classid}'"); if ($delfile == 0) { DelNewsTheFile($id, $classid, $r['fstb'], $delpl, $r['restb']); //删除附件 } }