织梦DEDE删除没被调用的图片

网站运营的时间久了,图片和文章就会越来越多,然后服务器的容量就越来越少,花钱给服务器扩容,又是一笔不小的开支,一般我们的网站最占服务器资源的也就是图片了,当我们发布的文章水删除之后,图片却还在占着资源,所以缩减一下服务器的容量,是个不错的选择。

织梦DEDE删除没被调用的图片

 

 

第一步、
找到后台路径中的 /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();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

永远的WEB小白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值