| 149 | | // If the last argument is a boolean, it's the XSS clean flag |
|---|
| 150 | | $xss_clean = (is_bool(end($args))) ? array_pop($args) : FALSE; |
|---|
| 151 | | |
|---|
| 152 | | // Reset the array pointer |
|---|
| 153 | | reset($args); |
|---|
| 154 | | |
|---|
| 155 | | // Multiple inputs require us to return an array |
|---|
| 156 | | $return_array = (count($args) > 1); |
|---|
| 157 | | |
|---|
| 158 | | $data = array(); |
|---|
| 159 | | while ($key = array_shift($args)) |
|---|
| 160 | | { |
|---|
| 161 | | if (isset($array[$key])) |
|---|
| 162 | | { |
|---|
| 163 | | // XSS clean if the data has not already been cleaned |
|---|
| 164 | | $data[$key] = ($this->use_xss_clean == FALSE AND $xss_clean == TRUE) ? $this->xss_clean($array[$key]) : $array[$key]; |
|---|
| 165 | | } |
|---|
| 166 | | else |
|---|
| 167 | | { |
|---|
| 168 | | $data[$key] = NULL; |
|---|
| 169 | | } |
|---|
| 170 | | } |
|---|
| 171 | | |
|---|
| 172 | | // Return the global value |
|---|
| 173 | | return ($return_array) ? $data : current($data); |
|---|
| | 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 | |
|---|
| | 157 | // Get the value from the array |
|---|
| | 158 | $value = isset($array[$key]) ? $array[$key] : $default; |
|---|
| | 159 | |
|---|
| | 160 | if ($xss_clean === TRUE AND $this->use_xss_clean === FALSE) |
|---|
| | 161 | { |
|---|
| | 162 | // XSS clean the value |
|---|
| | 163 | $value = $this->xss_clean($value); |
|---|
| | 164 | } |
|---|
| | 165 | |
|---|
| | 166 | return $value; |
|---|