From 3ea0e3202a73eb7efcbf0b825582a6d3504658aa Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Fri, 01 Sep 2006 09:43:14 -0400 Subject: [PATCH] Quota display as image --- program/include/main.inc | 59 ++++++++++++++++++----------------------------------------- 1 files changed, 18 insertions(+), 41 deletions(-) diff --git a/program/include/main.inc b/program/include/main.inc index 887668b..ecf53b5 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -377,38 +377,14 @@ // set localization charset based on the given language function rcmail_set_locale($lang) { - global $OUTPUT, $MBSTRING, $MBSTRING_ENCODING; + global $OUTPUT, $MBSTRING; static $s_mbstring_loaded = NULL; // settings for mbstring module (by Tadashi Jokagi) - if ($s_mbstring_loaded===NULL) - { - if ($s_mbstring_loaded = extension_loaded("mbstring")) - { - $MBSTRING = TRUE; - if (function_exists("mb_mbstring_encodings")) - $MBSTRING_ENCODING = mb_mbstring_encodings(); - else - $MBSTRING_ENCODING = array("ISO-8859-1", "UTF-7", "UTF7-IMAP", "UTF-8", - "ISO-2022-JP", "EUC-JP", "EUCJP-WIN", - "SJIS", "SJIS-WIN"); - - $MBSTRING_ENCODING = array_map("strtoupper", $MBSTRING_ENCODING); - if (in_array("SJIS", $MBSTRING_ENCODING)) - $MBSTRING_ENCODING[] = "SHIFT_JIS"; - } - else - { - $MBSTRING = FALSE; - $MBSTRING_ENCODING = array(); - } - } - - if ($MBSTRING && function_exists("mb_language")) - { - if (!@mb_language(strtok($lang, "_"))) - $MBSTRING = FALSE; // unsupport language - } + if (is_null($s_mbstring_loaded)) + $MBSTRING = $s_mbstring_loaded = extension_loaded("mbstring"); + else + $MBSTRING = $s_mbstring_loaded = FALSE; $OUTPUT->set_charset(rcube_language_prop($lang, 'charset')); } @@ -439,12 +415,12 @@ Inspired by Marco <P0L0_notspam_binware.org> */ // Check if we need to add domain - if ($CONFIG['username_domain'] && !strstr($user, '@')) + if (!empty($CONFIG['username_domain']) && !strstr($user, '@')) { if (is_array($CONFIG['username_domain']) && isset($CONFIG['username_domain'][$host])) $user .= '@'.$CONFIG['username_domain'][$host]; - else if (!empty($CONFIG['username_domain'])) - $user .= '@'.$CONFIG['username_domain']; + else if (is_string($CONFIG['username_domain'])) + $user .= '@'.$CONFIG['username_domain']; } @@ -490,7 +466,7 @@ // update user's record $DB->query("UPDATE ".get_table_name('users')." - SET last_login=now() + SET last_login=".$DB->now()." WHERE user_id=?", $user_id); } @@ -535,7 +511,7 @@ $DB->query("INSERT INTO ".get_table_name('users')." (created, last_login, username, mail_host, alias, language) - VALUES (now(), now(), ?, ?, ?, ?)", + VALUES (".$DB->now().", ".$DB->now().", ?, ?, ?, ?)", $user, $host, $user_email, @@ -868,22 +844,23 @@ // this function is not complete and not tested well function rcube_charset_convert($str, $from, $to=NULL) { - global $MBSTRING, $MBSTRING_ENCODING; + global $MBSTRING; $from = strtoupper($from); $to = $to==NULL ? strtoupper($GLOBALS['CHARSET']) : strtoupper($to); - if ($from==$to) + if ($from==$to || $str=='') return $str; - + // convert charset using mbstring module if ($MBSTRING) { $to = $to=="UTF-7" ? "UTF7-IMAP" : $to; $from = $from=="UTF-7" ? "UTF7-IMAP": $from; - - if (in_array($to, $MBSTRING_ENCODING) && in_array($from, $MBSTRING_ENCODING)) - return mb_convert_encoding($str, $to, $from); + + // return if convert succeeded + if (($out = mb_convert_encoding($str, $to, $from)) != '') + return $out; } // convert charset using iconv module @@ -944,7 +921,6 @@ { $html_encode_arr = get_html_translation_table(HTML_SPECIALCHARS); unset($html_encode_arr['?']); - unset($html_encode_arr['&']); } $ltpos = strpos($str, '<'); @@ -956,6 +932,7 @@ unset($encode_arr['"']); unset($encode_arr['<']); unset($encode_arr['>']); + unset($encode_arr['&']); } else if ($mode=='remove') $str = strip_tags($str); -- Gitblit v1.9.1