DEDE delete the article and delete the attachment to solve the code
/*
Obtain the body of a document based on the document id.
*/
Function getArcBody ($ arcid)
{
Global $ dsql;
If (empty ($ arcid) return;
$ Body = '';
$ Query = "select arc. *, ch. addtable, ch. fieldset from 'dede _ arctiny 'as arc left join 'dede _ channeltype' as ch on arc. channel = ch. id where arc. id = $ arcid ";
$ Row = $ dsql-> GetOne ($ query );
If (empty ($ row) return;
$ Addtable = $ row ['addtable'];
$ Fieldset = $ row ['fieldset'];
Include_once (DEDEINC. './dedetag. class. php Tutorial ');
$ Dtp = new DedeTagParse ();
$ Dtp-> SetNameSpace ('field', '<', '> ');
$ Dtp-> LoadSource ($ fieldset );
If (is_array ($ dtp-> CTags ))
{
Foreach ($ dtp-> CTags as $ tid => $ tag)
{
If ($ tag-> GetAtt ('type') = 'htmltext ')
{
$ Body = $ tag-> GetName ();
Break;
}
}
}
If (! Empty ($ body ))
{
$ Query = "select $ body from '$ addtable' where aid = $ arcid ";
$ Row = $ dsql-> GetOne ($ query );
$ Body = $ row [$ body];
Return $ body;
}
Return;
}
/*
Parse local image of document content
*/
Function get_img_from_body ($ body)
{
$ Result = array ();
If (empty ($ body ))
Return $ result;
Preg_match_all ('/ssrc = (["|']) ([^ 1] *?). (Gif | jpg | jpeg | png) 1/', $ body, $ res );
If (! Empty ($ res [2])
{
Foreach ($ res [2] as $ k => $ v)
{
$ Result [] = $ v. '.'. $ res [3] [$ k];
}
}
Return $ result;
}
Paste this code After include/common. func. php,
Next, open the dede/inc/inc_batchup.php file in the background (assuming the default dede is used as the background,
Add the following code to Line 1:
$ Body = getArcBody ($ aid );
Connect to the 139th rows, that is
Return true;
Add the following code DEDE technology to the above line-598080707.NET
If ($ body)
{
$ Img_arr = get_img_from_body ($ body );
If (! Empty ($ img_arr ))
{
Foreach ($ img_arr as $ v)
{
$ Img_file = GetTruePath (). str_replace ($ GLOBALS ['cfg _ basehost'], '', $ v );
If (file_exists ($ img_file )&&! Is_dir ($ img_file ))
@ Unlink ($ img_file );
}
}
}
In this way, you can delete the local image of the field "htmltext" type when deleting the document.