| 1 | <?php |
| 2 | /** |
| 3 | ** validate.php |
| 4 | ** |
| 5 | ** Copyright (c) 1999-2000 The SquirrelMail development team |
| 6 | ** Licensed under the GNU GPL. For full terms see the file COPYING. |
| 7 | ** |
| 8 | ** $Id$ |
| 9 | **/ |
| 10 | |
| 11 | if (defined ('validate_php')) { |
| 12 | return; |
| 13 | } else { |
| 14 | define ('validate_php', true); |
| 15 | } |
| 16 | |
| 17 | session_start(); |
| 18 | include ('../functions/auth.php'); |
| 19 | |
| 20 | is_logged_in(); |
| 21 | |
| 22 | |
| 23 | // Remove all slashes for form values |
| 24 | if (get_magic_quotes_gpc()) |
| 25 | { |
| 26 | global $REQUEST_METHOD; |
| 27 | if ($REQUEST_METHOD == "POST") |
| 28 | { |
| 29 | global $HTTP_POST_VARS; |
| 30 | RemoveSlashes($HTTP_POST_VARS); |
| 31 | } |
| 32 | elseif ($REQUEST_METHOD == "GET") |
| 33 | { |
| 34 | global $HTTP_GET_VARS; |
| 35 | RemoveSlashes($HTTP_GET_VARS); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // Auto-detection |
| 40 | // |
| 41 | // if $send (the form button's name) contains "\n" as the first char |
| 42 | // and the script is compose.php, then trim everything. Otherwise, |
| 43 | // we don't have to worry. |
| 44 | // |
| 45 | // This is for a RedHat package bug and a Konqueror (pre 2.1.1?) bug |
| 46 | global $send, $PHP_SELF; |
| 47 | if (isset($send) && substr($send, 0, 1) == "\n" && |
| 48 | substr($PHP_SELF, -12) == '/compose.php') |
| 49 | { |
| 50 | if ($REQUEST_METHOD == "POST") { |
| 51 | global $HTTP_POST_VARS; |
| 52 | TrimArray($HTTP_POST_VARS); |
| 53 | } else { |
| 54 | global $HTTP_GET_VARS; |
| 55 | TrimArray($HTTP_GET_VARS); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | //************************************************************************** |
| 60 | // Trims every element in the array |
| 61 | //************************************************************************** |
| 62 | function TrimArray(&$array) { |
| 63 | foreach ($array as $k => $v) { |
| 64 | global $$k; |
| 65 | if (is_array($$k)) { |
| 66 | foreach ($$k as $k2 => $v2) { |
| 67 | $$k[$k2] = substr($v2, 1); |
| 68 | } |
| 69 | } else { |
| 70 | $$k = substr($v, 1); |
| 71 | } |
| 72 | // Re-assign back to array |
| 73 | $array[$k] = $$k; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| 78 | //************************************************************************** |
| 79 | // Removes slashes from every element in the array |
| 80 | //************************************************************************** |
| 81 | function RemoveSlashes(&$array) |
| 82 | { |
| 83 | foreach ($array as $k => $v) |
| 84 | { |
| 85 | global $$k; |
| 86 | if (is_array($$k)) |
| 87 | { |
| 88 | foreach ($$k as $k2 => $v2) |
| 89 | { |
| 90 | $newArray[stripslashes($k2)] = stripslashes($v2); |
| 91 | } |
| 92 | $$k = $newArray; |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | $$k = stripslashes($v); |
| 97 | } |
| 98 | // Re-assign back to the array |
| 99 | $array[$k] = $$k; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // Everyone needs stuff from config, and config needs stuff from |
| 104 | // strings.php, so include them both here. |
| 105 | // Include them down here instead of at the top so that all config |
| 106 | // variables overwrite any passed in variables (for security) |
| 107 | include ('../functions/strings.php'); |
| 108 | include ('../config/config.php'); |
| 109 | |
| 110 | ?> |