- }
-
- // Go to the next line if we have more to process
- if ($i < count($words)) {
- $line .= "\n" . $beginning_spaces;
- }
- }
- }
-
-
- // Does the opposite of sqWordWrap()
- function sqUnWordWrap(&$body)
- {
- $lines = explode("\n", $body);
- $body = "";
- $PreviousSpaces = "";
- for ($i = 0; $i < count($lines); $i ++)
- {
- ereg("^([\t >]*)([^\t >].*)?$", $lines[$i], $regs);
- $CurrentSpaces = $regs[1];
- if (isset($regs[2]))
- $CurrentRest = $regs[2];
- if ($i == 0)
- {
- $PreviousSpaces = $CurrentSpaces;
- $body = $lines[$i];
- }
- else if ($PreviousSpaces == $CurrentSpaces && // Do the beginnings match
- strlen($lines[$i - 1]) > 65 && // Over 65 characters long
- strlen($CurrentRest)) // and there's a line to continue with
- {
- $body .= ' ' . $CurrentRest;
- }
- else
- {
- $body .= "\n" . $lines[$i];
- $PreviousSpaces = $CurrentSpaces;
- }
- }
- $body .= "\n";
- }
-
-
- /** Returns an array of email addresses **/
- /* Be cautious of "user@host.com" */
- function parseAddrs($text) {
- if (trim($text) == "")
- return array();
- $text = str_replace(' ', '', $text);
- $text = ereg_replace('"[^"]*"', '', $text);
- $text = ereg_replace('\\([^\\)]*\\)', '', $text);
- $text = str_replace(',', ';', $text);
- $array = explode(';', $text);
- for ($i = 0; $i < count ($array); $i++) {
- $array[$i] = eregi_replace ("^.*[<]", '', $array[$i]);
- $array[$i] = eregi_replace ("[>].*$", '', $array[$i]);
- }
- return $array;
- }
-
- /** Returns a line of comma separated email addresses from an array **/
- function getLineOfAddrs($array) {
- if (is_array($array)) {
- $to_line = implode(', ', $array);
- $to_line = trim(ereg_replace(', (, )+', ', ', $to_line));
- } else {
- $to_line = '';
- }
- return $to_line;
- }
-
- function translateText(&$body, $wrap_at, $charset) {
- global $where, $what; // from searching
-
- include '../functions/url_parser.php';
-
- $body_ary = explode("\n", $body);
- $PriorQuotes = 0;
- for ($i=0; $i < count($body_ary); $i++) {
- $line = $body_ary[$i];
- if (strlen($line) - 2 >= $wrap_at) {
- sqWordWrap($line, $wrap_at);
- }
- $line = charset_decode($charset, $line);
- $line = str_replace("\t", ' ', $line);
-
- parseUrl ($line);
-
- $Quotes = 0;
- $pos = 0;
- while (1)
- {
- if ($line[$pos] == ' ')
- {
- $pos ++;
- }
- else if (strpos($line, '>', $pos) === $pos)
- {
- $pos += 4;
- $Quotes ++;
- }
- else
- {
- break;
- }
- }
-
- if ($Quotes > 1)
- $line = '<FONT COLOR="FF0000">'.$line.'</FONT>';
- elseif ($Quotes)
- $line = '<FONT COLOR="800000">'.$line.'</FONT>';
-
- $body_ary[$i] = $line;
- }
- $body = '<pre>' . implode("\n", $body_ary) . '</pre>';
- }
-
- /* SquirrelMail version number -- DO NOT CHANGE */
- global $version;
- $version = '1.1.3 [cvs]';
-
-
- function find_mailbox_name ($mailbox) {
- if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs))
- return $regs[1];
- ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs);
- return $regs[1];
+ }
+
+ /* Go to the next line if we have more to process */
+ if ($i < count($words)) {
+ $line .= "\n";
+ }
+ }
+}
+
+/**
+ * Does the opposite of sqWordWrap()
+ */
+function sqUnWordWrap(&$body) {
+ global $squirrelmail_language;
+
+ if ($squirrelmail_language == 'ja_JP') {
+ return;
+ }
+
+ $lines = explode("\n", $body);
+ $body = '';
+ $PreviousSpaces = '';
+ $cnt = count($lines);
+ for ($i = 0; $i < $cnt; $i ++) {
+ preg_match("/^([\t >]*)([^\t >].*)?$/", $lines[$i], $regs);
+ $CurrentSpaces = $regs[1];
+ if (isset($regs[2])) {
+ $CurrentRest = $regs[2];
+ } else {
+ $CurrentRest = '';
+ }
+
+ if ($i == 0) {
+ $PreviousSpaces = $CurrentSpaces;
+ $body = $lines[$i];
+ } else if (($PreviousSpaces == $CurrentSpaces) /* Do the beginnings match */
+ && (strlen($lines[$i - 1]) > 65) /* Over 65 characters long */
+ && strlen($CurrentRest)) { /* and there's a line to continue with */
+ $body .= ' ' . $CurrentRest;
+ } else {
+ $body .= "\n" . $lines[$i];
+ $PreviousSpaces = $CurrentSpaces;
+ }
+ }
+ $body .= "\n";
+}
+
+/**
+ * If $haystack is a full mailbox name and $needle is the mailbox
+ * separator character, returns the last part of the mailbox name.
+ */
+function readShortMailboxName($haystack, $needle) {
+
+ if ($needle == '') {
+ $elem = $haystack;
+ } else {
+ $parts = explode($needle, $haystack);
+ $elem = array_pop($parts);
+ while ($elem == '' && count($parts)) {
+ $elem = array_pop($parts);
+ }
+ }
+ return( $elem );
+}
+
+function php_self () {
+ if ( sqgetGlobalVar('REQUEST_URI', $req_uri, SQ_SERVER) && !empty($req_uri) ) {
+ return $req_uri;
+ }
+
+ if ( sqgetGlobalVar('PHP_SELF', $php_self, SQ_SERVER) && !empty($php_self) ) {
+ return $php_self;
+ }
+
+ return '';
+}
+
+
+/**
+ * This determines the location to forward to relative to your server.
+ * If this doesnt work correctly for you (although it should), you can
+ * remove all this code except the last two lines, and change the header()
+ * function to look something like this, customized to the location of
+ * SquirrelMail on your server:
+ *
+ * http://www.myhost.com/squirrelmail/src/login.php
+ */
+function get_location () {
+
+ global $imap_server_type;