但
织梦本身是不支持的,需要经过小的
二次开发才可以,下面
织梦58符老师教你们怎么做,经过测试可以用的,
第一步找到
/include/extend.func.php
复制以下的全部
代码直接覆盖 到 extend.func.php
文件
003 |
function GetPicsTruePath($body,$litpic) //解析body数据,获得所有图片的绝对地址 |
007 |
$delfiles = array();//存储图片地址数据 |
013 |
$litpicpath = GetTruePath(); |
015 |
$litpicpath .= $litpic; |
017 |
$delfiles[] = $litpicpath;//缩略图地址 |
021 |
preg_match_all( "/src=[\"|'|\S|\s]([^ |\/|>]*){0,}(([^>]*)\.(gif|jpg|png))/isU" ,$body,$tmpdata); |
023 |
$picspath = array_unique($tmpdata[2]);//body中所有图片的地址 |
025 |
foreach($picspath as $tmppath) |
029 |
$path = GetTruePath();//获得绝对路径 |
031 |
$picpath = preg_replace( "/[a-zA-z]+:\/\/[^ |\/|\s]*/" , '' ,$tmppath);//去掉网址部分 |
035 |
$delfiles[] = $path;//保存处理后的数据 |
043 |
function WriteToDelFiles($msg)//删除文章的时候会通过此函数记录日志 |
047 |
if (empty($msg)) $savemsg= "未获得消息" ; |
049 |
else $savemsg = $msg; |
051 |
$errorFile = dirname (__FILE__). '/../data/del_body_file.txt' ;//删除记录文件 |
053 |
$fp = @fopen($errorFile, 'a' ); |
055 |
@fwrite($fp, "\r\n{$savemsg}" ); |
063 |
function GetArcBody($aid) |
069 |
$query = "SELECT dede_addonarticle.body FROM dede_addonarticle WHERE dede_addonarticle.aid = '$aid'" ; |
071 |
$row = $dsql->GetOne($query); |
073 |
if (is_array($row)) return $row; |
079 |
function litimgurls($imgid=0){ |
083 |
$dsql = new DedeSql( false ); |
087 |
$row = $dsql->GetOne( "SELECT c.addtable FROM dede_archives AS a LEFT JOIN dede_channeltype AS c ON a.channel=c.id where a.id='$imgid'" ); |
089 |
$addtable = trim($row[ 'addtable' ]); |
091 |
//获取图片附加表imgurls字段内容进行处理 |
093 |
$row = $dsql->GetOne( "Select imgurls From `$addtable` where aid='$imgid'" ); |
095 |
//调用inc_channel_unit.php中ChannelUnit类 |
097 |
$ChannelUnit = new ChannelUnit(2,$imgid); |
099 |
//调用ChannelUnit类中GetlitImgLinks方法处理缩略图 |
101 |
$lit_imglist = $ChannelUnit->GetlitImgLinks($row[ 'imgurls' ]); |
|
第二步 找到
\dede\inc\inc_batchup.php
复制以下的全部
代码直接覆盖 到 inc_batchup.php 文件
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; |
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) |
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' ]; |
|
到这里就结束了 ,很简单吧, 我们再去试着删除一篇文章 ,你会发现你删除这篇文章以后,这篇文章的缩列图和
内容上的图片都同时删除了!