$default_charset variable equal to user's locale when decoding messages.
authortokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 7 Jan 2003 19:49:51 +0000 (19:49 +0000)
committertokul <tokul@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 7 Jan 2003 19:49:51 +0000 (19:49 +0000)
set_my_locale function gets charset from locale if no language variable
found in user's prefs. Fixes possible problem when $default_charset and
$squirrelmail_default_language are incorrectly set in config.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4396 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/i18n.php

index ff02b5d68222b793a04e499ac16e0e6503d43688..25e9f8862ab01309e627afc0b43f6455907c922c 100644 (file)
@@ -29,6 +29,8 @@ function charset_decode ($charset, $string) {
 
     $charset = strtolower($charset);
 
 
     $charset = strtolower($charset);
 
+    set_my_charset() ;
+
     if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) {
         if ($res[1] == '1') {
             $ret = charset_decode_iso_8859_1 ($string);
     if (ereg('iso-8859-([[:digit:]]+)', $charset, $res)) {
         if ($res[1] == '1') {
             $ret = charset_decode_iso_8859_1 ($string);
@@ -36,6 +38,8 @@ function charset_decode ($charset, $string) {
             $ret = charset_decode_iso_8859_2 ($string);
         } else if ($res[1] == '4') {
             $ret = charset_decode_iso_8859_4 ($string);
             $ret = charset_decode_iso_8859_2 ($string);
         } else if ($res[1] == '4') {
             $ret = charset_decode_iso_8859_4 ($string);
+        } else if ($res[1] == '5') {
+            $ret = charset_decode_iso_8859_5 ($string);
         } else if ($res[1] == '7') {
             $ret = charset_decode_iso_8859_7 ($string);
         } else if ($res[1] == '9') {
         } else if ($res[1] == '7') {
             $ret = charset_decode_iso_8859_7 ($string);
         } else if ($res[1] == '9') {
@@ -422,12 +426,10 @@ function charset_decode_iso_8859_2 ($string) {
 */
 
 function charset_decode_iso_8859_4 ($string) {
 */
 
 function charset_decode_iso_8859_4 ($string) {
-    global $default_charset, $languages, $sm_notAlias;
+    global $default_charset;
 
     if (strtolower($default_charset) == 'iso-8859-4')
         return $string;
 
     if (strtolower($default_charset) == 'iso-8859-4')
         return $string;
-    if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'iso-8859-4')
-        return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
@@ -553,12 +555,10 @@ function charset_decode_iso_8859_7 ($string) {
  ISOIEC 8859-9:1999 Latin Alphabet No. 5
 */
 function charset_decode_iso_8859_9 ($string) {
  ISOIEC 8859-9:1999 Latin Alphabet No. 5
 */
 function charset_decode_iso_8859_9 ($string) {
-    global $default_charset, $languages, $sm_notAlias;
+    global $default_charset;
 
     if (strtolower($default_charset) == 'iso-8859-9')
         return $string;
 
     if (strtolower($default_charset) == 'iso-8859-9')
         return $string;
-    if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'iso-8859-9')
-        return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
@@ -586,12 +586,10 @@ function charset_decode_iso_8859_9 ($string) {
  ISO/IEC 8859-13:1998 Latin Alphabet No. 7 (Baltic Rim) 
 */
 function charset_decode_iso_8859_13 ($string) {
  ISO/IEC 8859-13:1998 Latin Alphabet No. 7 (Baltic Rim) 
 */
 function charset_decode_iso_8859_13 ($string) {
-    global $default_charset, $languages, $sm_notAlias;
+    global $default_charset;
 
     if (strtolower($default_charset) == 'iso-8859-13')
         return $string;
 
     if (strtolower($default_charset) == 'iso-8859-13')
         return $string;
-    if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'iso-8859-13')
-        return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
@@ -877,12 +875,10 @@ function charset_decode_koi8r ($string) {
  windows-1254 (Turks)
  */
 function charset_decode_windows_1254 ($string) {
  windows-1254 (Turks)
  */
 function charset_decode_windows_1254 ($string) {
-    global $default_charset, $languages, $sm_notAlias;
+    global $default_charset;
 
     if (strtolower($default_charset) == 'windows-1254')
         return $string;
 
     if (strtolower($default_charset) == 'windows-1254')
         return $string;
-    if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'windows-1254')
-        return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
@@ -959,9 +955,9 @@ function charset_decode_windows_1254 ($string) {
  windows-1253 (Greek)
  */
 function charset_decode_windows_1253 ($string) {
  windows-1253 (Greek)
  */
 function charset_decode_windows_1253 ($string) {
-    global $languages, $sm_notAlias;
+    global $default_charset;
 
 
-    if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'windows-1253')
+    if (strtolower($default_charset) == 'windows-1253')
         return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
         return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
@@ -1006,12 +1002,10 @@ function charset_decode_windows_1253 ($string) {
  windows-1257 (BaltRim)
  */
 function charset_decode_windows_1257 ($string) {
  windows-1257 (BaltRim)
  */
 function charset_decode_windows_1257 ($string) {
-    global $default_charset, $languages, $sm_notAlias;
+    global $default_charset;
 
     if (strtolower($default_charset) == 'windows-1257')
         return $string;
 
     if (strtolower($default_charset) == 'windows-1257')
         return $string;
-    if (strtolower($languages[$sm_notAlias]['CHARSET']) == 'windows-1257')
-        return $string;
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
 
     /* Only do the slow convert if there are 8-bit characters */
     if (! ereg("[\200-\377]", $string))
@@ -1175,11 +1169,11 @@ function set_my_charset(){
      * selection. This is "more right" (tm), than just stamping the
      * message blindly with the system-wide $default_charset.
      */
      * selection. This is "more right" (tm), than just stamping the
      * message blindly with the system-wide $default_charset.
      */
-    global $data_dir, $username, $default_charset, $languages;
+    global $data_dir, $username, $default_charset, $languages, $squirrelmail_default_language;
 
     $my_language = getPref($data_dir, $username, 'language');
     if (!$my_language) {
 
     $my_language = getPref($data_dir, $username, 'language');
     if (!$my_language) {
-        return;
+        $my_language = $squirrelmail_default_language ;
     }
     while (isset($languages[$my_language]['ALIAS'])) {
         $my_language = $languages[$my_language]['ALIAS'];
     }
     while (isset($languages[$my_language]['ALIAS'])) {
         $my_language = $languages[$my_language]['ALIAS'];