1: <?php
2: class Horde_Rampage_Environment
3: {
4: public function setup()
5: {
6: set_magic_quotes_runtime(0);
7: $this->reverseMagicQuotes();
8: $this->reverseRegisterGlobals();
9: }
10:
11: 12: 13:
14: public function reverseMagicQuotes()
15: {
16: if (get_magic_quotes_gpc()) {
17: $input = array(&$_GET, &$_POST, &$_REQUEST, &$_COOKIE, &$_ENV, &$_SERVER);
18:
19: while (list($k, $v) = each($input)) {
20: foreach ($v as $key => $val) {
21: if (!is_array($val)) {
22: $key = stripslashes($key);
23: $input[$k][$key] = stripslashes($val);
24: continue;
25: }
26: $input[] =& $input[$k][$key];
27: }
28: }
29:
30: unset($input);
31: }
32: }
33:
34: 35: 36: 37: 38: 39: 40:
41: public function reverseRegisterGlobals()
42: {
43: if (ini_get('register_globals')) {
44:
45: $noUnset = array(
46: 'GLOBALS',
47: '_GET',
48: '_POST',
49: '_COOKIE',
50: '_REQUEST',
51: '_SERVER',
52: '_ENV',
53: '_FILES',
54: );
55:
56: $input = array_merge(
57: $_GET,
58: $_POST,
59: $_COOKIE,
60: $_SERVER,
61: $_ENV,
62: $_FILES,
63: isset($_SESSION) ? $_SESSION : array()
64: );
65:
66: foreach ($input as $k => $v) {
67: if (!in_array($k, $noUnset) && isset($GLOBALS[$k])) {
68: unset($GLOBALS[$k]);
69: }
70: }
71: }
72: }
73: }
74: