From 70d4b9a5dc39a7165e469aa3b4f24d49e9a20b9e Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Fri, 08 Sep 2006 08:03:22 -0400 Subject: [PATCH] Fixed safe_mode issues --- 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 0d3cf82..c084588 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -823,19 +823,25 @@ } -// 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; + $tmp = unslashify($CONFIG['temp_dir']); + $expire = mktime() - 172800; // expire in 48 hours - $temp_dir = slashify($CONFIG['temp_dir']); - $cache_dir = $temp_dir.$sess_id; - - 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); + } } -- Gitblit v1.9.1