| | 126 | * Fetch an item from the $_GET array. |
| | 127 | * |
| | 128 | * @param string key to find |
| | 129 | * @param mixed default value |
| | 130 | * @param boolean XSS clean the value |
| | 131 | * @return mixed |
| | 132 | */ |
| | 133 | public function get($key, $default = NULL, $xss_clean = FALSE) |
| | 134 | { |
| | 135 | return $this->search_array($_GET, $key, $defult, $xss_clean); |
| | 136 | } |
| | 137 | |
| | 138 | /** |
| | 139 | * Fetch an item from the $_POST array. |
| | 140 | * |
| | 141 | * @param string key to find |
| | 142 | * @param mixed default value |
| | 143 | * @param boolean XSS clean the value |
| | 144 | * @return mixed |
| | 145 | */ |
| | 146 | public function post($key, $default = NULL, $xss_clean = FALSE) |
| | 147 | { |
| | 148 | return $this->search_array($_POST, $key, $defult, $xss_clean); |
| | 149 | } |
| | 150 | |
| | 151 | /** |
| | 152 | * Fetch an item from the $_COOKIE array. |
| | 153 | * |
| | 154 | * @param string key to find |
| | 155 | * @param mixed default value |
| | 156 | * @param boolean XSS clean the value |
| | 157 | * @return mixed |
| | 158 | */ |
| | 159 | public function cookie($key, $default = NULL, $xss_clean = FALSE) |
| | 160 | { |
| | 161 | return $this->search_array($_COOKIE, $key, $defult, $xss_clean); |
| | 162 | } |
| | 163 | |
| | 164 | /** |
| | 165 | * Fetch an item from the $_SERVER array. |
| | 166 | * |
| | 167 | * @param string key to find |
| | 168 | * @param mixed default value |
| | 169 | * @param boolean XSS clean the value |
| | 170 | * @return mixed |
| | 171 | */ |
| | 172 | public function server($key, $default = NULl, $xss_clean = FALSE) |
| | 173 | { |
| | 174 | return $this->search_array($_SERVER, $key, $defult, $xss_clean); |
| | 175 | } |
| | 176 | |
| | 177 | /** |
| 132 | | public function __call($global, $args = array()) |
| 133 | | { |
| 134 | | // Array to be searched, assigned by reference |
| 135 | | switch (strtolower($global)) |
| 136 | | { |
| 137 | | case 'get': $array =& $_GET; break; |
| 138 | | case 'post': $array =& $_POST; break; |
| 139 | | case 'cookie': $array =& $_COOKIE; break; |
| 140 | | case 'server': $array =& $_SERVER; break; |
| 141 | | default: |
| 142 | | throw new Kohana_Exception('core.invalid_method', $global, get_class($this)); |
| 143 | | } |
| 144 | | |
| 145 | | if ($args === array()) |
| 146 | | return $array; |
| 147 | | |
| 148 | | if (count($args) < 3) |
| 149 | | { |
| 150 | | // Add $default and $xss_clean params |
| 151 | | $args += array(1 => NULL, 2 => FALSE); |
| 152 | | } |
| 153 | | |
| 154 | | // Extract the arguments |
| 155 | | list ($key, $default, $xss_clean) = $args; |
| 156 | | |
| | 186 | protected function search_array(array $array, $key, $default = NULL, $xss_clean = FALSE) |
| | 187 | { |