From 88f66ec89cf87328536757ac33e508a9614bdc09 Mon Sep 17 00:00:00 2001 From: thomascube Date: Mon, 13 Aug 2007 20:15:27 +0000 Subject: Fix bugs introduced with latest changes --- CHANGELOG | 6 ++++++ index.php | 3 +-- program/include/main.inc | 24 +++++++++--------------- program/include/rcube_shared.inc | 21 +++++++++++++++++++++ 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 75466dd81..48d73aede 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,12 @@ CHANGELOG RoundCube Webmail --------------------------- +2007/08/13 (thomasb) +---------- +- Add alternative for getallheaders() (fix #1484508) +- Revert changes for mbstring usage (fix #1484509) + + 2007/08/10 (thomasb) ---------- - Identify mailboxes case-sensitive diff --git a/index.php b/index.php index 6e8b7ffa8..34b5f8b26 100644 --- a/index.php +++ b/index.php @@ -221,8 +221,7 @@ if (empty($_SESSION['user_id'])) // check client X-header to verify request origin if ($OUTPUT->ajax_call) { - $hdrs = getallheaders(); - if (empty($hdrs['X-RoundCube-Referer']) && empty($CONFIG['devel_mode'])) + if (empty($CONFIG['devel_mode']) && !rc_request_header('X-RoundCube-Referer')) { header('HTTP/1.1 404 Not Found'); die("Invalid Request"); diff --git a/program/include/main.inc b/program/include/main.inc index 9aa274f27..f938174d6 100644 --- a/program/include/main.inc +++ b/program/include/main.inc @@ -472,19 +472,11 @@ function rcmail_set_locale($lang) static $s_mbstring_loaded = NULL; // settings for mbstring module (by Tadashi Jokagi) - if (is_null($s_mbstring_loaded) && ($s_mbstring_loaded = extension_loaded("mbstring"))) - { - $MBSTRING = array(); - foreach (mb_list_encodings() as $charset) - $MBSTRING[strtoupper($charset)] = strtoupper($charset); - - // add some alias charsets - $MBSTRING['UTF-7'] = "UTF7-IMAP"; - $MBSTRING['WINDOWS-1257'] = "ISO-8859-13"; - } - else if (is_null($s_mbstring_loaded)) + if (is_null($s_mbstring_loaded)) + $MBSTRING = $s_mbstring_loaded = extension_loaded("mbstring"); + else $MBSTRING = $s_mbstring_loaded = FALSE; - + if ($MBSTRING) mb_internal_encoding(RCMAIL_CHARSET); @@ -1057,7 +1049,6 @@ function rcmail_message_cache_gc() function rcube_charset_convert($str, $from, $to=NULL) { global $MBSTRING; - static $mb_encodings; $from = strtoupper($from); $to = $to==NULL ? strtoupper(RCMAIL_CHARSET) : strtoupper($to); @@ -1070,10 +1061,13 @@ function rcube_charset_convert($str, $from, $to=NULL) return iconv($from, $to . "//IGNORE", $str); // convert charset using mbstring module - if ($MBSTRING && ($mbfrom = $MBSTRING[$from]) && ($mbto = $MBSTRING[$to])) + if ($MBSTRING) { + $to = $to=="UTF-7" ? "UTF7-IMAP" : $to; + $from = $from=="UTF-7" ? "UTF7-IMAP": $from; + // return if convert succeeded - if (($out = mb_convert_encoding($str, $mbto, $mbfrom)) != '') + if (($out = mb_convert_encoding($str, $to, $from)) != '') return $out; } diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc index acf98c938..eeca2b57a 100644 --- a/program/include/rcube_shared.inc +++ b/program/include/rcube_shared.inc @@ -522,6 +522,27 @@ function rc_strrpos($haystack, $needle, $offset=0) } +/** + * Read a specific HTTP request header + * + * @param string Header name + * @return string Header value or null if not available + */ +function rc_request_header($name) +{ + if (function_exists('getallheaders')) + { + $hdrs = getallheaders(); + return $hdrs[$name]; + } + else + { + $key = "HTTP_" . strtoupper(strtr($name, "-", "_")); + return $_SERVER[$key]; + } +} + + /** * Replace the middle part of a string with ... * if it is longer than the allowed length -- cgit v1.2.3