- $strings_php = true;
- $fix_form_endlines = false;
-
- // Remove all slashes for form values
- if (get_magic_quotes_gpc())
- {
- global $REQUEST_METHOD;
- if ($REQUEST_METHOD == "POST")
- {
- global $HTTP_POST_VARS;
- RemoveSlashes($HTTP_POST_VARS);
- }
- elseif ($REQUEST_METHOD == "GET")
- {
- global $HTTP_GET_VARS;
- RemoveSlashes($HTTP_GET_VARS);
- }
- }
-
- if (isset($fix_form_endlines) && $fix_form_endlines) {
- if ($REQUEST_METHOD == "POST") {
- TrimArray($HTTP_POST_VARS);
- } else {
- TrimArray($HTTP_GET_VARS);
- }
- }
-
- //**************************************************************************
- // Trims every element in the array and returns a new array.
- //**************************************************************************
- function TrimArray(&$array) {
- foreach ($array as $k => $v) {
- global $$k;
- if (is_array($$k)) {
- foreach ($$k as $k2 => $v2) {
- $newArray[trim($k2)] = trim($v2);
- }
- $$k = $newArray;
- } else {
- $$k = trim($v);
- }
- }
- }
-
-
- //**************************************************************************
- // Removes slashes from every element in the array
- //**************************************************************************
- function RemoveSlashes($array)
- {
- foreach ($array as $k => $v)
- {
- global $$k;
- if (is_array($$k))
- {
- foreach ($$k as $k2 => $v2)
- {
- $newArray[stripslashes($k2)] = stripslashes($v2);
- }
- $$k = $newArray;
- }
- else
- {
- $$k = stripslashes($v);
- }
- }
- }
-
-
- //*************************************************************************
- // Count the number of occurances of $needle are in $haystack.
- // $needle can be a character or string, and need not occur in $haystack
- //*************************************************************************
- function countCharInString($haystack, $needle) {
- if ($needle == '') return 0;
- return count(explode($needle, $haystack));
- }
-
- //*************************************************************************
- // Read from the back of $haystack until $needle is found, or the begining
- // of the $haystack is reached. $needle is a single character
- //*************************************************************************
- function readShortMailboxName($haystack, $needle) {
- if ($needle == '') return $haystack;
- $parts = explode($needle, $haystack);
- $elem = array_pop($parts);
- while ($elem == '' && count($parts))
- {
- $elem = array_pop($parts);
- }
- return $elem;
- }
-
- //*************************************************************************
- // Read from the back of $haystack until $needle is found, or the begining
- // of the $haystack is reached. $needle is a single character
- //*************************************************************************
- function readMailboxParent($haystack, $needle) {
- if ($needle == '') return '';
- $parts = explode($needle, $haystack);
- $elem = array_pop($parts);
- while ($elem == '' && count($parts))
- {
- $elem = array_pop($parts);
- }
- return join($needle, $parts);
- }
-
- // 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
- // Has a problem with special HTML characters, so call this before
- // you do character translation.
- // Specifically, ' comes up as 5 characters instead of 1.
- // This should not add newlines to the end of lines.
- function sqWordWrap(&$line, $wrap) {
- ereg("^([\t >]*)([^\t >].*)?$", $line, $regs);
- $beginning_spaces = $regs[1];
- if (isset($regs[2])) {
- $words = explode(' ', $regs[2]);
- } else {
- $words = "";
- }
-
- $i = 0;
- $line = $beginning_spaces;
-
- while ($i < count($words)) {
- // Force one word to be on a line (minimum)
- $line .= $words[$i];
- $line_len = strlen($beginning_spaces) + strlen($words[$i]) + 2;
- if (isset($words[$i + 1]))
- $line_len += strlen($words[$i + 1]);
- $i ++;
-
- // Add more words (as long as they fit)
- while ($line_len < $wrap && $i < count($words)) {
+/**
+ * strings.php
+ *
+ * Copyright (c) 1999-2003 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This code provides various string manipulation functions that are
+ * used by the rest of the Squirrelmail code.
+ *
+ * $Id$
+ */
+
+require_once(SM_PATH . 'functions/global.php');
+
+/**
+ * SquirrelMail version number -- DO NOT CHANGE
+ */
+global $version;
+$version = '1.4.0 [CVS-DEVEL]';
+
+/**
+ * SquirrelMail internal version number -- DO NOT CHANGE
+ * $sm_internal_version = array (release, major, minor)
+ */
+global $SQM_INTERNAL_VERSION;
+$SQM_INTERNAL_VERSION = array(1,4,0);
+
+
+/**
+ * Wraps text at $wrap characters
+ *
+ * Has a problem with special HTML characters, so call this before
+ * you do character translation.
+ *
+ * Specifically, ' comes up as 5 characters instead of 1.
+ * This should not add newlines to the end of lines.
+ */
+function sqWordWrap(&$line, $wrap) {
+ ereg("^([\t >]*)([^\t >].*)?$", $line, $regs);
+ $beginning_spaces = $regs[1];
+ if (isset($regs[2])) {
+ $words = explode(' ', $regs[2]);
+ } else {
+ $words = '';
+ }
+
+ $i = 0;
+ $line = $beginning_spaces;
+
+ while ($i < count($words)) {
+ /* Force one word to be on a line (minimum) */
+ $line .= $words[$i];
+ $line_len = strlen($beginning_spaces) + strlen($words[$i]) + 2;
+ if (isset($words[$i + 1]))
+ $line_len += strlen($words[$i + 1]);
+ $i ++;
+
+ /* Add more words (as long as they fit) */
+ while ($line_len < $wrap && $i < count($words)) {