[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /** 3 * ClickHeat : Fonctions diverses / Various functions 4 * 5 * @author Yvan Taviaud - LabsMedia - www.labsmedia.com 6 * @since 01/04/2007 7 **/ 8 9 /** Direct call forbidden */ 10 if (!defined('CLICKHEAT_LANGUAGE')) 11 { 12 exit; 13 } 14 15 if (CLICKHEAT_ADMIN === false) 16 { 17 return false; 18 } 19 $deletedFiles = 0; 20 $deletedDirs = 0; 21 /** 22 * Clean the logs' directory according to configuration data 23 **/ 24 if ($clickheatConf['flush'] !== 0 && is_dir($clickheatConf['logPath']) === true) 25 { 26 $logDir = dir($clickheatConf['logPath'].'/'); 27 while (($dir = $logDir->read()) !== false) 28 { 29 if ($dir === '.' || $dir === '..' || !is_dir($logDir->path.$dir)) 30 { 31 continue; 32 } 33 34 $d = dir($logDir->path.$dir.'/'); 35 $deletedAll = true; 36 $oldestDate = mktime(0, 0, 0, date('m'), date('d') - $clickheatConf['flush'], date('Y')); 37 while (($file = $d->read()) !== false) 38 { 39 if ($file === '.' || $file === '..' || $file === 'url.txt') 40 { 41 continue; 42 } 43 $ext = explode('.', $file); 44 if (count($ext) !== 2) 45 { 46 $deletedAll = false; 47 continue; 48 } 49 $filemtime = filemtime($d->path.$file); 50 if ($ext[1] === 'log' && $filemtime <= $oldestDate) 51 { 52 @unlink($d->path.$file); 53 $deletedFiles++; 54 continue; 55 } 56 $deletedAll = false; 57 } 58 /** If every log file (but the url.txt) has been deleted, then we should delete the directory too */ 59 if ($deletedAll === true) 60 { 61 @unlink($d->path.'/url.txt'); 62 $deletedFiles++; 63 @rmdir($d->path); 64 $deletedDirs++; 65 } 66 $d->close(); 67 } 68 $logDir->close(); 69 } 70 71 /** 72 * Clean the cache directory for every file older than 2 minutes 73 **/ 74 if (is_dir($clickheatConf['cachePath']) === true) 75 { 76 $d = dir($clickheatConf['cachePath'].'/'); 77 while (($file = $d->read()) !== false) 78 { 79 if ($file === '.' || $file === '..') 80 { 81 continue; 82 } 83 $ext = explode('.', $file); 84 if (count($ext) !== 2) 85 { 86 continue; 87 } 88 $filemtime = filemtime($d->path.$file); 89 switch ($ext[1]) 90 { 91 case 'html': 92 case 'png': 93 case 'png_temp': 94 case 'png_log': 95 { 96 if ($filemtime + 86400 < time()) 97 { 98 @unlink($d->path.$file); 99 $deletedFiles++; 100 continue; 101 } 102 break; 103 } 104 } 105 } 106 $d->close(); 107 } 108 109 if ($deletedDirs + $deletedFiles === 0) 110 { 111 echo 'OK'; 112 return true; 113 } 114 echo sprintf(LANG_CLEANER_RUN, $deletedFiles, $deletedDirs); 115 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |