diff options
Diffstat (limited to 'program/include/main.inc')
-rw-r--r-- | program/include/main.inc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/program/include/main.inc b/program/include/main.inc index 0d3cf82bb..c084588cf 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -823,19 +823,25 @@ function rcube_add_label() } -// remove temp files of a session -function rcmail_clear_session_temp($sess_id) +// remove temp files older than two day +function rcmail_temp_gc() { - global $CONFIG; - - $temp_dir = slashify($CONFIG['temp_dir']); - $cache_dir = $temp_dir.$sess_id; + $tmp = unslashify($CONFIG['temp_dir']); + $expire = mktime() - 172800; // expire in 48 hours - if (is_dir($cache_dir)) + if ($dir = opendir($tmp)) { - clear_directory($cache_dir); - rmdir($cache_dir); - } + while (($fname = readdir($dir)) !== false) + { + if ($fname{0} == '.') + continue; + + if (filemtime($tmp.'/'.$fname) < $expire) + @unlink($tmp.'/'.$fname); + } + + closedir($dir); + } } |