thomascube
2006-09-08 70d4b9a5dc39a7165e469aa3b4f24d49e9a20b9e
Fixed safe_mode issues

5 files modified
70 ■■■■■ changed files
program/include/main.inc 26 ●●●●● patch | view | raw | blame | history
program/include/session.inc 6 ●●●● patch | view | raw | blame | history
program/steps/mail/compose.inc 6 ●●●● patch | view | raw | blame | history
program/steps/mail/func.inc 28 ●●●●● patch | view | raw | blame | history
program/steps/mail/upload.inc 4 ●●●● patch | view | raw | blame | history
program/include/main.inc
@@ -823,19 +823,25 @@
  }
// 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;
  $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);
    rmdir($cache_dir);
    }
    while (($fname = readdir($dir)) !== false)
      {
      if ($fname{0} == '.')
        continue;
      if (filemtime($tmp.'/'.$fname) < $expire)
        @unlink($tmp.'/'.$fname);
      }
    closedir($dir);
    }
  }
program/include/session.inc
@@ -105,7 +105,6 @@
              WHERE sess_id=?",
              $key);
  rcmail_clear_session_temp($key);
  return TRUE;
  }
@@ -137,12 +136,9 @@
                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;
  }
program/steps/mail/compose.inc
@@ -497,9 +497,9 @@
  
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();
program/steps/mail/func.inc
@@ -1384,42 +1384,16 @@
  }
// 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']);
  }
program/steps/mail/upload.inc
@@ -26,8 +26,8 @@
  }
// 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']))