Changed comment. It used to plain wrong.
[squirrelmail.git] / functions / strings.php
index 2f7a92a531ee114739a4b263b93b26d721189cb8..84663b53506dc06c93e07b19e0b3ffbcb4a2ac24 100644 (file)
@@ -1,4 +1,6 @@
-<?
+<?php
+
+   $strings_php = true;
 
    //*************************************************************************
    // Count the number of occurances of $needle are in $haystack.
       return $data;
    }
 
+   // Searches for the next position in a string minus white space
+   function next_pos_minus_white ($haystack, $pos) {
+      while (substr($haystack, $pos, 1) == " " ||
+             substr($haystack, $pos, 1) == "\t" ||
+             substr($haystack, $pos, 1) == "\n" ||
+             substr($haystack, $pos, 1) == "\r") {
+         if ($pos >= strlen($haystack))
+            return -1;
+         $pos++;
+      }        
+      return $pos;        
+   }
+
    // Wraps text at $wrap characters
    function wordWrap($passed, $wrap) {
       $passed = str_replace("&gt;", ">", $passed);
       $text = str_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;
    }
 
       return $to_line;
    }
 
-   function translateText($body, $wrap_at) {
+   function translateText($body, $wrap_at, $charset) {
+      include ("../functions/url_parser.php");
       /** 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(">", "&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);
             $line = "<TT><FONT COLOR=000000>$line</FONT></TT><BR>\n";
          }
 
+         $line = parseEmail ($line);
+         $line = parseUrl ($line);
          $new_body[$i] = "$line";
       }
       $bdy = implode("\n", $new_body);
    }
 
    /* SquirrelMail version number -- DO NOT CHANGE */
-   $version = "0.3pre1";
+   $version = "0.5pre1";
 
 
    function find_mailbox_name ($mailbox) {