summaryrefslogtreecommitdiff
path: root/program/include/main.inc
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2006-09-08 12:03:22 +0000
committerthomascube <thomas@roundcube.net>2006-09-08 12:03:22 +0000
commit70d4b9a5dc39a7165e469aa3b4f24d49e9a20b9e (patch)
treef3cfab469bbbe08879b7de7f221b316762ee082a /program/include/main.inc
parente170b4b7f85767703293116c95d9e02020b1c99a (diff)
Fixed safe_mode issues
Diffstat (limited to 'program/include/main.inc')
-rw-r--r--program/include/main.inc26
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);
+ }
}