66cd5de8d562f45f1d26d527163af7cb19056b61
3 //*************************************************************************
4 // Count the number of occurances of $needle are in $haystack.
5 //*************************************************************************
6 function countCharInString($haystack, $needle) {
7 $len = strlen($haystack);
8 for ($i = 0; $i < $len; $i++
) {
9 if ($haystack[$i] == $needle)
15 //*************************************************************************
16 // Read from the back of $haystack until $needle is found, or the begining
17 // of the $haystack is reached.
18 //*************************************************************************
19 function readShortMailboxName($haystack, $needle) {
20 if (strpos($haystack, $needle)) {
21 $pos = strrpos($haystack, $needle) +
1;
22 $data = substr($haystack, $pos, strlen($haystack));
29 // Wraps text at $wrap characters
30 function wordWrap($passed, $wrap) {
31 $words = explode(" ", trim($passed));
33 $line_len = strlen($words[$i])+
1;
35 while ($i < count($words)) {
36 while ($line_len < $wrap) {
37 $line = "$line$words[$i] ";
39 $line_len = $line_len +
strlen($words[$i])+
1;
41 $line_len = strlen($words[$i])+
1;
42 if ($line_len < $wrap) {
43 if ($i < count($words)) // don't <BR> the last line
46 $endline = $words[$i];
47 while ($line_len >= $wrap) {
48 $bigline = substr($endline, 0, $wrap);
49 $endline = substr($endline, $wrap, strlen($endline));
50 $line_len = strlen($endline);
51 $line = "$line$bigline<BR>";
53 $line = "$line$endline<BR>";
60 /** Returns an array of email addresses **/
61 function parseAddrs($text) {
62 $text = str_replace(" ", "", $text);
63 $text = str_replace(",", ";", $text);
64 $array = explode(";", $text);
68 /** Returns a line of comma separated email addresses from an array **/
69 function getLineOfAddrs($array) {
71 for ($i = 0; $i < count($array); $i++
) {
73 $to_line = "$to_line, $array[$i]";
75 $to_line = "$array[$i]";
80 /* SquirrelMail version number -- DO NOT CHANGE */