X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fstrings.php;h=9b7371deb2dd7504132066adbd34cec68460a75d;hb=0bb7ad5eb668cfbcb9d958899075129a2182bcda;hp=82e8d0146329b845393f04f467f24e409709f07c;hpb=8a549df2a3129570bce1acc11d35e926268f70b8;p=squirrelmail.git diff --git a/functions/strings.php b/functions/strings.php index 82e8d014..9b7371de 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -18,7 +18,7 @@ //************************************************************************* function readShortMailboxName($haystack, $needle) { if ($needle == '') return $haystack; - if ($needle == '.') $needle = '\.'; + if ($needle == '.') $needle = '\\.'; ereg("([^$needle]+)$needle?$", $haystack, $regs); return $regs[1]; } @@ -28,7 +28,7 @@ // of the $haystack is reached. $needle is a single character //************************************************************************* function readMailboxParent($haystack, $needle) { - if ($needle == '.') $needle = '\.'; + if ($needle == '.') $needle = '\\.'; ereg("^(.+)$needle([^$needle]+)$needle?$", $haystack, $regs); return $regs[1]; } @@ -52,9 +52,13 @@ // Specifically, ' comes up as 5 characters instead of 1. // This should not add newlines to the end of lines. function sqWordWrap(&$line, $wrap) { - preg_match("/^([\s>]*)([^\s>].*)?$/", $line, $regs); + preg_match('/^([\\s>]*)([^\\s>].*)?$/', $line, $regs); $beginning_spaces = $regs[1]; - $words = explode(' ', $regs[2]); + if (isset($regs[2])) { + $words = explode(' ', $regs[2]); + } else { + $words = ""; + } $i = 0; $line = $beginning_spaces; @@ -84,7 +88,7 @@ // Go to the next line if we have more to process if ($i < count($words)) { - $line .= "\n$beginning_spaces"; + $line .= "\n" . $beginning_spaces; } } } @@ -98,7 +102,7 @@ $PreviousSpaces = ""; for ($i = 0; $i < count($lines); $i ++) { - preg_match("/^([\s>]*)([^\s>].*)?$/", $lines[$i], $regs); + preg_match('/^([\\s>]*)([^\\s>].*)?$/', $lines[$i], $regs); $CurrentSpaces = $regs[1]; if (isset($regs[2])) $CurrentRest = $regs[2]; @@ -130,7 +134,7 @@ return array(); $text = str_replace(' ', '', $text); $text = ereg_replace('"[^"]*"', '', $text); - $text = ereg_replace("\([^\)]*\)", '', $text); + $text = ereg_replace('\\([^\\)]*\\)', '', $text); $text = str_replace(',', ';', $text); $array = explode(';', $text); for ($i = 0; $i < count ($array); $i++) { @@ -191,9 +195,9 @@ } if ($Quotes > 1) - $line = '$line'; + $line = ''.$line.''; elseif ($Quotes) - $line = '$line'; + $line = ''.$line.''; $body_ary[$i] = $line; } @@ -205,18 +209,6 @@ 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; -*/ - if (ereg(" *\"([^\r\n\"]*)\"[ \r\n]*$", $mailbox, $regs)) return $regs[1]; ereg(" *([^ \r\n\"]*)[ \r\n]*$",$mailbox,$regs); @@ -384,7 +376,7 @@ $Str = ''; foreach ($dat as $k => $v) { - $Str .= "$k = $v\n"; + $Str .= $k . $v; } sq_mt_seed(md5($Str)); } @@ -414,7 +406,7 @@ function sqCheckPHPVersion($major, $minor, $release) { $ver = phpversion(); - eregi("^([0-9]+)\.([0-9]+)(.*)", $ver, $regs); + eregi('^([0-9]+)\\.([0-9]+)(.*)', $ver, $regs); // Parse the version string $vmajor = strval($regs[1]); @@ -496,6 +488,7 @@ sq_mt_randomize(); // Initialize the random number generator + $String = ""; while (strlen($String) < $size) { $String .= $chars[mt_rand(0, strlen($chars))]; } @@ -503,4 +496,4 @@ return $String; } -?> \ No newline at end of file +?>