Check whether the code is correct and delete the data and files a month ago. Solution

Source: Internet
Author: User
Check whether the code is correct and delete the data and files a month ago. In theory, the code is correct, but for fear ...... It's not fun to delete files or data wrong ...... Experts, can you tell me whether the following code is correct? PHPcoderequire (dirname (_ FILE __). & quot ;.. conn. php & quot;); mysql_select_db (& quot; news & quot;, $ co helps you check whether the code is correct and delete data and files from a month ago.
In theory, the code is correct, but for fear ......
It's not fun to delete files or data wrong ......
Experts, can you tell me whether the following code is correct?

PHP code
  require (dirname(__FILE__) . "/../conn.php");mysql_select_db("news",$conn_database);mysql_query("delete from web_news where news_date<(date(now())-60*60*24*30)");mysql_close($conn_database);if ($handle = opendir(dirname(__FILE__).'/../cache/')) {  while (false !== ($file = readdir($handle))) {      if ((time()-filectime(dirname(__FILE__).'/../cache/'.$file)) < 60*60*24*30) {         if (strripos($file, '.html') !== false) {          unlink(dirname(__FILE__).'/../cache/'.$file);        }      }  }}


------ Solution --------------------
Filectime
Should be changed
Filemtime

You can comment out unlink (dirname (_ FILE _). '/../cache/'. $ file );
Change
$ Fn = dirname (_ FILE _). '/../cache/'. $ file;
Echo $ fn. '-'. filemtime ($ fn );
Check it first
------ Solution --------------------
Ignored. do not pay attention to the database
(Date (now ()-60*60*24*30)
Change
DATE_SUB (now (), INTERVAL 30 DAY)

Select again.

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.