帮忙看下代码是否正确,删除一个月前的数据和文件。
理论上代码是正确的,但是怕个万一……
文件、数据删错了就不好玩了……
高手们,帮忙看下下面的代码正确与否?
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
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);
}
}
}
}
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号