DEDE delete the article and delete the attachment to solve the code

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.