Added limited support for Cyrillic (only KOI8-R yet) and made it possible to
authorgustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 22 Mar 2000 13:59:07 +0000 (13:59 +0000)
committergustavf <gustavf@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 22 Mar 2000 13:59:07 +0000 (13:59 +0000)
select default charset.

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

config/config_default.php
functions/i18n.php
functions/mime.php
functions/page_header.php
functions/smtp.php
functions/strings.php

index f3bd10faa7ea0051f083878ee8c50e309efa7f17..5d9deed5082985d9605543fb9720fb9d10185a5f 100644 (file)
 //  This is displayed right after they log in
     $motd = "You are using SquirrelMail's web-based email client.  If you run into any bugs or have suggestions, please report them to our <A HREF=\"mailto:squirrelmail-list@sourceforge.net\">mailing list</A>";
 
-//  Themes
-//     You can define your own theme and put it in this directory.  You must
-//     call it as the example below.  You can name the theme whatever you
-//     want.  For an example of a theme, see the ones included in the config
-//     directory.
-//
-//     You can download themes from http://squirrelmail.sourceforge.net/index.php3?page=10
-//
-//  To add a new theme to the options that users can choose from, just add
-//  a new number to the array at the bottom, and follow the pattern.
-
-    // The first one HAS to be here, and is your system's default theme.
-    // It can be any theme you want
-    $theme[0]["PATH"] = "../config/default_theme.php";
-    $theme[0]["NAME"] = "Default";
-
-    $theme[1]["PATH"] = "../config/sandstorm_theme.php";
-    $theme[1]["NAME"] = "Sand Storm";
-
-    $theme[2]["PATH"] = "../config/deepocean_theme.php";
-    $theme[2]["NAME"] = "Deep Ocean";
-
-    $theme[3]["PATH"] = "../config/slashdot_theme.php";
-    $theme[3]["NAME"] = "Slashdot";
-
-    $theme[4]["PATH"] = "../config/purple_theme.php";
-    $theme[4]["NAME"] = "Purple";
-
-    $theme[5]["PATH"] = "../config/forest_theme.php";
-    $theme[5]["NAME"] = "Forest";
-
-    $theme[6]["PATH"] = "../config/ice_theme.php";
-    $theme[6]["NAME"] = "Ice";
-
-    $theme[7]["PATH"] = "../config/seaspray_theme.php";
-    $theme[7]["NAME"] = "Sea Spray";
-
 //  Whether or not to use a special color for special folders.  If not, special
 //  folders will be the same color as the other folders
     $use_special_folder_color = true;
 
     $show_contain_subfolders_option = false;
 
+//  This option controls what character set is used when sending mail
+//  and when sending HTMl to the browser. Do not set this to US-ASCII,
+//  use ISO-8859-1 instead. For cyrillic it is best to use KOI8-R,
+//  since this implementation is faster than the alternatives.
+    $default_charset = "iso-8859-1";
+
 //  Whether or not to use META tags and automatically forward after an
 //  action has been completed.
     $auto_forward = true;
 //  but you can set it to whatever you wish.
 
    $default_left_size = 200;
+
+//  Themes
+//     You can define your own theme and put it in this directory.  You must
+//     call it as the example below.  You can name the theme whatever you
+//     want.  For an example of a theme, see the ones included in the config
+//     directory.
+//
+//     You can download themes from http://squirrelmail.sourceforge.net/index.php3?page=10
+//
+//  To add a new theme to the options that users can choose from, just add
+//  a new number to the array at the bottom, and follow the pattern.
+
+    // The first one HAS to be here, and is your system's default theme.
+    // It can be any theme you want
+    $theme[0]["PATH"] = "../config/default_theme.php";
+    $theme[0]["NAME"] = "Default";
+
+    $theme[1]["PATH"] = "../config/sandstorm_theme.php";
+    $theme[1]["NAME"] = "Sand Storm";
+
+    $theme[2]["PATH"] = "../config/deepocean_theme.php";
+    $theme[2]["NAME"] = "Deep Ocean";
+
+    $theme[3]["PATH"] = "../config/slashdot_theme.php";
+    $theme[3]["NAME"] = "Slashdot";
+
+    $theme[4]["PATH"] = "../config/purple_theme.php";
+    $theme[4]["NAME"] = "Purple";
+
+    $theme[5]["PATH"] = "../config/forest_theme.php";
+    $theme[5]["NAME"] = "Forest";
+
+    $theme[6]["PATH"] = "../config/ice_theme.php";
+    $theme[6]["NAME"] = "Ice";
+
+    $theme[7]["PATH"] = "../config/seaspray_theme.php";
+    $theme[7]["NAME"] = "Sea Spray";
+
 ?>
