Added html_top and html_bottom hooks to read_body for compression plugin
authorfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 21 Oct 2000 16:08:31 +0000 (16:08 +0000)
committerfidian <fidian@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sat, 21 Oct 2000 16:08:31 +0000 (16:08 +0000)
Changed internationalization things a bit, hopefully easier and less errors
Many bug fixes and speed enhancements from Martin Jespersen (embeejay)
Fixed a few bugs and did some speed changes on my own too!

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

23 files changed:
doc/plugin.txt
functions/i18n.php
functions/imap_general.php
functions/imap_messages.php
functions/mailbox_display.php
functions/mime.php
functions/page_header.php
functions/strings.php
src/addrbook_popup.php
src/addrbook_search.php
src/addrbook_search_html.php
src/compose.php
src/download.php
src/left_main.php
src/load_prefs.php
src/login.php
src/options.php
src/options_display.php
src/read_body.php
src/right_main.php
src/search.php
src/signout.php
src/webmail.php

index 60a44f5ca0541373b41f4d4812ee172fd5edbb12..1031e0ca8a0c6dbbefa86b755000463400500e02 100644 (file)
@@ -116,8 +116,10 @@ List of hooks
   right_main_bottom               src/right_main.php
   login_top                       src/login.php
   login_bottom                    src/login.php
+  html_top                        src/read_body.php
   read_body_top                   src/read_body.php
   read_body_bottom                src/read_body.php
+  html_bottom                     src/read_body.php
   search_before_form              src/search.php
   search_after_form               src/search.php
   search_bottom                   src/search.php
@@ -229,4 +231,4 @@ To set up links for actions, you assign them like this:
   
   $Args[1]['your_plugin_name']['href'] = 'URL to link to';
   $Args[1]['your_plugin_name']['text'] = 'What to display';
-    
\ No newline at end of file
+    
index 2b7d5f40659b980fa8a275a21274aa6aeca98563..32fb38a961ff3fcf4a47f0ab6033baff9b3450a2 100644 (file)
       }
    }
 
+
+   global $use_gettext;
+   
+   // Detect whether gettext is installed.
+   // If it is, set the flag so we can use it.
+   if (! function_exists("_") || 
+       ! function_exists("bindtextdomain") ||
+       ! function_exists("textdomain"))
+       $use_gettext = false;
+   else
+       $use_gettext = true;
+          
+
+   // Avoid warnings/errors   
+   if (! function_exists("_")) {
+      function _($str) { return $str; };
+   }
+   if (! function_exists("bindtextdomain")) {
+      function bindtextdomain() { return; }
+   }
+   if (! function_exists("textdomain")) {
+      function textdomain() { return; }
+   }
+
+
+   // Set up the language to be output
+   // if $do_search is true, then scan the browser information
+   // for a possible language that we know
+   function set_up_language($sm_language, $do_search = false)
+   {
+      static $SetupAlready = 0;
+      global $HTTP_ACCEPT_LANGUAGE;
+      
+      if ($SetupAlready)
+         return;
+      $SetupAlready = 1;
+     
+      if ($do_search && ! $sm_language && isset($HTTP_ACCEPT_LANGUAGE)) {
+         $sm_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
+      }
+      
+      if (isset($sm_language) && $use_gettext &&
+         $sm_language != "en" && $squirrelmail_language != "" &&
+         $languages[$sm_language]["CHARSET"]) {
+         putenv("LC_ALL=".$sm_language);
+         bindtextdomain("squirrelmail", "../locale/");
+         textdomain("squirrelmail");
+         header ("Content-Type: text/html; charset=".$languages[$sm_language]["CHARSET"]);
+      }
+   }
 ?>
