-
- // Add more words (as long as they fit)
- while ($line_len < $wrap && $i < count($words)) {
- $line .= $words[$i] . ' ';
- $i++;
- $line_len += strlen($words[$i]) + 1;
- }
-
- // Skip spaces if they are the first thing on a continued line
- while (!$words[$i] && $i < count($words))
- {
- $i ++;
- }
-
- if ($i < count($words)) {
- $line .= "\n$beginning_spaces";
- }
- }
- } else {
- $line .= $words[0];
- }
- }
-
- /** Returns an array of email addresses **/
- function parseAddrs($text) {
- if (trim($text) == "") {
- return;
- }
- $text = str_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
-
- if (!isset($url_parser_php)) {
- include "../functions/url_parser.php";
- }
-
- $body_ary = explode("\n", $body);
- 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);
-
- $line = str_replace(' ', ' ', $line);
- $line = nl2br($line);
-
- parseUrl ($line);
-
- $Quotes = 0;
- $pos = 0;
- while (1)
- {
- if (strpos($line, ' ', $pos) === $pos)
- {
- $pos += 6;
- }
- else if (strpos($line, '>', $pos) === $pos)
- {
- $pos += 4;
- $Quotes ++;
- }
- else
- {
- break;
- }
- }
-
- if ($Quotes > 1) {
- $line = "<FONT COLOR=FF0000>$line</FONT>\n";
- } else if ($Quotes) {
- $line = "<FONT COLOR=800000>$line</FONT>\n";
- }
-
- if ($line)
- {
- $line = '<tt>' . $line . '</tt>';
- }
-
- $body_ary[$i] = $line . '<br>';
- }
- $body = implode("\n", $body_ary);
- }
-
- /* SquirrelMail version number -- DO NOT CHANGE */
- $version = "0.6pre1 (cvs)";
-
-
- 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);
- }
-
- function get_location () {
- # 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
-
- global $PHP_SELF, $SERVER_NAME, $HTTPS, $HTTP_HOST, $SERVER_PORT;
-
- // Get the path
- $path = substr($PHP_SELF, 0, strrpos($PHP_SELF, '/'));
-
- // Check if this is a HTTPS or regular HTTP request
- $proto = "http://";
- if(isset($HTTPS) && $HTTPS == 'on' ) {
- $proto = "https://";
- }
-
- $port = "";
- if (isset($SERVER_PORT)) {
- if ($SERVER_PORT != 80) {
- $port = sprintf(':%d', $SERVER_PORT);