index 6d8b555b10263364a6c7353ce7596b8437ccc8e6..a7640d42ae83ba25d628e8c7a0f80c907ddee640 100644 (file)
@@ -39,6 +39,8 @@
             return charset_decode_iso_8859_default ($string);
       } else if ($charset == "ns_4551-1") {
          return charset_decode_ns_4551_1 ($string);
+      } else if ($charset == "koi8-r") {
+        return charset_decode_koi8r ($string);
       } else
          return $string;
    }
       return ($string);
    }
 
+   // ISO-8859-15 is Cyrillic
+   function charset_decode_iso_8859_5 ($string) {
+      // Not yet implemented.
+   }
+
    // Remove all 8 bit characters from all other ISO-8859 character sets
    function charset_decode_iso_8859_default ($string) {
       return (strtr($string, "\240\241\242\243\244\245\246\247".
       return strtr ($string, "[\\]{|}", "ÆØÅæøå");
    }
 
+   // KOI8-R is used to encode Russian mail (Cyrrilic). Defined in RFC
+   // 1489.
+   function charset_decode_koi8r ($string) {
+      global $default_charset;
+
+      if ($default_charset == "koi8-r") {
+         return $string;
+      } else { 
+         // Convert to Unicode HTML entities.
+         // This code is rather ineffective.
+         $string = ereg_replace("\200", "&#9472;", $string);
+         $string = ereg_replace("\201", "&#9474;", $string);
+         $string = ereg_replace("\202", "&#9484;", $string);
+         $string = ereg_replace("\203", "&#9488;", $string);
+         $string = ereg_replace("\204", "&#9492;", $string);
+         $string = ereg_replace("\205", "&#9496;", $string);
+         $string = ereg_replace("\206", "&#9500;", $string);
+         $string = ereg_replace("\207", "&#9508;", $string);
+         $string = ereg_replace("\210", "&#9516;", $string);
+         $string = ereg_replace("\211", "&#9524;", $string);
+         $string = ereg_replace("\212", "&#9532;", $string);
+         $string = ereg_replace("\213", "&#9600;", $string);
+         $string = ereg_replace("\214", "&#9604;", $string);
+         $string = ereg_replace("\215", "&#9608;", $string);
+         $string = ereg_replace("\216", "&#9612;", $string);
+         $string = ereg_replace("\217", "&#9616;", $string);
+         $string = ereg_replace("\220", "&#9617;", $string);
+         $string = ereg_replace("\221", "&#9618;", $string);
+         $string = ereg_replace("\222", "&#9619;", $string);
+         $string = ereg_replace("\223", "&#8992;", $string);
+         $string = ereg_replace("\224", "&#9632;", $string);
+         $string = ereg_replace("\225", "&#8729;", $string);
+         $string = ereg_replace("\226", "&#8730;", $string);
+         $string = ereg_replace("\227", "&#8776;", $string);
+         $string = ereg_replace("\230", "&#8804;", $string);
+         $string = ereg_replace("\231", "&#8805;", $string);
+         $string = ereg_replace("\232", "&#160;", $string);
+         $string = ereg_replace("\233", "&#8993;", $string);
+         $string = ereg_replace("\234", "&#176;", $string);
+         $string = ereg_replace("\235", "&#178;", $string);
+         $string = ereg_replace("\236", "&#183;", $string);
+         $string = ereg_replace("\237", "&#247;", $string);
+         $string = ereg_replace("\240", "&#9552;", $string);
+         $string = ereg_replace("\241", "&#9553;", $string);
+         $string = ereg_replace("\242", "&#9554;", $string);
+         $string = ereg_replace("\243", "&#1105;", $string);
+         $string = ereg_replace("\244", "&#9555;", $string);
+         $string = ereg_replace("\245", "&#9556;", $string);
+         $string = ereg_replace("\246", "&#9557;", $string);
+         $string = ereg_replace("\247", "&#9558;", $string);
+         $string = ereg_replace("\250", "&#9559;", $string);
+         $string = ereg_replace("\251", "&#9560;", $string);
+         $string = ereg_replace("\252", "&#9561;", $string);
+         $string = ereg_replace("\253", "&#9562;", $string);
+         $string = ereg_replace("\254", "&#9563;", $string);
+         $string = ereg_replace("\255", "&#9564;", $string);
+         $string = ereg_replace("\256", "&#9565;", $string);
+         $string = ereg_replace("\257", "&#9566;", $string);
+         $string = ereg_replace("\260", "&#9567;", $string);
+         $string = ereg_replace("\261", "&#9568;", $string);
+         $string = ereg_replace("\262", "&#9569;", $string);
+         $string = ereg_replace("\263", "&#1025;", $string);
+         $string = ereg_replace("\264", "&#9570;", $string);
+         $string = ereg_replace("\265", "&#9571;", $string);
+         $string = ereg_replace("\266", "&#9572;", $string);
+         $string = ereg_replace("\267", "&#9573;", $string);
+         $string = ereg_replace("\270", "&#9574;", $string);
+         $string = ereg_replace("\271", "&#9575;", $string);
+         $string = ereg_replace("\272", "&#9576;", $string);
+         $string = ereg_replace("\273", "&#9577;", $string);
+         $string = ereg_replace("\274", "&#9578;", $string);
+         $string = ereg_replace("\275", "&#9579;", $string);
+         $string = ereg_replace("\276", "&#9580;", $string);
+         $string = ereg_replace("\277", "&#169;", $string);
+         $string = ereg_replace("\300", "&#1102;", $string);
+         $string = ereg_replace("\301", "&#1072;", $string);
+         $string = ereg_replace("\302", "&#1073;", $string);
+         $string = ereg_replace("\303", "&#1094;", $string);
+         $string = ereg_replace("\304", "&#1076;", $string);
+         $string = ereg_replace("\305", "&#1077;", $string);
+         $string = ereg_replace("\306", "&#1092;", $string);
+         $string = ereg_replace("\307", "&#1075;", $string);
+         $string = ereg_replace("\310", "&#1093;", $string);
+         $string = ereg_replace("\311", "&#1080;", $string);
+         $string = ereg_replace("\312", "&#1081;", $string);
+         $string = ereg_replace("\313", "&#1082;", $string);
+         $string = ereg_replace("\314", "&#1083;", $string);
+         $string = ereg_replace("\315", "&#1084;", $string);
+         $string = ereg_replace("\316", "&#1085;", $string);
+         $string = ereg_replace("\317", "&#1086;", $string);
+         $string = ereg_replace("\320", "&#1087;", $string);
+         $string = ereg_replace("\321", "&#1103;", $string);
+         $string = ereg_replace("\322", "&#1088;", $string);
+         $string = ereg_replace("\323", "&#1089;", $string);
+         $string = ereg_replace("\324", "&#1090;", $string);
+         $string = ereg_replace("\325", "&#1091;", $string);
+         $string = ereg_replace("\326", "&#1078;", $string);
+         $string = ereg_replace("\327", "&#1074;", $string);
+         $string = ereg_replace("\330", "&#1100;", $string);
+         $string = ereg_replace("\331", "&#1099;", $string);
+         $string = ereg_replace("\332", "&#1079;", $string);
+         $string = ereg_replace("\333", "&#1096;", $string);
+         $string = ereg_replace("\334", "&#1101;", $string);
+         $string = ereg_replace("\335", "&#1097;", $string);
+         $string = ereg_replace("\336", "&#1095;", $string);
+         $string = ereg_replace("\337", "&#1098;", $string);
+         $string = ereg_replace("\340", "&#1070;", $string);
+         $string = ereg_replace("\341", "&#1040;", $string);
+         $string = ereg_replace("\342", "&#1041;", $string);
+         $string = ereg_replace("\343", "&#1062;", $string);
+         $string = ereg_replace("\344", "&#1044;", $string);
+         $string = ereg_replace("\345", "&#1045;", $string);
+         $string = ereg_replace("\346", "&#1060;", $string);
+         $string = ereg_replace("\347", "&#1043;", $string);
+         $string = ereg_replace("\350", "&#1061;", $string);
+         $string = ereg_replace("\351", "&#1048;", $string);
+         $string = ereg_replace("\352", "&#1049;", $string);
+         $string = ereg_replace("\353", "&#1050;", $string);
+         $string = ereg_replace("\354", "&#1051;", $string);
+         $string = ereg_replace("\355", "&#1052;", $string);
+         $string = ereg_replace("\356", "&#1053;", $string);
+         $string = ereg_replace("\357", "&#1054;", $string);
+         $string = ereg_replace("\360", "&#1055;", $string);
+         $string = ereg_replace("\361", "&#1071;", $string);
+         $string = ereg_replace("\362", "&#1056;", $string);
+         $string = ereg_replace("\363", "&#1057;", $string);
+         $string = ereg_replace("\364", "&#1058;", $string);
+         $string = ereg_replace("\365", "&#1059;", $string);
+         $string = ereg_replace("\366", "&#1046;", $string);
+         $string = ereg_replace("\367", "&#1042;", $string);
+         $string = ereg_replace("\370", "&#1068;", $string);
+         $string = ereg_replace("\371", "&#1067;", $string);
+         $string = ereg_replace("\372", "&#1047;", $string);
+         $string = ereg_replace("\373", "&#1064;", $string);
+         $string = ereg_replace("\374", "&#1069;", $string);
+         $string = ereg_replace("\375", "&#1065;", $string);
+         $string = ereg_replace("\376", "&#1063;", $string);
+         $string = ereg_replace("\377", "&#1066;", $string);
+
+         return $string;
+      }
+   }
+
 ?>
index 8b364a37ea2e949addcbc07caa7eda70d161ee29..cbc7d205275785e8cad0e01834c54dbfa24bbefd 100644 (file)
 
       if (containsType($message, "text", "html", $ent_num)) {
          $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+         $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
       } else if (containsType($message, "text", "plain", $ent_num)) {
          $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+         $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
       }
       // add other primary displaying message types here
       else {
          // find any type that's displayable
          if (containsType($message, "text", "any_type", $ent_num)) {
             $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+            $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
          } else if (containsType($message, "message", "any_type", $ent_num)) {
             $body = decodeBody($message["ENTITIES"][$ent_num]["BODY"], $message["ENTITIES"][$ent_num]["ENCODING"]);
+            $charset = $message["ENTITIES"][$ent_num]["CHARSET"];
          }
       }
 
       /** If there are other types that shouldn't be formatted, add
           them here **/
       if ($message["ENTITIES"][$ent_num]["TYPE1"] != "html")
-         $body = translateText($body, $wrap_at);
+         $body = translateText($body, $wrap_at, $charset);
 
 
       $body .= "<BR><SMALL><CENTER><A HREF=\"../src/download.php?absolute_dl=true&passed_id=$id&passed_ent_id=$ent_num&mailbox=$urlmailbox\">". _("Download this as a file") ."</A></CENTER><BR></SMALL>";
index 030a6070acfc34e4ab8c6beaea66d6c4468bd213..fb92f887c02885c172b65b50ad40cc030dc6a185 100644 (file)
@@ -13,7 +13,8 @@
 
    // This is done to ensure that the character set is correct when
    // receiving input from HTTP forms
-   header ("Content-Type: text/html; charset=iso-8859-1");
+   if ($default_charset != "")
+      header ("Content-Type: text/html; charset=$default_charset");
 
    // Check to see if gettext is installed
    if (function_exists("_")) {
index 28a2204a4cdeade21f2f29262567e350d294b8f0..5e39ad40e0e936192ed04cb88e0db97778729812 100644 (file)
    function write822Header ($fp, $t, $c, $b, $subject) {
       global $REMOTE_ADDR, $SERVER_NAME, $REMOTE_PORT;
       global $data_dir, $username, $domain, $version, $useSendmail;
+      global $default_charset;
 
       // Storing the header to make sure the header is the same
       // everytime the header is printed.
             $header .= mimeBoundary();
             $header .= "\"\r\n";
          } else {
-            $header .= "Content-Type: text/plain; charset=ISO-8859-1\r\n";
+            if ($default_charset != "")
+               $header .= "Content-Type: text/plain; charset=$default_charset\r\n";
+            else
+               $header .= "Content-Type: text/plain;\r\n";
             $header .= "Content-Transfer-Encoding: 8bit\r\n";
          }
          $header .= "\r\n"; // One blank line to separate header and body
 
    // Send the body
    function writeBody ($fp, $passedBody) {
+      global $default_charset;
+
       $attachmentlength = 0;
       
       if (isMultipart()) {
          $body = "--".mimeBoundary()."\r\n";
-         $body .= "Content-Type: text/plain; charset=iso-8859-1\r\n";
+
+         if ($default_charset != "")
+            $body .= "Content-Type: text/plain; charset=$default_charset\r\n";
+         else 
+            $body .= "Content-Type: text/plain\r\n";
+
          $body .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
          $body .= stripslashes($passedBody) . "\r\n";
          fputs ($fp, $body);
index 8d5385b903b130832c5c43ada9f5264c8f88eef7..c0f23a853f42fb29afe17ec6ff95bc25fe075f4e 100644 (file)
@@ -91,7 +91,7 @@
       return $to_line;
    }
 
-   function translateText($body, $wrap_at) {
+   function translateText($body, $wrap_at, $charset) {
       /** Add any parsing you want to in here */
       $body = trim($body);
       $body_ary = explode("\n", $body);
          $line = $body_ary[$i];
          $line = "^^$line";
 
-         $line = str_replace(">", "&gt;", $line);
-         $line = str_replace("<", "&lt;", $line);
+         //$line = str_replace(">", "&gt;", $line);
+         //$line = str_replace("<", "&lt;", $line);
+         //$line = htmlspecialchars($line);
 
          if (strlen($line) >= $wrap_at) // -2 because of the ^^ at the beginning
             $line = wordWrap($line, $wrap_at);
 
+         $line = charset_decode($charset, $line);
+
          $line = str_replace(" ", "&nbsp;", $line);
          $line = str_replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $line);
          $line = nl2br($line);