diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/include/main.inc | 26 | ||||
-rw-r--r-- | program/include/session.inc | 6 | ||||
-rw-r--r-- | program/steps/mail/compose.inc | 6 | ||||
-rw-r--r-- | program/steps/mail/func.inc | 28 | ||||
-rw-r--r-- | program/steps/mail/upload.inc | 4 |
5 files changed, 23 insertions, 47 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; } diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 14adb1266..29fdddd06 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -497,9 +497,9 @@ function rcmail_create_draft_body($body) function rcmail_write_compose_attachments(&$message) { - global $IMAP; - - $temp_dir = rcmail_create_compose_tempdir(); + global $IMAP, $CONFIG; + + $temp_dir = unslashify($CONFIG['temp_dir']); if (!is_array($_SESSION['compose']['attachments'])) $_SESSION['compose']['attachments'] = array(); diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index 827f13100..b51ec4b80 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -1384,42 +1384,16 @@ function rcmail_message_part_frame($attrib) } -// create temp dir for attachments -function rcmail_create_compose_tempdir() - { - global $CONFIG; - - if ($_SESSION['compose']['temp_dir']) - return $_SESSION['compose']['temp_dir']; - - if (!empty($CONFIG['temp_dir'])) - $temp_dir = $CONFIG['temp_dir'].(!eregi('\/$', $CONFIG['temp_dir']) ? '/' : '').$_SESSION['compose']['id']; - - // create temp-dir for uploaded attachments - if (!empty($CONFIG['temp_dir']) && is_writeable($CONFIG['temp_dir'])) - { - mkdir($temp_dir); - $_SESSION['compose']['temp_dir'] = $temp_dir; - } - - return $_SESSION['compose']['temp_dir']; - } - - // clear message composing settings function rcmail_compose_cleanup() { if (!isset($_SESSION['compose'])) return; - + // remove attachment files from temp dir if (is_array($_SESSION['compose']['attachments'])) foreach ($_SESSION['compose']['attachments'] as $attachment) @unlink($attachment['path']); - - // kill temp dir - if ($_SESSION['compose']['temp_dir']) - @rmdir($_SESSION['compose']['temp_dir']); unset($_SESSION['compose']); } diff --git a/program/steps/mail/upload.inc b/program/steps/mail/upload.inc index 850ccd01d..cde4ed2d4 100644 --- a/program/steps/mail/upload.inc +++ b/program/steps/mail/upload.inc @@ -26,8 +26,8 @@ if (!$_SESSION['compose']) } -// create temp dir for file uploads -$temp_dir = rcmail_create_compose_tempdir(); +// use common temp dir for file uploads +$temp_dir = unslashify($CONFIG['temp_dir']); if (!is_array($_SESSION['compose']['attachments'])) |