Fixed safe_mode issues

release-0.6
thomascube 18 years ago
parent e170b4b7f8
commit 70d4b9a5dc

@ -823,19 +823,25 @@ function rcube_add_label()
} }
// remove temp files of a session // remove temp files older than two day
function rcmail_clear_session_temp($sess_id) 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); while (($fname = readdir($dir)) !== false)
rmdir($cache_dir); {
} if ($fname{0} == '.')
continue;
if (filemtime($tmp.'/'.$fname) < $expire)
@unlink($tmp.'/'.$fname);
}
closedir($dir);
}
} }

@ -105,7 +105,6 @@ function sess_destroy($key)
WHERE sess_id=?", WHERE sess_id=?",
$key); $key);
rcmail_clear_session_temp($key);
return TRUE; return TRUE;
} }
@ -137,12 +136,9 @@ function sess_gc($maxlifetime)
WHERE sess_id IN ('".join("','", $a_exp_sessions)."')"); 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 // also run message cache GC
rcmail_message_cache_gc(); rcmail_message_cache_gc();
rcmail_temp_gc();
return TRUE; return TRUE;
} }

@ -497,9 +497,9 @@ function rcmail_create_draft_body($body)
function rcmail_write_compose_attachments(&$message) function rcmail_write_compose_attachments(&$message)
{ {
global $IMAP; global $IMAP, $CONFIG;
$temp_dir = rcmail_create_compose_tempdir(); $temp_dir = unslashify($CONFIG['temp_dir']);
if (!is_array($_SESSION['compose']['attachments'])) if (!is_array($_SESSION['compose']['attachments']))
$_SESSION['compose']['attachments'] = array(); $_SESSION['compose']['attachments'] = array();

@ -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 // clear message composing settings
function rcmail_compose_cleanup() function rcmail_compose_cleanup()
{ {
if (!isset($_SESSION['compose'])) if (!isset($_SESSION['compose']))
return; return;
// remove attachment files from temp dir // remove attachment files from temp dir
if (is_array($_SESSION['compose']['attachments'])) if (is_array($_SESSION['compose']['attachments']))
foreach ($_SESSION['compose']['attachments'] as $attachment) foreach ($_SESSION['compose']['attachments'] as $attachment)
@unlink($attachment['path']); @unlink($attachment['path']);
// kill temp dir
if ($_SESSION['compose']['temp_dir'])
@rmdir($_SESSION['compose']['temp_dir']);
unset($_SESSION['compose']); unset($_SESSION['compose']);
} }

@ -26,8 +26,8 @@ if (!$_SESSION['compose'])
} }
// create temp dir for file uploads // use common temp dir for file uploads
$temp_dir = rcmail_create_compose_tempdir(); $temp_dir = unslashify($CONFIG['temp_dir']);
if (!is_array($_SESSION['compose']['attachments'])) if (!is_array($_SESSION['compose']['attachments']))

Loading…
Cancel
Save