X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fstrings.php;h=44f1d12265a22808a31384c9bc5d3c844a2eabd4;hb=11353192de572c348b87ad6988409967d58308a6;hp=66cd5de8d562f45f1d26d527163af7cb19056b61;hpb=8dc0fb27d62a0f73b4170b81d1ad1e15e03bcd91;p=squirrelmail.git diff --git a/functions/strings.php b/functions/strings.php index 66cd5de8..44f1d122 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -1,5 +1,7 @@ ", $passed); + $passed = str_replace("<", "<", $passed); + $words = explode(" ", trim($passed)); $i = 0; $line_len = strlen($words[$i])+1; $line = ""; while ($i < count($words)) { while ($line_len < $wrap) { - $line = "$line$words[$i] "; + $line = "$line$words[$i] "; $i++; $line_len = $line_len + strlen($words[$i])+1; } $line_len = strlen($words[$i])+1; if ($line_len < $wrap) { if ($i < count($words)) // don't
the last line - $line = "$line
"; + $line = "$line\n"; } else { $endline = $words[$i]; while ($line_len >= $wrap) { @@ -54,11 +62,17 @@ $i++; } } + + $line = str_replace(">", ">", $line); + $line = str_replace("<", "<", $line); return $line; } /** Returns an array of email addresses **/ function parseAddrs($text) { + if (trim($text) == "") { + return; + } $text = str_replace(" ", "", $text); $text = str_replace(",", ";", $text); $array = explode(";", $text); @@ -77,6 +91,66 @@ return $to_line; } + function translateText($body, $wrap_at, $charset) { + /** Add any parsing you want to in here */ + $body = trim($body); + $body_ary = explode("\n", $body); + + for ($i = 0; $i < count($body_ary); $i++) { + $line = $body_ary[$i]; + $line = "^^$line"; + + //$line = str_replace(">", ">", $line); + //$line = str_replace("<", "<", $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(" ", " ", $line); + $line = str_replace("\t", "        ", $line); + $line = nl2br($line); + + if (strpos(trim(str_replace(" ", "", $line)), ">>") == 2) { + $line = substr($line, 2, strlen($line)); + $line = "$line
\n"; + } else if (strpos(trim(str_replace(" ", "", $line)), ">") == 2) { + $line = substr($line, 2, strlen($line)); + $line = "$line
\n"; + } else { + $line = substr($line, 2, strlen($line)); + $line = "$line
\n"; + } + + $new_body[$i] = "$line"; + } + $bdy = implode("\n", $new_body); + return $bdy; + } + /* SquirrelMail version number -- DO NOT CHANGE */ - $version = "0.2"; + $version = "0.4pre1"; + + + function find_mailbox_name ($mailbox) { + $mailbox = trim($mailbox); + if (substr($mailbox, strlen($mailbox)-1, strlen($mailbox)) == "\"") { + $mailbox = substr($mailbox, 0, strlen($mailbox) - 1); + $pos = strrpos ($mailbox, "\"")+1; + $box = substr($mailbox, $pos); + } else { + $box = substr($mailbox, strrpos($mailbox, " ")+1, strlen($mailbox)); + } + return $box; + } + + function replace_spaces ($string) { + return str_replace(" ", " ", $string); + } + + function replace_escaped_spaces ($string) { + return str_replace(" ", " ", $string); + } ?>