In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you Dede delete document pictures of the method, I believe that most people do not know much, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!
How does Dede delete document pictures?
Dede deletes documents and deletes pictures in articles. This function is very important for friends who do photo sites, especially when deleting collected articles, it will produce a lot of useless pictures. This program does not guarantee 100% access to pictures in Body, but during this period of personal use, I did not find any problems.
First, create the "extend.func.php" file in the "/ include" directory. Then, save the following in the "extend.func.php" file with a total of three functions:
The code is as follows:
/ / parse the body data to get the absolute address function GetPicsTruePath ($body,$litpic) {$delfiles = array (); / / store the image address data if (! empty ($litpic)) {$litpicpath = GetTruePath (); $litpicpath. = $litpic; $delfiles [] = $litpicpath / / thumbnail address} preg_match_all ("/ src= [\" |'|\ S |\ s] ([^ title= "liehuo.net" |\ / >] *) {0,} (([^ >] *)\. (gif | jpg | png)) / isU ", $body,$tmpdata); $picspath = array_unique ($tmpdata [2]); / / address of all pictures in body foreach ($picspath as $tmppath) {$path = GetTruePath () / / get the absolute path $picpath = preg_replace ("/ [a-zA-z] +:\ /\ / [^ |\ /\ s] * /",'', $tmppath); / / remove the URL part $path. = $picpath; $delfiles [] = $path;// saved processed data} return $delfiles;} / / get the article Body data function GetArcBody ($aid) {global $dsql $query = "SELECT [url=mailto:dede_addonarticle.body] dede_ addonroomle.body[ / url] FROM [url=mailto:%60dede_addonarticle] `dede_ addonroomle`WHERE [url=mailto:dede_addonarticle.aid] dede_addonarti cle.aid [/ url] ='$aid'"; $row = $dsql- > GetOne ($query); if (is_array ($row) return $row; else return false } / / write the log file function WriteToDelFiles ($msg) / / when you delete the article, log {if (empty ($msg)) $savemsg= "no message"; else $savemsg= $msg; $errorFile = dirname (_ _ FILE__).'/.. / data/del_body_file.txt';// delete the record file $fp = @ fopen ($errorFile,'a'); @ fwrite ($fp, "\ r\ n {$savemsg}"); @ fclose ($fp);}
Next open the "/ dede/inc/inc_batchup.php" file.
1: add below line 33, that is, "$arcRow = $dsql- > GetOne ($arcQuery);" below:
$arcBodyRow = GetArcBody ($aid)
2: add below line 138, that is, above "return true;":
The code is as follows:
/ / parse the resources in the Body and delete $willDelFiles = GetPicsTruePath ($arcBodyRow ['body'], $arcRow [' litpic']); $nowtime = time (); $executetime = MyDate ('Y-m-d Hizug); / / get the execution time $msg = "\ r\ nArticle title: $arcRow [title]"; WriteToDelFiles ($msg) If (! empty ($willDelFiles)) {foreach ($willDelFiles as $file) {if (file_exists ($file) & &! is_dir ($file)) {if (unlink ($file)) $msg = "\ r\ nlocation: $file\ r\ nResult: deleted successfully! \ r\ ntime: $executetime "; else $msg ="\ r\ nlocation: $file\ r\ nResult: deletion failed! \ r\ ntime: $executetime ";} else $msg ="\ r\ nlocation: $file\ r\ nResult: file not saved! \ r\ ntime: $executetime "; WriteToDelFiles ($msg);} / / END foreach} else {$msg ="\ r\ nNo data was parsed in Body\ r\ nBody raw data: $arcBodyRows\ r\ ntime: $executetime "; WriteToDelFiles ($BodyRows);}
At this point, all modifications are completed, when deleting the article, the program will analyze the picture address in Body, and then delete. And in the / data/ directory, generate a log file: del_body_file.txt.
These are all the contents of Dede's method of deleting document pictures. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.