网站运营的时间久了,图片和文章就会越来越多,然后服务器的容量就越来越少,花钱给服务器扩容,又是一笔不小的开支,一般我们的网站最占服务器资源的也就是图片了,当我们发布的文章水删除之后,图片却还在占着资源,所以缩减一下服务器的容量,是个不错的选择。
第一步、
找到后台路径中的 /templets/content_batch_up.htm
找到下面代码:
《input type='radio' value='delnulltitle' name='action' class='np' /》
删除空标题的文章
《input type='radio' value='delnullbody' name='action' class='np' /》
删除内容为空的文章
《input type='radio' value='modddpic' name='action' class='np' /》
更正缩图错误
修改成:
《input type='radio' value='delnulltitle' name='action' class='np' /》
删除空标题的文章
《input type='radio' value='delnullbody' name='action' class='np' /》
删除内容为空的文章
《input type='radio' value='modddpic' name='action' class='np' /》
更正缩图错误
《input class="np" type="radio" name="action" value="delerrpic" /》
清空错误的图片
找到
dede/content_batchup_action.php
在最后一个大括号后增加
else if($action == 'delerrpic')
{
$file_a=array();
function rFile($p){
global $file_a;
$handle=opendir($p);
$dir_a=array();
while ($file = readdir($handle)) {
if($file!="." && $file!=".."){
$tmp=$p."/".$file;
if(is_dir($tmp)){
$dir_a[count($dir_a)]=$tmp;
}elseif(is_file($tmp)){
$file_a[count($file_a)]=$tmp;
}
}
}
closedir($handle);
foreach($dir_a as $v){
rFile($v);
}
}
rFile("../uploads/allimg");//调用,要遍历的目录
foreach($file_a as $v){
$temp=substr($v,2);
$tempimg = $dsql->GetOne("SELECT * FROM #@__archives AS b ,#@__addonarticle AS a WHERE a.aid=b.id and (a.body like '%".$temp."%' OR b.litpic like '%".$temp."%'); ");
if(!is_array($tempimg)){
if(substr($v, -8, 4)!="_lit" && substr($v, -10, 5)!="index"){
if(file_exists($v)){
unlink($v);
}
}
}
}
$dsql->Close();
ShowMsg("成功清除错误图片!","");
exit();
}