index 83ffe7e68fcd607986d4a8fcb2cb5334f9481047..e8ee3deb55581421c67b575fcf15dfd653e539e2 100755 (executable)
@@ -11,7 +11,7 @@
     **  the errors will be sent back through $response and $message
     ******************************************************************************/
    function sqimap_read_data ($imap_stream, $pre, $handle_errors, $response, $message) {
-      global $color;
+      global $color, $squirrelmail_language;
 
       //$imap_general_debug = true;
       $imap_general_debug = false;
       $read = fgets ($imap_stream, 1024);
                if ($imap_general_debug) echo "<small><tt><font color=cc0000>$read</font></tt></small><br>";
       $counter = 0;
-      while ((substr($read, 0, strlen("$pre OK")) != "$pre OK") &&
-             (substr($read, 0, strlen("$pre BAD")) != "$pre BAD") &&
-             (substr($read, 0, strlen("$pre NO")) != "$pre NO")) {
+      while (! ereg("^$pre (OK|BAD|NO)(.*)$", $read, $regs)) {
          $data[$counter] = $read;
          $read = fgets ($imap_stream, 1024);
                        if ($imap_general_debug) echo "<small><tt><font color=cc0000>$read</font></tt></small><br>";
          $counter++;
       }       
       if ($imap_general_debug) echo "--<br>";
-      if (substr($read, 0, strlen("$pre OK")) == "$pre OK") {
-         $response = "OK";
-         $message = trim(substr($read, strlen("$pre OK"), strlen($read)));
-      }
-      else if (substr($read, 0, strlen("$pre BAD")) == "$pre BAD") {
-         $response = "BAD";
-         $message = trim(substr($read, strlen("$pre BAD"), strlen($read)));
-      }
-      else {   
-         $response = "NO";
-         $message = trim(substr($read, strlen("$pre NO"), strlen($read)));
-      }
 
       if ($handle_errors == true) {
-         if ($response == "NO") {
+         if ($regs[1] == "NO") {
+            set_up_language($squirrelmail_language);
             echo "<br><b><font color=$color[2]>\n";
             echo _("ERROR : Could not complete request.");
             echo "</b><br>\n";
             echo _("Reason Given: ");
-            echo "$message</font><br>\n";
+            echo trim($regs[2]) . "</font><br>\n";
             exit;
-         } else if ($response == "BAD") {
+         } else if ($regs[1] == "BAD") {
+            set_up_language($squirrelmail_language);
             echo "<br><b><font color=$color[2]>\n";
             echo _("ERROR : Bad or malformed request.");
             echo "</b><br>\n";
             echo _("Server responded: ");
-            echo "$message</font><br>\n";
+            echo trim($regs[2]) . "</font><br>\n";
             exit;
          }
       }
       // Decrypt the password
       $password = OneTimePadDecrypt($password, $onetimepad);
 
-      // This function can sometimes be called before the check for
-      // gettext is done.
-      if (!function_exists("_")) {
-         function _($string) {
-            return $string;
-         }
-      }
-
       /** Do some error correction **/
       if (!$imap_stream) {
          if (!$hide) {
+            set_up_language($squirrelmail_language, true);
             printf (_("Error connecting to IMAP server: %s.")."<br>\r\n", $imap_server_address);
             echo "$error_number : $error_string<br>\r\n";
          }
       if (substr($read, 0, 7) != "a001 OK") {
          if (!$hide) {
             if (substr($read, 0, 8) == "a001 BAD") {
+               set_up_language($squirrelmail_language, true);
                printf (_("Bad request: %s")."<br>\r\n", $read);
                exit;
             } else if (substr($read, 0, 7) == "a001 NO") {
                // $squirrelmail_language is set by a cookie when
                // the user selects language and logs out
                
-               // Use HTTP content language negotiation if cookie
-               // not set
-               if (!isset($squirrelmail_language) && isset($HTTP_ACCEPT_LANGUAGE)) {
-                  $squirrelmail_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
-               }
-               
-               if (isset($squirrelmail_language) && function_exists("bindtextdomain")) {
-                  if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
-                     putenv("LC_ALL=".$squirrelmail_language);
-                     bindtextdomain("squirrelmail", "../locale/");
-                     textdomain("squirrelmail");
-                     header ("Content-Type: text/html; charset=".$languages[$squirrelmail_language]["CHARSET"]);
-                  }
-               }
+               set_up_language($squirrelmail_language, true);
                
                ?>
                   <html>
                session_destroy();
                exit;
             } else {
+               set_up_language($squirrelmail_language, true);
                printf (_("Unknown error: %s")."<br>", $read);
                exit;
             }
     **  Returns the delimeter between mailboxes:  INBOX/Test, or INBOX.Test... 
     ******************************************************************************/
    function sqimap_get_delimiter ($imap_stream) {
-      fputs ($imap_stream, ". LIST \"INBOX\" \"\"\r\n");
-      $read = sqimap_read_data($imap_stream, ".", true, $a, $b);
-      $quote_position = strpos ($read[0], "\"");
-      $delim = substr ($read[0], $quote_position+1, 1);
-
-      return $delim;
+      fputs ($imap_stream, "a001 NAMESPACE\r\n");
+      $read = sqimap_read_data($imap_stream, "a001", true, $a, $b);
+      eregi("\"\" \"(.)\"", $read[0], $regs);
+      return $regs[1];
    }
 
 
       fputs ($imap_stream, "a001 EXAMINE \"$mailbox\"\r\n");
       $read_ary = sqimap_read_data ($imap_stream, "a001", true, $result, $message);
       for ($i = 0; $i < count($read_ary); $i++) {
-         if (substr(trim($read_ary[$i]), -6) == EXISTS) {
-            $array = explode (" ", $read_ary[$i]);
-            $num = $array[1];
+         if (ereg("[^ ]+ +([^ ]+) +EXISTS", $read_ary[$i], $regs)) {
+           return $regs[1];
          }
       }
-      return $num;
+      return "BUG!  Couldn't get number of messages in $mailbox!";
    }
 
    
        ** lehresma@css.tayloru.edu
        **/
 
-      if (strpos($string, "<") && strpos($string, ">")) {
-         $string = substr($string, strpos($string, "<")+1);
-         $string = substr($string, 0, strpos($string, ">"));
+      if (ereg("<([^>]+)>", $string, $regs)) {
+          $string = $regs[1];
       }
       return trim($string); 
    }
     **           becomes:   lkehresman@yahoo.com
     ******************************************************************************/
    function sqimap_find_displayable_name ($string) {
-      $string = " ".trim($string);
-      $orig_string = $string;
-      if (strpos($string, "<") && strpos($string, ">")) {
-         if (strpos($string, "<") == 1) {
-            $string = sqimap_find_email($string);
-         } else {
-            $string = trim($string);
-            $string = substr($string, 0, strpos($string, "<"));
-            $string = ereg_replace ("\"", "", $string);   
-         }   
-
-         if (trim($string) == "") {
-            $string = sqimap_find_email($orig_string);
-         }
-      }
-      return $string; 
+      ereg("^\"?([^\"<]*)[\" <]*([^>]+)>?$", trim($string), $regs);
+      if ($regs[1] == '')
+          return $regs[2];
+      return $regs[1];
    }
 
 
       //fputs ($imap_stream, "a001 SEARCH UNSEEN NOT DELETED\r\n");
       fputs ($imap_stream, "a001 STATUS \"$mailbox\" (UNSEEN)\r\n");
       $read_ary = sqimap_read_data ($imap_stream, "a001", true, $result, $message);
-      $unseen = false;
-      
-               $read_ary[0] = trim($read_ary[0]);
-               return substr($read_ary[0], strrpos($read_ary[0], " ")+1, (strlen($read_ary[0]) - strrpos($read_ary[0], " ") - 2)); 
+      ereg("UNSEEN ([0-9]+)", $read_ary[0], $regs);
+      return $regs[1];
    }
  
   
index f9da824d2c2bde34ecda80863c66cd88508b3837..1f4d57d427c8d517a8c0a963d367d56b4ef67cbf 100755 (executable)
 
       $g = 0;
       for ($i = 0; $i < count($read); $i++) {
-         if (eregi ("^to:", $read[$i])) {
+         if (eregi ("^to:(.*)$", $read[$i], $regs)) {
             //$to = sqimap_find_displayable_name(substr($read[$i], 3));
-            $to = substr($read[$i], 3);
-             } else if (eregi ("^from:", $read[$i])) {
+            $to = $regs[1];
+        } else if (eregi ("^from:(.*)$", $read[$i], $regs)) {
             //$from = sqimap_find_displayable_name(substr($read[$i], 5));
-            $from = substr($read[$i], 5);
-             } else if (eregi ("^x-priority:", $read[$i])) {
-            $priority = trim(substr($read[$i], 11));
-         } else if (eregi ("^message-id:", $read[$i])) {
-            $messageid = trim(substr($read[$i], 11));
-         } else if (eregi ("^cc:", $read[$i])) {
-            $cc = substr($read[$i], 3);
-         } else if (eregi ("^date:", $read[$i])) {
-            $date = substr($read[$i], 5);
-         } else if (eregi ("^subject:", $read[$i])) {
-            $subject = htmlspecialchars(eregi_replace ("^subject: ", "", $read[$i]));
-            if (trim($subject) == "")
+            $from = $regs[1];
+        } else if (eregi ("^x-priority:(.*)$", $read[$i], $regs)) {
+            $priority = trim($regs[1]);
+         } else if (eregi ("^message-id:(.*)$", $read[$i], $regs)) {
+            $messageid = trim($regs[1]);
+         } else if (eregi ("^cc:(.*)$", $read[$i], $regs)) {
+            $cc = $regs[1];
+         } else if (eregi ("^date:(.*)$", $read[$i], $regs)) {
+            $date = $regs[1];
+         } else if (eregi ("^subject:(.*)$", $read[$i], $regs)) {
+            $subject = htmlspecialchars(trim($regs[1]));
+            if ($subject == "")
                $subject = _("(no subject)");
-         } else if (eregi ("^content-type:", $read[$i])) {
-            $type = substr($read[$i], 14);
-            $type = strtolower(trim($type));
+         } else if (eregi ("^content-type:(.*)$", $read[$i], $regs)) {
+            $type = strtolower(trim($regs[1]));
             if ($pos = strpos($type, ";"))
                $type = substr($type, 0, $pos);
             $type = explode("/", $type);
       
       $header = new small_header;
       if ($sent == true)
-         $header->from = $to;
+         $header->from = (trim($to) != '')? $to : _('(only Cc/Bcc)');
       else   
          $header->from = $from;
 
    function sqimap_get_flags ($imap_stream, $i) {
       fputs ($imap_stream, "a001 FETCH $i:$i FLAGS\r\n");
       $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
-      if (strpos($read[0], "FLAGS")) {
-         $tmp = ereg_replace("\(", "", $read[0]);
-         $tmp = ereg_replace("\)", "", $tmp);
-         $tmp = str_replace("\\", "", $tmp);
-         $tmp = substr($tmp, strpos($tmp, "FLAGS")+6, strlen($tmp));
-         $tmp = trim($tmp);
-         $flags = explode(" ", $tmp);
-      } else {
-         $flags[0] = "None";
-      }
-      return $flags;
+      if (ereg("FLAGS(.*)", $read[0], $regs))
+          return explode(" ", trim(ereg_replace('[\(\)\\]', '', $regs[1])));
+      return Array('None');
    }
 
    /******************************************************************************
index 5a12ca4651e0a4f435170dff0ec9ec3d4e1535c7..95ea1b95cfbc985a72f511e366abb47c55bd6e18 100644 (file)
             $messages[$j]["TYPE0"] = $type[$j];
 
             # fix SUBJECT-SORT to remove Re:
-            if (substr($messages[$j]["SUBJECT-SORT"], 0, 3) == "re:" ||
-                substr($messages[$j]["SUBJECT-SORT"], 0, 3) == "aw:")
-               $messages[$j]["SUBJECT-SORT"] = trim(substr($messages[$j]["SUBJECT-SORT"], 3));    
+           $re_abbr = # Add more here!
+              "vedr|sv|" .    # Danish
+              "re|aw";        # English
+           if (eregi("^($re_abbr):[ ]*(.*)$",
+              $messages[$j]['SUBJECT-SORT'], $regs))
+              $messages[$j]['SUBJECT-SORT'] = $regs[2];
    
             $num = 0;
             while ($num < count($flags[$j])) {
index 2ae23b00a7477e88030a61f3814ab5ac38308364..e60bcb62e878b2d3fcaead6bb33f88ccdd8388e0 100644 (file)
 
       fputs ($imap_stream, "a001 FETCH $id BODY[$ent_id]\r\n");
       $topline = fgets ($imap_stream, 1024);
-      $size = substr ($topline, strpos($topline, "{")+1); 
-      $size = substr ($size, 0, strpos($size, "}"));
-      $read = fread ($imap_stream, $size);
-      return $read;
+      if (ereg('\{([^\}]*)\}', $topline, $regs)) {
+         return fread ($imap_stream, $regs[1]);
+      }
+      else if (ereg('"([^"]*)"', $topline, $regs)) {
+         return $regs[1];
+      }
+      return "Body retrival error, please report this bug!\n\nTop line is \"$topline\"\n";
    }
 
    /* -[ END MIME DECODING ]----------------------------------------------------------- */
index 8b1d1d9e531e024177c650f9476a821a57bbcf8c..e03a5fefc63845017d21ab8acb0cd4d0ee3fef7e 100644 (file)
       include ("../functions/plugin.php");
 
    // Check to see if gettext is installed
-   if (function_exists("_")) {
-      // Setting the language to use for gettext if it is not English
-      // (the default language) or empty.
-      $squirrelmail_language = getPref ($data_dir, $username, "language");
-      if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
-         putenv("LC_ALL=$squirrelmail_language");
-         bindtextdomain("squirrelmail", "../locale/");
-         textdomain("squirrelmail");
-         $default_charset = $languages[$squirrelmail_language]["CHARSET"];
-      }
-   } else {
-      function _($string) {
-         return $string;
-      }
-   }
+   set_up_language(getPref($data_dir, $username, "language"));
 
    // This is done to ensure that the character set is correct.
    if ($default_charset != "")
index 10f896f4b067084a18a10fb3e6af4221b8ff2704..ecd423b5a56c63b4686a53a946eb83f677c018cb 100644 (file)
          
          // We need to do it twice to catch times where there
          // are an odd number of spaces
+         if (ereg("^ (.*)$", $line, $regs))
+             $line = "&nbsp;" . $regs[1];
          $line = str_replace('  ', '&nbsp; ', $line);
          $line = str_replace('  ', '&nbsp; ', $line);
          $line = nl2br($line);
index f8248efe561c6ab68c12c7680be1063c0309a640..e629cea0b14e1bb364ab70e0211447058ef92a55 100644 (file)
@@ -11,6 +11,8 @@
 
    session_start();
 
+   if (!isset($i18n_php))
+      include("../functions/i18n.php");
    if (!isset($config_php))
       include("../config/config.php");
    if (!isset($page_header_php))
       include("../functions/addressbook.php");
 
    is_logged_in();
+
+   include("../src/load_prefs.php");
+   
+   set_up_language(getPref($data_dir, $username, "language"));
+   
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
 
index df487f719613bbcf80b4387dcadbd52e6c019d40..3205e4a4478b9d8afb14a6f4379eca774fe880cb 100644 (file)
@@ -125,12 +125,17 @@ function bcc_address($addr) {
    /* ================= End of functions ================= */
 
    session_start();
+   
+   if (!isset($i18n_php))
+      include("../functions/i18n.php");
 
    if(!isset($logged_in)) {
+      set_up_language($squirrelmail_language, true);
       echo _("You must login first.");
       exit;
    }
    if(!isset($username) || !isset($key)) {
+      set_up_language($squirrelmail_language, true);
       echo _("You need a valid user and password to access this page!");
       exit;
    }
index 95b93fccaffaf0fbca9cff6df01d7f1a58195a1a..495f218e53f8477c1d71c6809b75128db1d87a14 100644 (file)
    // Insert hidden data
    function addr_insert_hidden() {
       global $body, $subject, $send_to, $send_to_cc, $send_to_bcc;
-      printf("<input type=hidden value=\"%s\" name=body>\n", 
-             htmlspecialchars($body));
-      printf("<input type=hidden value=\"%s\" name=subject>\n", 
-             htmlspecialchars($subject));
-      printf("<input type=hidden value=\"%s\" name=send_to>\n", 
-             htmlspecialchars($send_to));
-      printf("<input type=hidden value=\"%s\" name=send_to_cc>\n", 
-             htmlspecialchars($send_to_cc));
-      printf("<input type=hidden value=\"%s\" name=send_to_bcc>\n", 
-             htmlspecialchars($send_to_bcc));     
-      printf("<input type=hidden value=\"true\" name=from_htmladdr_search>\n");
+      
+      echo "<input type=hidden value=\"";
+      if (substr($body, 0, 1) == "\r")
+          echo "\n";
+      echo htmlspecialchars($body) . "\" name=body>\n";
+      echo "<input type=hidden value=\"" . htmlspecialchars($subject)
+          . "\" name=subject>\n";
+      echo "<input type=hidden value=\"" . htmlspecialchars($send_to)
+          . "\" name=send_to>\n";
+      echo "<input type=hidden value=\"" . htmlspecialchars($send_to_cc)
+          . "\" name=send_to_cc>\n";
+      echo "<input type=hidden value=\"" . htmlspecialchars($send_to_bcc)
+          . "\" name=send_to_bcc>\n";
+      echo "<input type=hidden value=\"true\" name=from_htmladdr_search>\n";
    }
 
 
index cf4c4593b81f0218b599d0adf86bd2c72ed0e017..39d3d33bb7a97cf479966ee0ab470204666bda94 100644 (file)
          
          sqUnWordWrap($body);   
          $body_ary = explode("\n", $body);
+         while (ereg("^[>\s]*$", $body_ary[count($body_ary) - 1])) {
+            unset($body_ary[count($body_ary) - 1]);
+         }
          $body = "";
          for ($i=0; $i < count($body_ary); $i++) {
             if (! $forward_id)
             {
-                if (preg_match('/^[\s>]+/', $body_ary[$i]))
+                if (ereg('^[\s>]+', $body_ary[$i]))
                 {
                     $body_ary[$i] = '>' . $body_ary[$i];
                 }
              $bodyTop .= "\n";
              $body = $bodyTop . $body;
          }
+         
+         $body = ereg_replace('\\\\', '\\\\', $body);
 
          sqimap_mailbox_close($imapConnection);
          return;
       global $send_to, $send_to_cc, $reply_subj, $forward_subj, $body,
          $passed_body, $color, $use_signature, $signature, $editor_size,
          $attachments, $subject, $newmail, $use_javascript_addr_book,
-         $send_to_bcc, $reply_id, $mailbox, $from_htmladdr_search;
+         $send_to_bcc, $reply_id, $mailbox, $from_htmladdr_search,
+         $location_of_buttons;
 
       $subject = sqStripSlashes(decodeHeader($subject));
       $reply_subj = decodeHeader($reply_subj);
       }                 
       printf("<INPUT TYPE=hidden NAME=mailbox VALUE=\"%s\">\n", htmlspecialchars($mailbox));
       echo "<TABLE WIDTH=\"100%\" ALIGN=center CELLSPACING=0 BORDER=0>\n";
+
+      if ($location_of_buttons == 'top') showComposeButtonRow();
+
       echo "   <TR>\n";
       echo "      <TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>\n";
       echo _("To:");
       }
       echo "</td></tr>\n\n";
 
-      echo "   <TR><td>\n   </td><td>\n";
-      if ($use_javascript_addr_book) {
-         echo "      <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
-         echo "         <input type=button value=\\\""._("Addresses")."\\\" onclick='javascript:open_abook();'>\");";
-         echo "         // --></SCRIPT><NOSCRIPT>\n";
-         echo "         <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
-         echo "      </NOSCRIPT>\n";
-      } else {  
-         echo "      <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
-      }   
-      echo "\n    <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
-      
-      do_hook("compose_button_row");
-
-      echo "   </TD>\n";
-      echo "   </TR>\n\n";
-
+      if ($location_of_buttons == 'between') showComposeButtonRow();
 
       echo "   <TR>\n";
       echo "      <TD BGCOLOR=\"$color[4]\" COLSPAN=2>\n";
       echo "         &nbsp;&nbsp;<TEXTAREA NAME=body ROWS=20 COLS=\"$editor_size\" WRAP=HARD>";
+      echo htmlspecialchars($body);
       if ($use_signature == true && $newmail == true && !isset($from_htmladdr_search)) {
-         echo (htmlspecialchars($body)) . "\n\n-- \n" . htmlspecialchars($signature);
-      } else {
-         echo (htmlspecialchars($body));
+         echo "\n\n-- \n" . htmlspecialchars($signature);
       }
       echo "</TEXTAREA><BR>\n";
       echo "      </TD>\n";
       echo "   </TR>\n";
-      echo "   <TR><TD>&nbsp;</TD><TD ALIGN=LEFT><INPUT TYPE=SUBMIT NAME=send VALUE=\""._("Send")."\"></TD></TR>\n";
+
+      if ($location_of_buttons == 'bottom') 
+         showComposeButtonRow();
+      else {
+         echo "   <TR><TD>&nbsp;</TD><TD ALIGN=LEFT><INPUT TYPE=SUBMIT NAME=send VALUE=\""._("Send")."\"></TD></TR>\n";
+      }
       
       // This code is for attachments
       echo "   <tr>\n";
       echo "</FORM>";
       do_hook("compose_bottom");
    }
+   
+   function showComposeButtonRow() {
+      echo "   <TR><td>\n   </td><td>\n";
+      if ($use_javascript_addr_book) {
+         echo "      <SCRIPT LANGUAGE=JavaScript><!--\n document.write(\"";
+         echo "         <input type=button value=\\\""._("Addresses")."\\\" onclick='javascript:open_abook();'>\");";
+         echo "         // --></SCRIPT><NOSCRIPT>\n";
+         echo "         <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
+         echo "      </NOSCRIPT>\n";
+      } else {  
+         echo "      <input type=submit name=\"html_addr_search\" value=\""._("Addresses")."\">";
+      }   
+      echo "\n    <INPUT TYPE=SUBMIT NAME=send VALUE=\"". _("Send") . "\">\n";
+      
+      do_hook("compose_button_row");
+
+      echo "   </TD>\n";
+      echo "   </TR>\n\n";
+   }
 
    function showSentForm () {
       echo "<BR><BR><BR><CENTER><B>Message Sent!</B><BR><BR>";
index 0ae0bc04681eb2bafb7ba95af7bfd449eafee8e0..a74796399bb58a698909c3ae6c0e4796a27d2bdc 100644 (file)
@@ -19,6 +19,8 @@
       include("../functions/mime.php");
    if (!isset($date_php))
       include("../functions/date.php");
+   if (!isset($i18n_php))
+      include("../functions/i18n.php");
 
    include("../src/load_prefs.php");
 
             $body = decodeBody($body, $header->encoding);
             header("Content-Disposition: attachment; filename=\"$filename\"");
             header("Content-type: application/octet-stream; name=\"$filename\"");
+            set_up_language(getPref($data_dir, $username, "language"));
             if ($type1 == "plain") {
                echo _("Subject") . ": " . decodeHeader(sqStripSlashes($top_header->subject)) . "\n";
                echo "   " . _("From") . ": " . decodeHeader(sqStripSlashes($top_header->from)) . "\n";
index 2a540b44f4c63bb4b2d150311b13c8eeb1358c06..c348303503a8cef6d1bcea3bfe985a11c2129264 100644 (file)
@@ -12,6 +12,7 @@
    session_start();
 
    if(!isset($username)) {
+      set_up_language($squirrelmail_language, true);
       echo "You need a valid user and password to access this page!";
       exit;
    }
index dcef5e2ec6b0100bb381c7ae869efc4533c764d0..1c91e573ad2e392772dbc1b158953a2e40d0e3b8 100644 (file)
    $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
    if ($location_of_bar == '')
        $location_of_bar = 'left';
+       
+   $location_of_buttons = getPref($data_dir, $username, 'location_of_buttons');
+   if ($location_of_buttons == '')
+       $location_of_buttons = 'between';
 
    do_hook("loading_prefs");
 
index ad71c775aa502a8f8be5872e299e6dc50ab3fa83..f234550972e1ddc7816a5977203fd8e000b84a4d 100644 (file)
    if (!isset($plugin_php))
       include("../functions/plugin.php");
 
-   // let's check to see if they compiled with gettext support
-   if (!function_exists("_")) {
-      function _($string) {
-         return $string;
-      }
-   } else {
-      // $squirrelmail_language is set by a cookie when the user selects
-      // language and logs out
-
-      // Use HTTP content language negotiation if cookie not set
-      if (!isset($squirrelmail_language) && isset($HTTP_ACCEPT_LANGUAGE)) {
-         $squirrelmail_language = substr($HTTP_ACCEPT_LANGUAGE, 0, 2);
-      }
-
-      if (isset($squirrelmail_language)) {
-         if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
-            putenv("LC_ALL=".$squirrelmail_language);
-            bindtextdomain("squirrelmail", "../locale/");
-            textdomain("squirrelmail");
-            header ("Content-Type: text/html; charset=".$languages[$squirrelmail_language]["CHARSET"]);
-         }
-      }
-   }
+   // $squirrelmail_language is set by a cookie when the user selects
+   // language and logs out
+   set_up_language($squirrelmail_language, true);
 
    // Need the base URI to set the cookies. (Same code as in webmail.php)
    ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
index 14edf1a875693d12c6b22f264444c8e362b502ed..5710f0d06aa11363695305e13fc5acb8c4dcc9aa 100644 (file)
@@ -66,6 +66,7 @@
       setPref($data_dir, $username, "left_refresh", $leftrefresh);
       setPref($data_dir, $username, "language", $language);
       setPref($data_dir, $username, 'location_of_bar', $folder_new_location);
+      setPref($data_dir, $username, 'location_of_buttons', $button_new_location);
       setPref($data_dir, $username, "left_size", $leftsize);
       setPref($data_dir, $username, "use_javascript_addr_book", $javascript_abook);
     
index 37227bd6637ea70d14014f8c2ce5fc2012354865..91ec6136d65eb347d42b98db5aa5e47a9ea321bf 100644 (file)
             </td>
          </tr>
          <tr>
-            <td align=right nowrap><?php echo _("Language"); ?>:
+            <td valign=top align=right nowrap><?php echo _("Language"); ?>:
             </td><td>
 <?php
    echo "         <tt><select name=language>\n";
-   reset ($languages);
-   while (list($code, $name)=each($languages)) {
+   foreach ($languages as $code => $name) {
       if ($code==$chosen_language)
          echo "         <OPTION SELECTED VALUE=\"".$code."\">".$languages[$code]["NAME"]."\n";
       else
          echo "         <OPTION VALUE=\"".$code."\">".$languages[$code]["NAME"]."\n";
-   } 
+   }
    echo "         </select></tt>";  
+   if (! $use_gettext)
+      echo "<br><small>This system doesn't support multiple languages</small>";
+      
 ?>
             </td>
          <tr>
             <td align=right nowrap>&nbsp;
-            </td><td>
-               <?php echo _("Use Javascript or HTML addressbook?") . "<br>"; 
+               <?php echo _("Use Javascript or HTML addressbook?") . "</td><td>"; 
                if ($use_javascript_addr_book == true) {
                   echo "         <input type=radio name=javascript_abook value=1 checked> " . _("JavaScript") . "&nbsp;&nbsp;&nbsp;&nbsp;";
                   echo "         <input type=radio name=javascript_abook value=0> " . _("HTML"); 
                 </select>
             </td>
          </tr>
+         <tr>
+            <td align=right nowrap><?PHP echo _('Location of buttons when composing') ?>:</td>
+            <td><select name="button_new_location">
+                <option value="top"<?PHP
+                    if ($location_of_buttons == 'top') echo ' SELECTED';
+                    ?>><?PHP echo _('Before headers'); ?></option>
+                <option value="between"<?PHP
+                    if ($location_of_buttons == 'between') echo ' SELECTED';
+                    ?>><?PHP echo _('Between headers and message body'); ?></option>
+                <option value="bottom"<?PHP
+                    if ($location_of_buttons == 'bottom') echo ' SELECTED';
+                    ?>><?PHP echo _('After message body'); ?></option>
+                </select>
+            </td>
+         </tr>
          <tr>
             <td align=right nowrap><?php echo _("Width of folder list"); ?>:
             </td><td>
index a16372b1a8bc8ebd648dac36efd829c958579b2b..3aa9bdb43385b94a9506b270986776e299f3d32b 100644 (file)
@@ -27,6 +27,7 @@
    include("../src/load_prefs.php");
    $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
    sqimap_mailbox_select($imapConnection, $mailbox);
+   do_hook("html_top");
    displayPageHeader($color, $mailbox);
 
    if ($view_hdr) {
    
    $body = formatBody($imapConnection, $message, $color, $wrap_at);
 
-   echo "$body";
-
+   echo $body;
+   
    echo "<TABLE COLS=1 CELLSPACING=0 WIDTH=100% BORDER=0 ALIGN=CENTER CELLPADDING=0>\n";
    echo "   <TR><TD BGCOLOR=\"$color[9]\">&nbsp;</TD></TR>";
    echo "</TABLE>\n";
 
    do_hook("read_body_bottom");
+   do_hook("html_bottom");
    sqimap_logout($imapConnection);
 ?>
index 3efad3d61471d9b7feb37d52d8cd57447e6ea906..16306ce3f3c38590b0f11433d0996bf9d9eb3fdf 100644 (file)
     **
     **/
 
+   if (!isset($i18n_php))
+      include("../functions/i18n.php");
 
    session_start();
 
    if(!isset($logged_in)) {
+      set_up_language($squirrelmail_language, true);
       echo _("You must login first.");
       exit;
    }
    if(!isset($username) || !isset($key)) {
+      set_up_language($squirrelmail_language, true);
       echo _("You need a valid user and password to access this page!");
       exit;
    }
index f5b4798db4f8d69959373032f9cd97e502a1879a..ed92be5e85d7a2173d7d65f9e43b07483764882e 100644 (file)
@@ -2,10 +2,12 @@
    session_start();
 
    if(!isset($logged_in)) {
+      set_up_language($squirrelmail_language, true);
       echo _("You must login first.");
       exit;
    }
    if(!isset($username) || !isset($key)) {
+      set_up_language($squirrelmail_language, true);
       echo _("You need a valid user and password to access this page!");
       exit;
    }
index 84e693d073732b1fda7f976cbe116dc473db6851..ebf2fa6e0d69904b00daf908d3a29d10172800a2 100644 (file)
    if (!isset($plugin_php))
       include ("../functions/plugin.php");
 
-   // Quick Fix for Gettext in LogOut Screen
-   if (!function_exists("_")) {
-      function _($string) {
-         return $string;
-      }
-   }
-
-   $squirrelmail_language = getPref ($data_dir, $username, "language");
-   if (isset($squirrelmail_language)) {
-      if ($squirrelmail_language != "en" && $squirrelmail_language != "") {
-         putenv("LC_ALL=".$squirrelmail_language);
-         bindtextdomain("squirrelmail", "../locale/");
-         textdomain("squirrelmail");
-         header ("Content-Type: text/html; charset=".$languages[$squirrelmail_language]["CHARSET"]);
-
-         // Setting cookie to use on the login screen the next time the
-         // same user logs in.
-         setcookie("squirrelmail_language", $squirrelmail_language, 
-                   time()+2592000);
-
-      }
-   }
+   set_up_language(getPref($data_dir, $username, "language"));
 
    do_hook("logout");
    setcookie("username", "", 0, $base_uri);
index 66eb3af3a462623f7c599648d54b02db272fa7a4..89811e017edf3bb1a60a25b7e42dbc2d7eb54d26 100644 (file)
 
    session_register ("base_uri");
 
+   if (!isset($i18n_php))
+      include ("../functions/i18n.php");
+
    if(!isset($username)) {
+      set_up_language($squirrelmail_language);
       echo _("You need a valid user and password to access this page!");
       exit;
    }
@@ -68,6 +72,9 @@
 
    include ("../src/load_prefs.php");
 
+   // We'll need this to later have a noframes version
+   set_up_language(getPref($data_dir, $username, "language"));
+
    echo "<html><head>\n";
    echo "<TITLE>";
    echo "$org_title";