-
- /* $Id$ */
-
- $strings_php = true;
-
- // 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);
- }
- }
-
-
- 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;
- }