003 |
function DelArc($aid,$type='ON',$onlyfile=false) |
007 |
global $dsql,$cfg_cookie_encode,$cfg_multi_site,$cfg_medias_dir; |
009 |
global $cuserLogin,$cfg_upload_switch,$cfg_delete,$cfg_basedir; |
011 |
global $admin_catalogs, $cfg_admin_channel; |
013 |
if($cfg_delete == 'N') $type = 'OK'; |
015 |
if(empty($aid)) return ; |
017 |
$aid = ereg_replace("[^0-9]", '', $aid); |
019 |
$arctitle = $arcurl = ''; |
023 |
$query = "Select ch.maintable,ch.addtable,ch.nid,ch.issystem From `dede_arctiny` arc |
025 |
left join `dede_arctype` tp on tp.id=arc.typeid |
027 |
left join `dede_channeltype` ch on ch.id=arc.channel where arc.id='$aid' "; |
029 |
$row = $dsql->GetOne($query); |
033 |
$maintable = (trim($row['maintable'])=='' ? 'dede_archives' : trim($row['maintable'])); |
035 |
$addtable = trim($row['addtable']); |
037 |
$issystem = $row['issystem']; |
045 |
$arcQuery = "Select arc.*,tp.* from `$addtable` arc left join `dede_arctype` tp on arc.typeid=tp.id where arc.aid='$aid' "; |
053 |
$arcQuery = "Select arc.*,tp.*,arc.id as aid from `$maintable` arc left join `dede_arctype` tp on arc.typeid=tp.id where arc.id='$aid' "; |
057 |
$arcRow = $dsql->GetOne($arcQuery); |
059 |
$arcBodyRow = GetArcBody($aid); |
063 |
if(!TestPurview('a_Del,sys_ArcBatch')) |
067 |
if(TestPurview('a_AccDel')) |
071 |
if( !in_array($arcRow['typeid'], $admin_catalogs) && (count($admin_catalogs) != 0 || $cfg_admin_channel != 'all') ) |
081 |
else if(TestPurview('a_MyDel')) |
085 |
if($arcRow['mid'] != $cuserLogin->getUserID()) |
105 |
//$issystem==-1 是单表模型,不使用回收站 |
107 |
if($issystem == -1) $type = 'OK'; |
109 |
if(!is_array($arcRow)) return false; |
113 |
if($cfg_delete == 'Y' && $type == 'ON') |
117 |
$dsql->ExecuteNoneQuery("Update `$maintable` set arcrank='-2' where id='$aid' "); |
119 |
$dsql->ExecuteNoneQuery("Update `dede_arctiny` set `arcrank` = '-2' where id = '$aid'; "); |
135 |
if($cfg_upload_switch == 'Y') |
139 |
$dsql->Execute("me", "SELECT * FROM `dede_uploads` WHERE arcid = '$aid'"); |
141 |
while($row = $dsql->GetArray('me')) |
145 |
$addfile = $row['url']; |
149 |
$dsql->ExecuteNoneQuery("Delete From `dede_uploads` where aid = '$aid' "); |
151 |
$upfile = $cfg_basedir.$addfile; |
153 |
if(@file_exists($upfile)) @unlink($upfile); |
159 |
$dsql->ExecuteNoneQuery("Delete From `dede_arctiny` where id='$aid'"); |
165 |
$dsql->ExecuteNoneQuery("Delete From `$addtable` where aid='$aid' "); |
173 |
$dsql->ExecuteNoneQuery("Delete From `dede_archives` where id='$aid' "); |
177 |
$dsql->ExecuteNoneQuery("Delete From `dede_feedback` where aid='$aid' "); |
179 |
$dsql->ExecuteNoneQuery("Delete From `dede_member_stow` where aid='$aid' "); |
181 |
$dsql->ExecuteNoneQuery("Delete From `dede_taglist` where aid='$aid' "); |
183 |
$dsql->ExecuteNoneQuery("Delete From `dede_erradd` where aid='$aid' "); |
189 |
$filenameh = DEDEDATA."/textdata/".(ceil($aid/5000))."/{$aid}-".substr(md5($cfg_cookie_encode),0,16).".txt"; |
191 |
if(@is_file($filenameh)) @unlink($filenameh); |
195 |
if(empty($arcRow['money'])) $arcRow['money'] = 0; |
197 |
if(empty($arcRow['ismake'])) $arcRow['ismake'] = 1; |
199 |
if(empty($arcRow['arcrank'])) $arcRow['arcrank'] = 0; |
201 |
if(empty($arcRow['filename'])) $arcRow['filename'] = ''; |
205 |
if($arcRow['ismake']==-1 || $arcRow['arcrank']!=0 || $arcRow['typeid']==0 || $arcRow['money']>0) |
213 |
//强制转换非多站点模式,以便统一方式获得实际HTML文件 |
215 |
$GLOBALS['cfg_multi_site'] = 'N'; |
217 |
$arcurl = GetFileUrl($arcRow['aid'],$arcRow['typeid'],$arcRow['senddate'],$arcRow['title'],$arcRow['ismake'], |
219 |
$arcRow['arcrank'],$arcRow['namerule'],$arcRow['typedir'],$arcRow['money'],$arcRow['filename']); |
221 |
if(!ereg("\?", $arcurl)) |
225 |
$htmlfile = GetTruePath().str_replace($GLOBALS['cfg_basehost'],'',$arcurl); |
227 |
if(file_exists($htmlfile) && !is_dir($htmlfile)) |
233 |
$arcurls = explode(".", $htmlfile); |
235 |
$sname = $arcurls[count($arcurls)-1]; |
237 |
$fname = ereg_replace("(\.$sname)$", "", $htmlfile); |
239 |
for($i=2; $i<=100; $i++) |
243 |
$htmlfile = $fname."_{$i}.".$sname; |
245 |
if( @file_exists($htmlfile) ) @unlink($htmlfile); |
257 |
$willDelFiles = GetPicsTruePath($arcBodyRow['body'],$arcRow['litpic']); |
261 |
$executetime = MyDate('Y-m-d H:i:s',$nowtime);//获得执行时间 |
263 |
$msg = "\r\n文章标题:$arcRow[title]"; |
265 |
WriteToDelFiles($msg); |
267 |
if(!empty($willDelFiles)) |
271 |
foreach($willDelFiles as $file) |
275 |
if(file_exists($file) && !is_dir($file)) |
279 |
if(unlink($file)) $msg = "\r\n位置:$file\r\n结果:删除成功!\r\n时间:$executetime"; |
281 |
else $msg = "\r\n位置:$file\r\n结果:删除失败!\r\n时间:$executetime"; |
285 |
else $msg = "\r\n位置:$file\r\n结果:文件不存!\r\n时间:$executetime"; |
287 |
WriteToDelFiles($msg); |
297 |
$msg = "\r\n未在Body中解析到数据\r\nBody原始数据:$arcBodyRow[body]\r\n时间:$executetime"; |
299 |
WriteToDelFiles($msg); |
309 |
function GetTruePath($siterefer='', $sitepath='') |
313 |
$truepath = $GLOBALS['cfg_basedir']; |
|