From 70d4b9a5dc39a7165e469aa3b4f24d49e9a20b9e Mon Sep 17 00:00:00 2001 From: thomascube Date: Fri, 8 Sep 2006 12:03:22 +0000 Subject: Fixed safe_mode issues --- program/include/main.inc | 26 ++++++++++++++++---------- program/include/session.inc | 6 +----- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'program/include') 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); + } } diff --git a/program/include/session.inc b/program/include/session.inc index dc7714777..6c4687e68 100644 --- a/program/include/session.inc +++ b/program/include/session.inc @@ -105,7 +105,6 @@ function sess_destroy($key) WHERE sess_id=?", $key); - rcmail_clear_session_temp($key); return TRUE; } @@ -137,12 +136,9 @@ function sess_gc($maxlifetime) WHERE sess_id IN ('".join("','", $a_exp_sessions)."')"); } - // remove session specific temp dirs - foreach ($a_exp_sessions as $key) - rcmail_clear_session_temp($key); - // also run message cache GC rcmail_message_cache_gc(); + rcmail_temp_gc(); return TRUE; } -- cgit v1.2.3