织梦删除dedecms中遗留的多余图片
打开dede/templets/content_batch_up2.htm找到下面代码:
<input class="np" type="radio" checked="checked" name="action" value="modddpic" /><br /> 更正缩图错误<br /> <input class="np" type="radio" name="action" value="delerrdata" /><br /> 清空错误的文档数据</td>
修改成:
<input class="np" type="radio" checked="checked" name="action" value="modddpic" /><br /> 更正缩图错误<br /> <input class="np" type="radio" name="action" value="delerrdata" /><br /> 清空错误的文档数据<br /> <input class="np" type="radio" name="action" value="delerrpic" /><br /> 清空错误的图片</td>
打开dede/content_batchup_action2.php
在最后一个大括号后增加
elseif($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); $query = "select count(*) from dede_addonarticle where body like '%".$temp."%'"; $dsql->setquery($query); $dsql->execute(); while($row = $dsql->getarray()) { if($row[0]==0){ if(substr($v, -8, 4)!="_lit" && substr($v, -10, 5)!="index"){ if(file_exists($v)) unlink($v); } } } } $dsql->Close(); ShowMsg("成功清除错误图片!","javascript:;"); exit(); }
本文网址:https://www.dedexuexi.com/dedejiaocheng/eckf/3371.html
本站部分文章搜集与网络,如有侵权请联系本站,转载请说明出处。