alecpl
2011-05-05 d08333ea578e3b6c6ab42bed05f808a2b7b93cf1
program/include/main.inc
@@ -26,11 +26,8 @@
 * @author Thomas Bruederli <roundcube@gmail.com>
 */
require_once('lib/utf7.inc');
require_once('include/rcube_shared.inc');
// fallback if not PHP modules are available
@include_once('lib/utf8.class.php');
require_once 'utf7.inc';
require_once INSTALL_PATH . 'program/include/rcube_shared.inc';
// define constannts for input reading
define('RCUBE_INPUT_GET', 0x0101);
@@ -290,7 +287,7 @@
    }
    $error = true;
  }
  // encode string for output
  if ($from == 'UTF-8') {
    // @TODO: we need a function for UTF-7 (RFC2152) conversion
@@ -312,7 +309,7 @@
    }
    $error = true;
  }
  // report error
  if ($error && !$convert_warning) {
    raise_error(array(
@@ -322,10 +319,10 @@
      'line' => __LINE__,
      'message' => "Could not convert string from $from to $to. Make sure iconv/mbstring is installed or lib/utf8.class is available."
      ), true, false);
    $convert_warning = true;
  }
  // return UTF-8 or original string
  return $str;
  }
@@ -1231,17 +1228,20 @@
  else
    $list = $RCMAIL->imap->list_mailboxes();
  foreach ($list as $folder)
  $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
  foreach ($list as $folder) {
    if (empty($p['exceptions']) || !in_array($folder, $p['exceptions']))
      rcmail_build_folder_tree($a_mailboxes, $folder, $RCMAIL->imap->get_hierarchy_delimiter());
      rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
  }
  $select = new html_select($p);
  if ($p['noselection'])
    $select->add($p['noselection'], '');
  rcmail_render_folder_tree_select($a_mailboxes, $mbox, $p['maxlength'], $select, $p['realnames']);
  return $select;
}
@@ -1254,6 +1254,17 @@
function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='')
{
  global $RCMAIL;
  // Handle namespace prefix
  $prefix = '';
  if (!$path) {
    $n_folder = $folder;
    $folder = $RCMAIL->imap->mod_mailbox($folder);
    if ($n_folder != $folder) {
      $prefix = substr($n_folder, 0, -strlen($folder));
    }
  }
  $pos = strpos($folder, $delm);
@@ -1275,14 +1286,14 @@
    $virtual = false;
  }
  $path .= $currentFolder;
  // Check \Noselect option (if options are in cache)
  if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) {
    $virtual = in_array('\\Noselect', $opts);
  }
  $path .= $prefix.$currentFolder;
  if (!isset($arrFolders[$currentFolder])) {
    // Check \Noselect option (if options are in cache)
    if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) {
      $virtual = in_array('\\Noselect', $opts);
    }
    $arrFolders[$currentFolder] = array(
      'id' => $path,
      'name' => rcube_charset_convert($currentFolder, 'UTF7-IMAP'),
@@ -1676,14 +1687,20 @@
{
  // %n - host
  $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
  // %d - domain name without first part, e.g. %d=mail.domain.tld, %m=domain.tld
  // %d - domain name without first part, e.g. %n=mail.domain.tld, %d=domain.tld
  $d = preg_replace('/^[^\.]+\./', '', $n);
  // %h - IMAP host
  $h = $_SESSION['imap_host'] ? $_SESSION['imap_host'] : $host;
  // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
  $z = preg_replace('/^[^\.]+\./', '', $h);
  // %s - domain name after the '@' from e-mail address provided at login screen. Returns FALSE if an invalid email is provided
  if ( strpos($name, '%s') !== false ){
    $user_email = rcube_idn_convert(get_input_value('_user', RCUBE_INPUT_POST), true);
    if ( preg_match('/(.*)@([a-z0-9\.\-\[\]\:]+)/i', $user_email, $s) < 1 || filter_var($s[1]."@".$s[2], FILTER_VALIDATE_EMAIL) === false )
      return false;
  }
  $name = str_replace(array('%n', '%d', '%h', '%z'), array($n, $d, $h, $z), $name);
  $name = str_replace(array('%n', '%d', '%h', '%z', '%s'), array($n, $d, $h, $z, $s[2]), $name);
  return $name;
}
@@ -1975,14 +1992,14 @@
function rcube_print_time($timer, $label='Timer', $dest='console')
{
  static $print_count = 0;
  $print_count++;
  $now = rcube_timer();
  $diff = $now-$timer;
  if (empty($label))
    $label = 'Timer '.$print_count;
  write_log($dest, sprintf("%s: %0.4f sec", $label, $diff));
}
@@ -2013,7 +2030,7 @@
    if ($terminate) {
        $ERROR_CODE = $arg['code'];
        $ERROR_MESSAGE = $arg['message'];
        include('program/steps/utils/error.inc');
        include INSTALL_PATH . 'program/steps/utils/error.inc';
        exit;
    }
}