summaryrefslogtreecommitdiff
path: root/program/include
diff options
context:
space:
mode:
Diffstat (limited to 'program/include')
-rw-r--r--program/include/main.inc71
-rw-r--r--program/include/rcube_imap.inc23
-rw-r--r--program/include/rcube_shared.inc10
3 files changed, 85 insertions, 19 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index aa6a60790..06d4d7b80 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -79,6 +79,7 @@ function rcmail_startup($task='mail')
session_start();
$sess_id = session_id();
+ $_SESSION['user_lang'] = rcube_language_prop($CONFIG['locale_string']);
// create session and set session vars
if (!$_SESSION['client_id'])
{
@@ -265,7 +266,7 @@ function rcube_language_prop($lang, $prop='lang')
$lang = $rcube_language_aliases[$lang];
// try the first two chars
- if (!isset($rcube_languages[$lang]) && strlen($lang>2))
+ if (!isset($rcube_languages[$lang]) && strlen($lang)>2)
{
$lang = substr($lang, 0, 2);
$lang = rcube_language_prop($lang);
@@ -280,6 +281,7 @@ function rcube_language_prop($lang, $prop='lang')
else
$charset = 'UTF-8';
+
if ($prop=='charset')
return $charset;
else
@@ -320,7 +322,39 @@ function load_gui()
// set localization charset based on the given language
function rcmail_set_locale($lang)
{
- global $OUTPUT;
+ global $OUTPUT, $MBSTRING, $MBSTRING_ENCODING;
+ 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
+ }
+
$OUTPUT->set_charset(rcube_language_prop($lang, 'charset'));
}
@@ -448,13 +482,22 @@ function rcmail_create_user($user, $host)
$user_name = $user!=$user_email ? $user : '';
- // also create a new identity record
+ // try to resolve the e-mail address from the virtuser table
+ if (!empty($CONFIG['virtuser_query']))
+ {
+ $sql_result = $DB->query(preg_replace('/%u/', $user, $CONFIG['virtuser_query']));
+ if ($sql_arr = $DB->fetch_array($sql_result))
+ $user_email = $sql_arr[0];
+ }
+
+ // also create new identity records
$DB->query("INSERT INTO ".get_table_name('identities')."
(user_id, del, standard, name, email)
VALUES (?, 0, 1, ?, ?)",
$user_id,
$user_name,
$user_email);
+
// get existing mailboxes
$a_mailboxes = $IMAP->list_mailboxes();
@@ -662,7 +705,6 @@ function rcube_list_languages()
closedir($dh);
}
}
-
return $sa_languages;
}
@@ -718,16 +760,27 @@ function rcmail_message_cache_gc()
// this function is not complete and not tested well
function rcube_charset_convert($str, $from, $to=NULL)
{
+ global $MBSTRING, $MBSTRING_ENCODING;
+
$from = strtoupper($from);
$to = $to==NULL ? strtoupper($GLOBALS['CHARSET']) : strtoupper($to);
-
+
if ($from==$to)
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);
+ }
+
// convert charset using iconv module
- if (function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7') {
+ if (function_exists('iconv') && $from!='UTF-7' && $to!='UTF-7')
return iconv($from, $to, $str);
- }
$conv = new utf8();
@@ -1488,7 +1541,6 @@ EOF;
}
-
function rcmail_charset_selector($attrib)
{
// pass the following attributes to the form class
@@ -1499,10 +1551,11 @@ function rcmail_charset_selector($attrib)
$charsets = array(
'US-ASCII' => 'ASCII (English)',
- 'X-EUC-JP' => 'EUC-JP (Japanese)',
+ 'EUC-JP' => 'EUC-JP (Japanese)',
'EUC-KR' => 'EUC-KR (Korean)',
'BIG5' => 'BIG5 (Chinese)',
'GB2312' => 'GB2312 (Chinese)',
+ 'ISO-2022-JP' => 'ISO-2022-JP (Japanese)',
'ISO-8859-1' => 'ISO-8859-1 (Latin-1)',
'ISO-8859-2' => 'ISO-8895-2 (Central European)',
'ISO-8859-7' => 'ISO-8859-7 (Greek)',
diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index 400d0c0d7..50264acf0 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -865,7 +865,7 @@ class rcube_imap
{
$mailbox = $this->_mod_mailbox($mbox);
- // make shure mailbox exists
+ // make sure mailbox exists
if (in_array($mailbox, $this->_list_mailboxes()))
$saved = iil_C_Append($this->conn, $mailbox, $message);
@@ -885,10 +885,15 @@ class rcube_imap
$to_mbox = $this->_mod_mailbox($to_mbox);
$from_mbox = $from_mbox ? $this->_mod_mailbox($from_mbox) : $this->mailbox;
- // make shure mailbox exists
+ // make sure mailbox exists
if (!in_array($to_mbox, $this->_list_mailboxes()))
- return FALSE;
-
+ {
+ if (in_array(strtolower($to_mbox), $this->default_folders))
+ $this->create_mailbox($to_mbox, TRUE);
+ else
+ return FALSE;
+ }
+
// convert the list of uids to array
$a_uids = is_string($uids) ? explode(',', $uids) : (is_array($uids) ? $uids : NULL);
@@ -1473,10 +1478,10 @@ class rcube_imap
$key,
$index,
$headers->uid,
- substr($this->decode_header((string)$headers->subject, TRUE), 0, 128),
- substr($this->decode_header((string)$headers->from, TRUE), 0, 128),
- substr($this->decode_header((string)$headers->to, TRUE), 0, 128),
- substr($this->decode_header((string)$headers->cc, TRUE), 0, 128),
+ substr((string)$this->decode_header($headers->subject, TRUE), 0, 128),
+ substr((string)$this->decode_header($headers->from, TRUE), 0, 128),
+ substr((string)$this->decode_header($headers->to, TRUE), 0, 128),
+ substr((string)$this->decode_header($headers->cc, TRUE), 0, 128),
(int)$headers->size,
serialize($headers));
}
@@ -1931,4 +1936,4 @@ function quoted_printable_encode($input="", $line_max=76, $space_conv=false)
return trim($output);
}
-?>
+?> \ No newline at end of file
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index fb200de57..79428fa16 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -85,7 +85,15 @@ class rcube_html_page
function set_charset($charset)
{
+ global $MBSTRING;
$this->charset = $charset;
+ if ($MBSTRING&&function_exists( "mb_internal_encoding"))
+ {
+ if(!@mb_internal_encoding( $charset))
+ {
+ $MBSTRING = FALSE;
+ }
+ }
}
function get_charset()
@@ -1386,4 +1394,4 @@ function get_offset_time($offset_str, $factor=1)
}
-?> \ No newline at end of file
+?>