| 1 |
<?php |
| 2 |
|
| 3 |
if (!defined('WEBTOTEM_INIT') || WEBTOTEM_INIT !== true) { |
| 4 |
if (!headers_sent()) { |
| 5 |
header('HTTP/1.1 403 Forbidden'); |
| 6 |
} |
| 7 |
die("Protected By WebTotem!"); |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* HTTP request handler. |
| 12 |
* |
| 13 |
*/ |
| 14 |
class WebTotemRequest extends WebTotem { |
| 15 |
|
| 16 |
/** |
| 17 |
* Returns the value of the _GET, _POST or _REQUEST key. |
| 18 |
* |
| 19 |
* @param array $list |
| 20 |
* The array where the specified key will be searched. |
| 21 |
* @param string $key |
| 22 |
* Name of the variable contained in _POST. |
| 23 |
* |
| 24 |
* @return array|string|bool Value from the global _GET or _POST variable. |
| 25 |
*/ |
| 26 |
private static function request($list = array(), $key = '') { |
| 27 |
if (!is_array($list) || !isset($list[$key])) { |
| 28 |
return false; |
| 29 |
} |
| 30 |
|
| 31 |
// raw request parameter |
| 32 |
$key_value = $list[$key]; |
| 33 |
|
| 34 |
if(is_array($key_value)){ |
| 35 |
|
| 36 |
foreach ($key_value as $key => $value){ |
| 37 |
$key_value[$key] = self::escape($value); |
| 38 |
} |
| 39 |
|
| 40 |
return $key_value; |
| 41 |
} |
| 42 |
else { |
| 43 |
return self::escape($key_value); |
| 44 |
} |
| 45 |
|
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Returns the value stored in the index in the global variable _GET. |
| 50 |
* |
| 51 |
* @param string $key |
| 52 |
* Name of the variable contained in _GET. |
| 53 |
* |
| 54 |
* @return array|string |
| 55 |
* Value from the global _GET variable. |
| 56 |
*/ |
| 57 |
public static function get($key = '') { |
| 58 |
return self::request($_GET, $key); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Returns the value stored in the index in the global _POST variable. |
| 63 |
* |
| 64 |
* @param string $key |
| 65 |
* Name of the variable contained in _POST. |
| 66 |
* |
| 67 |
* @return array|string |
| 68 |
* Value from the global _POST variable. |
| 69 |
*/ |
| 70 |
public static function post($key = '') { |
| 71 |
return self::request($_POST, $key); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Returns the value stored in the index in the global _REQUEST variable. |
| 76 |
* |
| 77 |
* @param string $key |
| 78 |
* Name of the variable contained in _REQUEST. |
| 79 |
* |
| 80 |
* @return array|string |
| 81 |
* Value from the global _REQUEST variable. |
| 82 |
*/ |
| 83 |
public static function getOrPost($key = '') { |
| 84 |
return self::request($_REQUEST, $key); |
| 85 |
} |
| 86 |
} |
| 87 |
|