德德如何删除文档图片?
Dede删除文章中的文档和图片。这个功能对于做图片网站的朋友来说非常重要,尤其是在删除收藏文章的时候,会产生大量无用的图片。这个程序并不能保证100%得到正文中的图片,但是在我个人使用过程中,并没有发现任何问题。
推荐学习:梦想编织cms
首先,在quot/include quot;创建quot目录下;extend . func . PHP quot;文件。然后,将以下内容保存在quotextend . func . PHP quot;文件,共有三个功能:
代码如下:
//解析正文数据,得到所有图片的绝对地址。
函数GetPicsTruePath($body,$litpic)
{
$ del files = array();//存储图片地址数据
如果(!空($litpic))
{
$ litpicpath = GetTruePath();
$litpicpath。= $ litpic
$ del files[]= $ litpicpath;//缩略图地址
}
preg _ match _ all(quot;/src =[\\ quot;|#39;|\\s|\\s]([^ title = quot;liehuo.netquot| \\/| gt;]*){0,}(([^gt;]*)\\.(gif | jpg | png))/ISU quot;,$body,$ tmpdata);
$ pics path = array _ unique($ tmpdata[2]);//正文中所有图片的地址
foreach($picspath as $tmppath)
{
$ path = GetTruePath();//获取绝对路径
$ picpath = preg _ replace(quot;/[a-za-z]+:\\/\\/[^ | \\/| \\ s]*/quot;,#39;#39;,$ tmppath);//删除URL部分
$path。= $ picpath
$ del files[]= $ path;//保存处理后的数据。
}
返回$ delfiles
}
//获取文章的正文数据
函数GetArcBody($aid)
{
全球$ dsql
$ query = quotSELECT[URL = mailto:dede _ addon article . body]dede _ addon article . body[/URL]FROM[URL = mailto:% 60 dede _ addon article]` dede _ addon article[/URL]`其中[URL = mailto:dede _ addon article . aid]dede _ addon article . aid[/URL]= # 39;$ aid # 39quot;
$ row = $ dsql -gt;GetOne($ query);
if(is_array($row))
返回$ row
其他
返回false
}
//写入日志文件
函数writedelfiles ($ msg)//Log在删除文章时会被这个函数记录下来。
{
if(empty($ msg))$ save msg = quot;消息quot未获得;;
else $ savemsg = $ msg
$errorFile = dirname(__FILE__)。#39;/../data/del _ body _ file . txt # 39;;//删除日志文件
$fp = @fopen($errorFile,# 39;a # 39);
@fwrite($fp,quot\\ r \\ n { $ savemsg } quot);
@ fclose($ FP);
}登录后复制
