summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc26
-rw-r--r--program/include/session.inc6
2 files changed, 17 insertions, 15 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);
+ }
}
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;
}