note 44662 deleted from function.filectime by betz
| From: | betz@php.net | Date: | Thu, 12 Aug 2004 14:21:15 +0000 |
| Subject: | note 44662 deleted from function.filectime by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74539@lists.php.net to get a copy of this message | ||
Note Submitter: hansjorg.morandell@brennercom.it
----
Ecco di sotto un piccolo dcript per cancellare file pi`u vecchi di xxx secondi...
Untenstehend ein kleines Script um Dateien in einem Ordner zu löschen, die älter als xxx sekunden
sind...
<?php
#########################################
# questo file dovrebbe cancellare
# immagini vecchie di piu di xxx secondi
# dalla directory ./my_cache
#
# @author Hansjoerg Morandell
#########################################
# directory
$dir2handle = opendir("./my_cache");
#data di adesso
$nowdate = date("U");
# per quanto temp si vuole tenere i file (in secondi)
$keeptime = 60*60*12;
# loop per cancellare i file vecchi
while ($datfile = readdir($dir2handle)) {
$dat_date = date("U", filectime("./my_cache/$datfile"));
# calcoliamo la differenza
$difftime = $nowdate - $keeptime;
if ($dat_date < $difftime) {
unlink("./my_cache/$datfile");
}
}
closedir($dir2handle);
?>