alecpl
2010-10-29 7bdd3e22b56b17df7f15d2179f7918c9a5d15da1
program/include/main.inc
@@ -4,8 +4,8 @@
 +-----------------------------------------------------------------------+
 | program/include/main.inc                                              |
 |                                                                       |
 | This file is part of the RoundCube Webmail client                     |
 | Copyright (C) 2005-2009, RoundCube Dev, - Switzerland                 |
 | This file is part of the Roundcube Webmail client                     |
 | Copyright (C) 2005-2009, Roundcube Dev, - Switzerland                 |
 | Licensed under the GNU GPL                                            |
 |                                                                       |
 | PURPOSE:                                                              |
@@ -20,7 +20,7 @@
*/
/**
 * RoundCube Webmail common functions
 * Roundcube Webmail common functions
 *
 * @package Core
 * @author Thomas Bruederli <roundcube@gmail.com>
@@ -151,6 +151,7 @@
/**
 * Garbage collector for cache entries.
 * Remove all expired message cache records
 * @return void
 */
function rcmail_cache_gc()
  {
@@ -187,7 +188,7 @@
 * @param  string Input string
 * @param  string Suspected charset of the input string
 * @param  string Target charset to convert to; defaults to RCMAIL_CHARSET
 * @return Converted string
 * @return string Converted string
 */
function rcube_charset_convert($str, $from, $to=NULL)
  {
@@ -322,8 +323,8 @@
 * Sometimes charset string is malformed, there are also charset aliases 
 * but we need strict names for charset conversion (specially utf8 class)
 *
 * @param  string  Input charset name
 * @return The validated charset name
 * @param  string Input charset name
 * @return string The validated charset name
 */
function rcube_parse_charset($input)
  {
@@ -357,15 +358,23 @@
    'ISO88599'       => 'WINDOWS-1254',
    'ISO885911'       => 'WINDOWS-874',
    'MACROMAN'       => 'MACINTOSH',
    '238'           => 'WINDOWS-1250',
    '178'           => 'WINDOWS-1256',
    '177'           => 'WINDOWS-1255',
    '204'           => 'WINDOWS-1251',
    '161'           => 'WINDOWS-1253',
    '222'           => 'WINDOWS-874',
    '77'            => 'MAC',
    '128'           => 'SHIFT-JIS',
    '129'           => 'CP949',
    '130'           => 'CP1361',
    '134'           => 'GBK',
    '136'           => 'BIG5',
    '161'           => 'WINDOWS-1253',
    '162'           => 'WINDOWS-1254',
    '163'           => 'WINDOWS-1258',
    '177'           => 'WINDOWS-1255',
    '178'           => 'WINDOWS-1256',
    '186'           => 'WINDOWS-1257',
    '204'           => 'WINDOWS-1251',
    '222'           => 'WINDOWS-874',
    '238'           => 'WINDOWS-1250',
    '128'           => 'SHIFT-JIS'
    'MS950'         => 'CP950',
    'WINDOWS949'    => 'UHC',
  );
  // allow A-Z and 0-9 only
@@ -421,7 +430,7 @@
 * Converts string from standard UTF-7 (RFC 2152) to UTF-8.
 *
 * @param  string  Input string
 * @return The converted string
 * @return string  The converted string
 */
function rcube_utf7_to_utf8($str)
{
@@ -480,7 +489,7 @@
 * Converts string from UTF-16 to UTF-8 (helper for utf-7 to utf-8 conversion)
 *
 * @param  string  Input string
 * @return The converted string
 * @return string  The converted string
 */
function rcube_utf16_to_utf8($str)
{
@@ -511,7 +520,7 @@
 * @param  string  Encoding type: text|html|xml|js|url
 * @param  string  Replace mode for tags: show|replace|remove
 * @param  boolean Convert newlines
 * @return The quoted string
 * @return string  The quoted string
 */
function rep_specialchars_output($str, $enctype='', $mode='', $newlines=TRUE)
  {
@@ -1081,6 +1090,7 @@
 * Print or write debug messages
 *
 * @param mixed Debug message or data
 * @return void
 */
function console()
  {
@@ -1115,6 +1125,7 @@
 *
 * @param $name name of log file
 * @param line Line to append
 * @return void
 */
function write_log($name, $line)
  {
@@ -1167,6 +1178,8 @@
/**
 * Write login data (name, ID, IP address) to the 'userlogins' log file.
 *
 * @return void
 */
function rcmail_log_login()
{
@@ -1195,6 +1208,7 @@
/**
 * @access private
 * @return mixed
 */
function rcube_timer()
{
@@ -1204,6 +1218,7 @@
/**
 * @access private
 * @return void
 */
function rcube_print_time($timer, $label='Timer', $dest='console')
{
@@ -1255,7 +1270,7 @@
    foreach ($a_folders as $folder)
      rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
  }
  // allow plugins to alter the folder tree or to localize folder names
  $hook = $RCMAIL->plugins->exec_hook('render_mailboxlist', array('list' => $a_mailboxes, 'delimiter' => $delimiter));
@@ -1286,7 +1301,7 @@
 * Return the mailboxlist as html_select object
 *
 * @param array Named parameters
 * @return object html_select HTML drop-down object
 * @return html_select HTML drop-down object
 */
function rcmail_mailbox_select($p = array())
{
@@ -1313,14 +1328,25 @@
/**
 * Create a hierarchical array of the mailbox list
 * @access private
 * @return void
 */
function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='')
{
  global $RCMAIL;
  $pos = strpos($folder, $delm);
  if ($pos !== false) {
    $subFolders = substr($folder, $pos+1);
    $currentFolder = substr($folder, 0, $pos);
    $virtual = !isset($arrFolders[$currentFolder]);
    // sometimes folder has a delimiter as the last character
    if (empty($subFolders))
      $virtual = false;
    else if (!isset($arrFolders[$currentFolder]))
      $virtual = true;
    else
      $virtual = $arrFolders[$currentFolder]['virtual'];
  }
  else {
    $subFolders = false;
@@ -1329,6 +1355,11 @@
  }
  $path .= $currentFolder;
  // Check \Noselect option (if options are in cache)
  if (!$virtual && ($opts = $RCMAIL->imap->mailbox_options($path))) {
    $virtual = in_array('\\Noselect', $opts);
  }
  if (!isset($arrFolders[$currentFolder])) {
    $arrFolders[$currentFolder] = array(
@@ -1348,6 +1379,7 @@
/**
 * Return html for a structured list &lt;ul&gt; for the mailbox tree
 * @access private
 * @return string
 */
function rcmail_render_folder_tree_html(&$arrFolders, &$mbox_name, &$jslist, $attrib, $nestLevel=0)
{
@@ -1446,6 +1478,7 @@
/**
 * Return html for a flat list <select> for the mailbox tree
 * @access private
 * @return string
 */
function rcmail_render_folder_tree_select(&$arrFolders, &$mbox_name, $maxlength, &$select, $realnames=false, $nestLevel=0)
  {
@@ -1479,6 +1512,7 @@
/**
 * Return internal name for the given folder if it matches the configured special folders
 * @access private
 * @return string
 */
function rcmail_folder_classname($folder_id)
{
@@ -1516,6 +1550,7 @@
 * Output HTML editor scripts
 *
 * @param string Editor mode
 * @return void
 */
function rcube_html_editor($mode='')
{
@@ -1546,6 +1581,7 @@
 *
 * @param integer HTTPS port number
 * @param boolean Enables 'use_https' option checking
 * @return boolean
 */
function rcube_https_check($port=null, $use_https=true)
{
@@ -1564,7 +1600,13 @@
}
// for backward compatibility
/**
 * For backward compatibility.
 *
 * @global rcmail $RCMAIL
 * @param string $var_name Variable name.
 * @return void
 */
function rcube_sess_unset($var_name=null)
{
  global $RCMAIL;
@@ -1573,7 +1615,13 @@
}
// Replaces hostname variables
/**
 * Replaces hostname variables
 *
 * @param string $name Hostname
 * @return string
 */
function rcube_parse_host($name)
{
  // %n - host
@@ -1582,14 +1630,20 @@
  $d = preg_replace('/^[^\.]+\./', '', $n);
  // %h - IMAP host
  $h = $_SESSION['imap_host'];
  // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
  $z = preg_replace('/^[^\.]+\./', '', $h);
  $name = str_replace(array('%n', '%d', '%h'), array($n, $d, $h), $name);
  $name = str_replace(array('%n', '%d', '%h', '%z'), array($n, $d, $h, $z), $name);
  return $name;
}
/**
 * E-mail address validation
 *
 * @param string $email Email address
 * @param boolean $dns_check True to check dns
 * @return boolean
 */
function check_email($email, $dns_check=true)
{
@@ -1715,6 +1769,7 @@
 * Report error according to configured debug_level
 *
 * @param array Named parameters
 * @return void
 * @see raise_error()
 */
function log_bug($arg_arr)
@@ -1756,4 +1811,3 @@
        flush();
    }
}