-
網(wǎng)站模板資源下載類網(wǎng)站...
-
電腦系統(tǒng)軟件下載類網(wǎng)站...
-
蔬菜鮮果配送類網(wǎng)站織夢...
-
裝飾建材公司類網(wǎng)站織夢...
-
展覽展會信息類網(wǎng)站織夢...
-
物流快運速遞類網(wǎng)站織夢...
-
貂絨大衣服裝設(shè)計類網(wǎng)站...
-
鋼結(jié)構(gòu)崗?fù)I銷型織夢網(wǎng)...
-
精工機械軸承生產(chǎn)廠家類...
-
水利工程施工類網(wǎng)站織夢...
-
手游APP軟件下載類網(wǎng)站織...
-
電子元件電路板類網(wǎng)站織...
-
中英雙語律師事務(wù)所類網(wǎng)...
-
食品百貨英文外貿(mào)類網(wǎng)站...
-
人力資源管理類網(wǎng)站織夢...
-
儀器分析儀類網(wǎng)站織夢模...
-
儀器儀表科技公司類網(wǎng)站...
-
玩具動漫類網(wǎng)站織夢模板...
-
營銷型無縫鋼管定制生產(chǎn)...
-
財稅記賬工商注冊認(rèn)證類...
在用織夢建站的時候,我們時常會刪除一些文章或者上傳一些沒用的圖片,但是有個問題,就是刪除文章的同時,文章內(nèi)的圖片還保存在網(wǎng)站空間中,占用了服務(wù)器資源。我曾經(jīng)就有過一次,無用的圖片達(dá)到八百多MB,要是手動去刪,何年何月啊。
一般來說有二種情況,我們分別來操作:
- 1、刪除文章的同時,刪除該文章內(nèi)的圖片,
打開dede/inc/inc_batchup.php
找到
"//刪除數(shù)據(jù)庫的內(nèi)容"
在這前面加上
//刪除縮略圖if($arcRow['litpic']!=""){$dsql->ExecuteNoneQuery("Delete From dede_uploads where url='$arcRow[litpic]'");$truedir = GetTruePath($arcRow['siterefer'],$arcRow['sitepath']);$litpicfile = $truedir.$arcRow['litpic'];@unlink($litpicfile);}//刪除大圖$arcbodyQuery = "Select * from ".$arcRow['addtable']." where aid='$aid'";$arcbodyRow = $dsql->GetOne($arcbodyQuery);$imgsrcarray=GetImageSrc($arcbodyRow['body']);foreach ($imgsrcarray as $v) {if((trim($v)!="")&&(!eregi("^http://",$v))){$dsql->ExecuteNoneQuery("Delete From dede_uploads where url='$v'");$picfile = $truedir.$v;@unlink($picfile);}}//刪除數(shù)據(jù)庫的內(nèi)容
再找到
Select dede_archives.ID,dede_archives.title,dede_archives.typeid
改成
Select dede_archives.ID,dede_archives.title,dede_archives.typeid,dede_archives.litpic
在文件最后加上一函數(shù)
//獲得內(nèi)容中的圖像地址function GetImageSrc($body){if( !isset($body)) return '';else{preg_match_all ("/<(img|IMG)(.*)(src|SRC)=[\"|'|]{0,}([h|\/].*(jpg|JPG|gif|GIF))[\"|'|\s]{0,}/isU",$body,$out);return $out[4];}}
- 2、那就是很早之前刪除了很多文章,當(dāng)時并沒有完成第一種情況時的修改, 意思就是明知道空間中有多余的圖片。
找到后臺路徑中的
dede/templets/content_batch_up.htm
找到下面代碼:
<inputclass="np"type="radio"checked="checked"name="action"value="modddpic"/><br />更正縮圖錯誤<br /><inputclass="np"type="radio"name="action"value="delerrdata"/><br />清空錯誤的文檔數(shù)據(jù)</td>
改成
<inputclass="np"type="radio"checked="checked"name="action"value="modddpic"/><br />更正縮圖錯誤<br /> <inputclass="np"type="radio"name="action"value="delerrdata"/><br />清空錯誤的文檔數(shù)據(jù)<br /> <inputclass="np"type="radio"name="action"value="delerrpic"/><br />清空錯誤的圖片</td>
找到
dede/content_batchup_actionphp
在最底部加入下面代碼
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");//調(diào)用,要遍歷的目錄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();}