blob: c86a3cec08ba64381aa86200d8153335367109be [file] [log] [blame]
Derek Jones0b59f272008-05-13 04:22:33 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Derek Allarda72b60d2007-01-31 23:56:11 +00002/**
Derek Allardd2df9bc2007-04-15 17:41:17 +00003 * CodeIgniter
Derek Allarda72b60d2007-01-31 23:56:11 +00004 *
5 * An open source application development framework for PHP 4.3.2 or newer
6 *
7 * @package CodeIgniter
Derek Allard3d879d52008-01-18 19:41:32 +00008 * @author ExpressionEngine Dev Team
Derek Allardd2df9bc2007-04-15 17:41:17 +00009 * @copyright Copyright (c) 2006, EllisLab, Inc.
Derek Jones7a9193a2008-01-21 18:39:20 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
Derek Allarda72b60d2007-01-31 23:56:11 +000012 * @since Version 1.0
13 * @filesource
14 */
15
16// ------------------------------------------------------------------------
17
18/**
19 * Input Class
20 *
21 * Pre-processes global input data for security
22 *
23 * @package CodeIgniter
24 * @subpackage Libraries
25 * @category Input
Derek Allard3d879d52008-01-18 19:41:32 +000026 * @author ExpressionEngine Dev Team
Derek Jones7a9193a2008-01-21 18:39:20 +000027 * @link http://codeigniter.com/user_guide/libraries/input.html
Derek Allarda72b60d2007-01-31 23:56:11 +000028 */
29class CI_Input {
30 var $use_xss_clean = FALSE;
Derek Jones53437de2008-05-12 18:07:08 +000031 var $xss_hash = '';
Derek Allarda72b60d2007-01-31 23:56:11 +000032 var $ip_address = FALSE;
33 var $user_agent = FALSE;
34 var $allow_get_array = FALSE;
Derek Jonese3332b02008-05-13 14:44:32 +000035
36 /* never allowed, string replacement */
37 var $never_allowed_str = array(
38 'document.cookie' => '[removed]',
39 'document.write' => '[removed]',
40 '.parentNode' => '[removed]',
41 '.innerHTML' => '[removed]',
42 'window.location' => '[removed]',
43 '-moz-binding' => '[removed]',
44 '<!--' => '&lt;!--',
45 '-->' => '--&gt;',
46 '<![CDATA[' => '&lt;![CDATA['
47 );
48 /* never allowed, regex replacement */
49 var $never_allowed_regex = array(
50 "javascript\s*:" => '[removed]',
51 "expression\s*\(" => '[removed]', // CSS and IE
52 "Redirect\s+302" => '[removed]'
53 );
54
Derek Allarda72b60d2007-01-31 23:56:11 +000055 /**
56 * Constructor
57 *
58 * Sets whether to globally enable the XSS processing
59 * and whether to allow the $_GET array
60 *
61 * @access public
Derek Allard15dcf492008-05-12 21:37:04 +000062 */
Derek Allarda72b60d2007-01-31 23:56:11 +000063 function CI_Input()
Derek Allard15dcf492008-05-12 21:37:04 +000064 {
Derek Allarda72b60d2007-01-31 23:56:11 +000065 log_message('debug', "Input Class Initialized");
Derek Allard15dcf492008-05-12 21:37:04 +000066
Derek Allarda72b60d2007-01-31 23:56:11 +000067 $CFG =& load_class('Config');
68 $this->use_xss_clean = ($CFG->item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
Derek Allard15dcf492008-05-12 21:37:04 +000069 $this->allow_get_array = ($CFG->item('enable_query_strings') === TRUE) ? TRUE : FALSE;
Derek Allarda72b60d2007-01-31 23:56:11 +000070 $this->_sanitize_globals();
71 }
Derek Allard15dcf492008-05-12 21:37:04 +000072
Derek Allarda72b60d2007-01-31 23:56:11 +000073 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +000074
Derek Allarda72b60d2007-01-31 23:56:11 +000075 /**
76 * Sanitize Globals
77 *
78 * This function does the following:
79 *
80 * Unsets $_GET data (if query strings are not enabled)
81 *
82 * Unsets all globals if register_globals is enabled
83 *
84 * Standardizes newline characters to \n
85 *
86 * @access private
87 * @return void
88 */
89 function _sanitize_globals()
90 {
Derek Jonesd85a11e2008-01-24 20:48:07 +000091 // Would kind of be "wrong" to unset any of these GLOBALS
92 $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST', '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
93 'system_folder', 'application_folder', 'BM', 'EXT', 'CFG', 'URI', 'RTR', 'OUT', 'IN');
Derek Allard15dcf492008-05-12 21:37:04 +000094
Derek Jones0ea06fd2008-02-05 15:23:51 +000095 // Unset globals for security.
Rick Ellisbb2041d2007-06-09 00:16:13 +000096 // This is effectively the same as register_globals = off
Derek Jones0ea06fd2008-02-05 15:23:51 +000097 foreach (array($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, (isset($_SESSION) && is_array($_SESSION)) ? $_SESSION : array()) as $global)
Derek Allarda72b60d2007-01-31 23:56:11 +000098 {
Derek Jones0b59f272008-05-13 04:22:33 +000099 if ( ! is_array($global))
Derek Allarda72b60d2007-01-31 23:56:11 +0000100 {
Derek Jones0b59f272008-05-13 04:22:33 +0000101 if ( ! in_array($global, $protected))
paulburdick8816aaa2007-06-27 23:07:36 +0000102 {
Derek Jones0ea06fd2008-02-05 15:23:51 +0000103 unset($GLOBALS[$global]);
paulburdick8816aaa2007-06-27 23:07:36 +0000104 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000105 }
106 else
107 {
108 foreach ($global as $key => $val)
109 {
Derek Jones0b59f272008-05-13 04:22:33 +0000110 if ( ! in_array($key, $protected))
paulburdick8816aaa2007-06-27 23:07:36 +0000111 {
Derek Jones0ea06fd2008-02-05 15:23:51 +0000112 unset($GLOBALS[$key]);
113 }
Derek Allard15dcf492008-05-12 21:37:04 +0000114
Derek Jones0ea06fd2008-02-05 15:23:51 +0000115 if (is_array($val))
116 {
117 foreach($val as $k => $v)
118 {
Derek Jones0b59f272008-05-13 04:22:33 +0000119 if ( ! in_array($k, $protected))
Derek Jones0ea06fd2008-02-05 15:23:51 +0000120 {
121 unset($GLOBALS[$k]);
122 }
123 }
paulburdick8816aaa2007-06-27 23:07:36 +0000124 }
Derek Allard15dcf492008-05-12 21:37:04 +0000125 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000126 }
127 }
128
129 // Is $_GET data allowed? If not we'll set the $_GET to an empty array
130 if ($this->allow_get_array == FALSE)
131 {
132 $_GET = array();
133 }
Rick Ellis112569d2007-02-26 19:19:08 +0000134 else
135 {
136 if (is_array($_GET) AND count($_GET) > 0)
137 {
138 foreach($_GET as $key => $val)
139 {
140 $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
141 }
142 }
143 }
Derek Allard15dcf492008-05-12 21:37:04 +0000144
Derek Allarda72b60d2007-01-31 23:56:11 +0000145 // Clean $_POST Data
146 if (is_array($_POST) AND count($_POST) > 0)
147 {
148 foreach($_POST as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000149 {
Derek Allarda72b60d2007-01-31 23:56:11 +0000150 $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
Derek Allard15dcf492008-05-12 21:37:04 +0000151 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000152 }
Derek Allard15dcf492008-05-12 21:37:04 +0000153
Derek Allarda72b60d2007-01-31 23:56:11 +0000154 // Clean $_COOKIE Data
155 if (is_array($_COOKIE) AND count($_COOKIE) > 0)
156 {
157 foreach($_COOKIE as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000158 {
Derek Allarda72b60d2007-01-31 23:56:11 +0000159 $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
Derek Allard15dcf492008-05-12 21:37:04 +0000160 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000161 }
Derek Allard15dcf492008-05-12 21:37:04 +0000162
Derek Allarda72b60d2007-01-31 23:56:11 +0000163 log_message('debug', "Global POST and COOKIE data sanitized");
Derek Allard15dcf492008-05-12 21:37:04 +0000164 }
165
Derek Allarda72b60d2007-01-31 23:56:11 +0000166 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000167
Derek Allarda72b60d2007-01-31 23:56:11 +0000168 /**
169 * Clean Input Data
170 *
171 * This is a helper function. It escapes data and
172 * standardizes newline characters to \n
173 *
174 * @access private
175 * @param string
176 * @return string
Derek Allard15dcf492008-05-12 21:37:04 +0000177 */
Derek Allarda72b60d2007-01-31 23:56:11 +0000178 function _clean_input_data($str)
179 {
180 if (is_array($str))
181 {
182 $new_array = array();
183 foreach ($str as $key => $val)
184 {
185 $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
186 }
187 return $new_array;
188 }
Derek Allard15dcf492008-05-12 21:37:04 +0000189
Rick Ellisbb2041d2007-06-09 00:16:13 +0000190 // We strip slashes if magic quotes is on to keep things consistent
191 if (get_magic_quotes_gpc())
192 {
193 $str = stripslashes($str);
194 }
Derek Allard15dcf492008-05-12 21:37:04 +0000195
Rick Ellisbb2041d2007-06-09 00:16:13 +0000196 // Should we filter the input data?
Derek Allarda72b60d2007-01-31 23:56:11 +0000197 if ($this->use_xss_clean === TRUE)
198 {
199 $str = $this->xss_clean($str);
200 }
Derek Allard15dcf492008-05-12 21:37:04 +0000201
Derek Allarda72b60d2007-01-31 23:56:11 +0000202 // Standardize newlines
Derek Jones0b59f272008-05-13 04:22:33 +0000203 if (strpos($str, "\r") !== FALSE)
204 {
205 $str = str_replace(array("\r\n", "\r"), "\n", $str);
206 }
207
208 return $str;
Derek Allarda72b60d2007-01-31 23:56:11 +0000209 }
Derek Allard15dcf492008-05-12 21:37:04 +0000210
Derek Allarda72b60d2007-01-31 23:56:11 +0000211 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000212
Derek Allarda72b60d2007-01-31 23:56:11 +0000213 /**
214 * Clean Keys
215 *
216 * This is a helper function. To prevent malicious users
217 * from trying to exploit keys we make sure that keys are
218 * only named with alpha-numeric text and a few other items.
219 *
220 * @access private
221 * @param string
222 * @return string
223 */
224 function _clean_input_keys($str)
Derek Allard15dcf492008-05-12 21:37:04 +0000225 {
Derek Jones0b59f272008-05-13 04:22:33 +0000226 if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
Derek Allarda72b60d2007-01-31 23:56:11 +0000227 {
228 exit('Disallowed Key Characters.');
229 }
Rick Ellisbb2041d2007-06-09 00:16:13 +0000230
Derek Allarda72b60d2007-01-31 23:56:11 +0000231 return $str;
232 }
Rick Ellis112569d2007-02-26 19:19:08 +0000233
234 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000235
Rick Ellis112569d2007-02-26 19:19:08 +0000236 /**
237 * Fetch an item from the GET array
238 *
239 * @access public
240 * @param string
241 * @param bool
242 * @return string
243 */
Derek Allard87d1eeb2007-03-01 13:20:43 +0000244 function get($index = '', $xss_clean = FALSE)
Derek Allard15dcf492008-05-12 21:37:04 +0000245 {
Derek Jones0b59f272008-05-13 04:22:33 +0000246 if ( ! isset($_GET[$index]))
Rick Ellis112569d2007-02-26 19:19:08 +0000247 {
248 return FALSE;
249 }
250
251 if ($xss_clean === TRUE)
252 {
253 if (is_array($_GET[$index]))
254 {
255 foreach($_GET[$index] as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000256 {
Rick Ellis112569d2007-02-26 19:19:08 +0000257 $_GET[$index][$key] = $this->xss_clean($val);
258 }
259 }
260 else
261 {
262 return $this->xss_clean($_GET[$index]);
263 }
264 }
265
266 return $_GET[$index];
267 }
Derek Allard15dcf492008-05-12 21:37:04 +0000268
Derek Allarda72b60d2007-01-31 23:56:11 +0000269 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000270
Derek Allarda72b60d2007-01-31 23:56:11 +0000271 /**
272 * Fetch an item from the POST array
273 *
274 * @access public
275 * @param string
276 * @param bool
277 * @return string
278 */
279 function post($index = '', $xss_clean = FALSE)
Derek Allard15dcf492008-05-12 21:37:04 +0000280 {
Derek Jones0b59f272008-05-13 04:22:33 +0000281 if ( ! isset($_POST[$index]))
Derek Allarda72b60d2007-01-31 23:56:11 +0000282 {
283 return FALSE;
284 }
285
286 if ($xss_clean === TRUE)
287 {
288 if (is_array($_POST[$index]))
289 {
290 foreach($_POST[$index] as $key => $val)
Derek Allard15dcf492008-05-12 21:37:04 +0000291 {
Derek Allarda72b60d2007-01-31 23:56:11 +0000292 $_POST[$index][$key] = $this->xss_clean($val);
293 }
294 }
295 else
296 {
297 return $this->xss_clean($_POST[$index]);
298 }
299 }
300
301 return $_POST[$index];
302 }
Derek Allard15dcf492008-05-12 21:37:04 +0000303
Derek Allarda72b60d2007-01-31 23:56:11 +0000304 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000305
Derek Allarda72b60d2007-01-31 23:56:11 +0000306 /**
307 * Fetch an item from the COOKIE array
308 *
309 * @access public
310 * @param string
311 * @param bool
312 * @return string
313 */
314 function cookie($index = '', $xss_clean = FALSE)
315 {
Derek Jones0b59f272008-05-13 04:22:33 +0000316 if ( ! isset($_COOKIE[$index]))
Derek Allarda72b60d2007-01-31 23:56:11 +0000317 {
318 return FALSE;
319 }
320
321 if ($xss_clean === TRUE)
322 {
323 if (is_array($_COOKIE[$index]))
324 {
325 $cookie = array();
326 foreach($_COOKIE[$index] as $key => $val)
327 {
328 $cookie[$key] = $this->xss_clean($val);
329 }
Derek Allard15dcf492008-05-12 21:37:04 +0000330
Derek Allarda72b60d2007-01-31 23:56:11 +0000331 return $cookie;
332 }
333 else
334 {
335 return $this->xss_clean($_COOKIE[$index]);
336 }
337 }
338 else
339 {
340 return $_COOKIE[$index];
341 }
342 }
343
344 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000345
Derek Allarda72b60d2007-01-31 23:56:11 +0000346 /**
347 * Fetch an item from the SERVER array
348 *
349 * @access public
350 * @param string
351 * @param bool
352 * @return string
353 */
354 function server($index = '', $xss_clean = FALSE)
Derek Allard15dcf492008-05-12 21:37:04 +0000355 {
Derek Jones0b59f272008-05-13 04:22:33 +0000356 if ( ! isset($_SERVER[$index]))
Derek Allarda72b60d2007-01-31 23:56:11 +0000357 {
358 return FALSE;
359 }
360
361 if ($xss_clean === TRUE)
362 {
363 return $this->xss_clean($_SERVER[$index]);
364 }
Derek Allard15dcf492008-05-12 21:37:04 +0000365
Derek Allarda72b60d2007-01-31 23:56:11 +0000366 return $_SERVER[$index];
367 }
Derek Allard15dcf492008-05-12 21:37:04 +0000368
Derek Allarda72b60d2007-01-31 23:56:11 +0000369 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000370
Derek Allarda72b60d2007-01-31 23:56:11 +0000371 /**
372 * Fetch the IP Address
373 *
374 * @access public
375 * @return string
376 */
377 function ip_address()
378 {
379 if ($this->ip_address !== FALSE)
380 {
381 return $this->ip_address;
382 }
Derek Allard15dcf492008-05-12 21:37:04 +0000383
Derek Allarda72b60d2007-01-31 23:56:11 +0000384 if ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
385 {
386 $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
387 }
388 elseif ($this->server('REMOTE_ADDR'))
389 {
390 $this->ip_address = $_SERVER['REMOTE_ADDR'];
391 }
392 elseif ($this->server('HTTP_CLIENT_IP'))
393 {
394 $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
395 }
396 elseif ($this->server('HTTP_X_FORWARDED_FOR'))
397 {
398 $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
399 }
Derek Allard15dcf492008-05-12 21:37:04 +0000400
Derek Allarda72b60d2007-01-31 23:56:11 +0000401 if ($this->ip_address === FALSE)
402 {
403 $this->ip_address = '0.0.0.0';
404 return $this->ip_address;
405 }
Derek Allard15dcf492008-05-12 21:37:04 +0000406
Derek Allarda72b60d2007-01-31 23:56:11 +0000407 if (strstr($this->ip_address, ','))
408 {
409 $x = explode(',', $this->ip_address);
410 $this->ip_address = end($x);
411 }
Derek Allard15dcf492008-05-12 21:37:04 +0000412
Derek Jones0b59f272008-05-13 04:22:33 +0000413 if ( ! $this->valid_ip($this->ip_address))
Derek Allarda72b60d2007-01-31 23:56:11 +0000414 {
415 $this->ip_address = '0.0.0.0';
416 }
Derek Allard15dcf492008-05-12 21:37:04 +0000417
Derek Allarda72b60d2007-01-31 23:56:11 +0000418 return $this->ip_address;
419 }
Derek Allard15dcf492008-05-12 21:37:04 +0000420
Derek Allarda72b60d2007-01-31 23:56:11 +0000421 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000422
Derek Allarda72b60d2007-01-31 23:56:11 +0000423 /**
424 * Validate IP Address
425 *
Rick Ellise666afc2007-06-11 05:03:11 +0000426 * Updated version suggested by Geert De Deckere
427 *
Derek Allarda72b60d2007-01-31 23:56:11 +0000428 * @access public
429 * @param string
430 * @return string
431 */
432 function valid_ip($ip)
433 {
Rick Ellise666afc2007-06-11 05:03:11 +0000434 $ip_segments = explode('.', $ip);
Derek Allard15dcf492008-05-12 21:37:04 +0000435
Rick Ellise666afc2007-06-11 05:03:11 +0000436 // Always 4 segments needed
437 if (count($ip_segments) != 4)
Rick Ellis112569d2007-02-26 19:19:08 +0000438 {
439 return FALSE;
440 }
Rick Ellis65e8f0e2007-06-12 03:53:21 +0000441 // IP can not start with 0
Rick Ellis39213142007-06-12 03:53:12 +0000442 if (substr($ip_segments[0], 0, 1) == '0')
Rick Ellis112569d2007-02-26 19:19:08 +0000443 {
Rick Ellise666afc2007-06-11 05:03:11 +0000444 return FALSE;
445 }
446 // Check each segment
447 foreach ($ip_segments as $segment)
448 {
449 // IP segments must be digits and can not be
450 // longer than 3 digits or greater then 255
Rick Ellisba648932007-06-12 03:39:38 +0000451 if (preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
Rick Ellis112569d2007-02-26 19:19:08 +0000452 {
Rick Ellise666afc2007-06-11 05:03:11 +0000453 return FALSE;
Rick Ellis112569d2007-02-26 19:19:08 +0000454 }
455 }
Derek Allard15dcf492008-05-12 21:37:04 +0000456
Rick Ellis112569d2007-02-26 19:19:08 +0000457 return TRUE;
Derek Allarda72b60d2007-01-31 23:56:11 +0000458 }
Derek Allard15dcf492008-05-12 21:37:04 +0000459
Derek Allarda72b60d2007-01-31 23:56:11 +0000460 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000461
Derek Allarda72b60d2007-01-31 23:56:11 +0000462 /**
463 * User Agent
464 *
465 * @access public
466 * @return string
467 */
468 function user_agent()
469 {
470 if ($this->user_agent !== FALSE)
471 {
472 return $this->user_agent;
473 }
Derek Allard15dcf492008-05-12 21:37:04 +0000474
Derek Jones0b59f272008-05-13 04:22:33 +0000475 $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
Derek Allard15dcf492008-05-12 21:37:04 +0000476
Derek Allarda72b60d2007-01-31 23:56:11 +0000477 return $this->user_agent;
478 }
Derek Allard15dcf492008-05-12 21:37:04 +0000479
Derek Allarda72b60d2007-01-31 23:56:11 +0000480 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000481
Derek Allarda72b60d2007-01-31 23:56:11 +0000482 /**
paulburdick763064b2007-06-27 23:25:55 +0000483 * Filename Security
484 *
485 * @access public
486 * @param string
487 * @return string
488 */
489 function filename_security($str)
490 {
491 $bad = array(
492 "../",
493 "./",
494 "<!--",
495 "-->",
496 "<",
497 ">",
498 "'",
499 '"',
500 '&',
501 '$',
502 '#',
503 '{',
504 '}',
505 '[',
506 ']',
507 '=',
508 ';',
509 '?',
paulburdick763064b2007-06-27 23:25:55 +0000510 "%20",
511 "%22",
512 "%3c", // <
513 "%253c", // <
514 "%3e", // >
515 "%0e", // >
516 "%28", // (
517 "%29", // )
518 "%2528", // (
519 "%26", // &
520 "%24", // $
521 "%3f", // ?
522 "%3b", // ;
523 "%3d" // =
Derek Allard15dcf492008-05-12 21:37:04 +0000524 );
525
526 return stripslashes(str_replace($bad, '', $str));
paulburdick763064b2007-06-27 23:25:55 +0000527 }
Derek Allard15dcf492008-05-12 21:37:04 +0000528
paulburdick763064b2007-06-27 23:25:55 +0000529 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000530
paulburdick763064b2007-06-27 23:25:55 +0000531 /**
Derek Allarda72b60d2007-01-31 23:56:11 +0000532 * XSS Clean
533 *
534 * Sanitizes data so that Cross Site Scripting Hacks can be
535 * prevented.  This function does a fair amount of work but
536 * it is extremely thorough, designed to prevent even the
537 * most obscure XSS attempts.  Nothing is ever 100% foolproof,
538 * of course, but I haven't been able to get anything passed
539 * the filter.
540 *
541 * Note: This function should only be used to deal with data
542 * upon submission.  It's not something that should
543 * be used for general runtime processing.
544 *
545 * This function was based in part on some code and ideas I
546 * got from Bitflux: http://blog.bitflux.ch/wiki/XSS_Prevention
547 *
548 * To help develop this script I used this great list of
549 * vulnerabilities along with a few other hacks I've
550 * harvested from examining vulnerabilities in other programs:
551 * http://ha.ckers.org/xss.html
552 *
553 * @access public
554 * @param string
555 * @return string
556 */
Derek Jones303c9cb2007-07-12 19:12:37 +0000557 function xss_clean($str)
Derek Jones53437de2008-05-12 18:07:08 +0000558 {
559 /*
560 * Is the string an array?
561 *
562 */
563 if (is_array($str))
564 {
565 while (list($key) = each($str))
566 {
567 $str[$key] = $this->xss_clean($str[$key]);
568 }
Derek Allard15dcf492008-05-12 21:37:04 +0000569
Derek Jones53437de2008-05-12 18:07:08 +0000570 return $str;
571 }
Derek Allard15dcf492008-05-12 21:37:04 +0000572
Derek Allarda72b60d2007-01-31 23:56:11 +0000573 /*
574 * Remove Null Characters
575 *
576 * This prevents sandwiching null characters
577 * between ascii characters, like Java\0script.
578 *
579 */
580 $str = preg_replace('/\0+/', '', $str);
581 $str = preg_replace('/(\\\\0)+/', '', $str);
582
583 /*
Derek Jones53437de2008-05-12 18:07:08 +0000584 * Protect GET variables in URLs
585 */
586
587 // 901119URL5918AMP18930PROTECT8198
588
589 $str = preg_replace('|\&([a-z\_0-9]+)\=([a-z\_0-9]+)|i', $this->xss_hash()."\\1=\\2", $str);
590
591 /*
Derek Allarda72b60d2007-01-31 23:56:11 +0000592 * Validate standard character entities
593 *
594 * Add a semicolon if missing. We do this to enable
595 * the conversion of entities to ASCII later.
596 *
597 */
Derek Jones48bb32a2007-07-12 13:10:42 +0000598 $str = preg_replace('#(&\#?[0-9a-z]+)[\x00-\x20]*;?#i', "\\1;", $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000599
Derek Allarda72b60d2007-01-31 23:56:11 +0000600 /*
Derek Jones48bb32a2007-07-12 13:10:42 +0000601 * Validate UTF16 two byte encoding (x00)
Derek Allarda72b60d2007-01-31 23:56:11 +0000602 *
603 * Just as above, adds a semicolon if missing.
604 *
605 */
Derek Jones48bb32a2007-07-12 13:10:42 +0000606 $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str);
Derek Allarda72b60d2007-01-31 23:56:11 +0000607
608 /*
Derek Jones53437de2008-05-12 18:07:08 +0000609 * Un-Protect GET variables in URLs
610 */
611
612 $str = str_replace($this->xss_hash(), '&', $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000613
Derek Jones53437de2008-05-12 18:07:08 +0000614 /*
Derek Allarda72b60d2007-01-31 23:56:11 +0000615 * URL Decode
616 *
617 * Just in case stuff like this is submitted:
618 *
619 * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
620 *
Derek Jonesab32a422008-02-04 22:02:11 +0000621 * Note: Use rawurldecode() so it does not remove plus signs
Derek Allarda72b60d2007-01-31 23:56:11 +0000622 *
Derek Allard15dcf492008-05-12 21:37:04 +0000623 */
Derek Jonesab32a422008-02-04 22:02:11 +0000624 $str = rawurldecode($str);
Derek Allard15dcf492008-05-12 21:37:04 +0000625
Derek Allarda72b60d2007-01-31 23:56:11 +0000626 /*
Derek Jones303c9cb2007-07-12 19:12:37 +0000627 * Convert character entities to ASCII
Derek Allarda72b60d2007-01-31 23:56:11 +0000628 *
629 * This permits our tests below to work reliably.
630 * We only convert entities that are within tags since
631 * these are the ones that will pose security problems.
632 *
633 */
Derek Allard15dcf492008-05-12 21:37:04 +0000634
Derek Jones303c9cb2007-07-12 19:12:37 +0000635 $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_attribute_conversion'), $str);
636
637 $str = preg_replace_callback("/<([\w]+)[^>]*>/si", array($this, '_html_entity_decode_callback'), $str);
638
639 /*
Derek Allard15dcf492008-05-12 21:37:04 +0000640
Derek Jones303c9cb2007-07-12 19:12:37 +0000641 Old Code that when modified to use preg_replace()'s above became more efficient memory-wise
Derek Allard15dcf492008-05-12 21:37:04 +0000642
Derek Jones303c9cb2007-07-12 19:12:37 +0000643 if (preg_match_all("/[a-z]+=([\'\"]).*?\\1/si", $str, $matches))
644 {
645 for ($i = 0; $i < count($matches[0]); $i++)
Derek Allarda72b60d2007-01-31 23:56:11 +0000646 {
Derek Jones303c9cb2007-07-12 19:12:37 +0000647 if (stristr($matches[0][$i], '>'))
648 {
649 $str = str_replace( $matches['0'][$i],
650 str_replace('>', '&lt;', $matches[0][$i]),
651 $str);
652 }
653 }
654 }
655
656 if (preg_match_all("/<([\w]+)[^>]*>/si", $str, $matches))
657 {
658 for ($i = 0; $i < count($matches[0]); $i++)
659 {
660 $str = str_replace($matches[0][$i],
661 $this->_html_entity_decode($matches[0][$i], $charset),
Derek Allarda72b60d2007-01-31 23:56:11 +0000662 $str);
663 }
664 }
Derek Jones303c9cb2007-07-12 19:12:37 +0000665 */
Derek Allard15dcf492008-05-12 21:37:04 +0000666
Derek Jones48bb32a2007-07-12 13:10:42 +0000667 /*
668 * Convert all tabs to spaces
669 *
670 * This prevents strings like this: ja vascript
671 * NOTE: we deal with spaces between characters later.
672 * NOTE: preg_replace was found to be amazingly slow here on large blocks of data,
673 * so we use str_replace.
674 *
675 */
Derek Allard15dcf492008-05-12 21:37:04 +0000676
Derek Jones0b59f272008-05-13 04:22:33 +0000677 if (strpos($str, "\t") !== FALSE)
678 {
679 $str = str_replace("\t", ' ', $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000680 }
Derek Jones48bb32a2007-07-12 13:10:42 +0000681
Derek Allarda72b60d2007-01-31 23:56:11 +0000682 /*
683 * Not Allowed Under Any Conditions
Derek Allard15dcf492008-05-12 21:37:04 +0000684 */
Derek Jonese3332b02008-05-13 14:44:32 +0000685
686 foreach ($this->never_allowed_str as $key => $val)
Derek Jones48bb32a2007-07-12 13:10:42 +0000687 {
688 $str = str_replace($key, $val, $str);
689 }
Derek Jonese3332b02008-05-13 14:44:32 +0000690
691 foreach ($this->never_allowed_regex as $key => $val)
Derek Allarda72b60d2007-01-31 23:56:11 +0000692 {
693 $str = preg_replace("#".$key."#i", $val, $str);
694 }
Derek Allard15dcf492008-05-12 21:37:04 +0000695
Derek Allarda72b60d2007-01-31 23:56:11 +0000696 /*
Derek Allarda72b60d2007-01-31 23:56:11 +0000697 * Makes PHP tags safe
698 *
699 * Note: XML tags are inadvertently replaced too:
700 *
701 * <?xml
702 *
703 * But it doesn't seem to pose a problem.
704 *
Derek Allard15dcf492008-05-12 21:37:04 +0000705 */
Derek Jones48bb32a2007-07-12 13:10:42 +0000706 $str = str_replace(array('<?php', '<?PHP', '<?', '?'.'>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000707
Derek Allarda72b60d2007-01-31 23:56:11 +0000708 /*
709 * Compact any exploded words
710 *
711 * This corrects words like: j a v a s c r i p t
712 * These words are compacted back to their correct state.
713 *
Derek Allard15dcf492008-05-12 21:37:04 +0000714 */
paulburdickb614d392007-06-26 21:58:56 +0000715 $words = array('javascript', 'expression', 'vbscript', 'script', 'applet', 'alert', 'document', 'write', 'cookie', 'window');
Derek Allarda72b60d2007-01-31 23:56:11 +0000716 foreach ($words as $word)
717 {
718 $temp = '';
719 for ($i = 0; $i < strlen($word); $i++)
720 {
721 $temp .= substr($word, $i, 1)."\s*";
722 }
Derek Allard15dcf492008-05-12 21:37:04 +0000723
Derek Jones01f72ca2007-05-04 18:19:17 +0000724 // We only want to do this when it is followed by a non-word character
725 // That way valid stuff like "dealer to" does not become "dealerto"
726 $str = preg_replace('#('.substr($temp, 0, -3).')(\W)#ise', "preg_replace('/\s+/s', '', '\\1').'\\2'", $str);
Derek Allarda72b60d2007-01-31 23:56:11 +0000727 }
Derek Allard15dcf492008-05-12 21:37:04 +0000728
Derek Allarda72b60d2007-01-31 23:56:11 +0000729 /*
730 * Remove disallowed Javascript in links or img tags
paulburdick391eb032007-06-27 22:58:24 +0000731 */
732 do
733 {
734 $original = $str;
Derek Allard15dcf492008-05-12 21:37:04 +0000735
Derek Jones48bb32a2007-07-12 13:10:42 +0000736 if ((version_compare(PHP_VERSION, '5.0', '>=') === TRUE && stripos($str, '</a>') !== FALSE) OR
737 preg_match("/<\/a>/i", $str))
738 {
739 $str = preg_replace_callback("#<a.*?</a>#si", array($this, '_js_link_removal'), $str);
740 }
Derek Allard15dcf492008-05-12 21:37:04 +0000741
Derek Jones48bb32a2007-07-12 13:10:42 +0000742 if ((version_compare(PHP_VERSION, '5.0', '>=') === TRUE && stripos($str, '<img') !== FALSE) OR
743 preg_match("/img/i", $str))
744 {
745 $str = preg_replace_callback("#<img.*?".">#si", array($this, '_js_img_removal'), $str);
746 }
Derek Allard15dcf492008-05-12 21:37:04 +0000747
Derek Jones48bb32a2007-07-12 13:10:42 +0000748 if ((version_compare(PHP_VERSION, '5.0', '>=') === TRUE && (stripos($str, 'script') !== FALSE OR stripos($str, 'xss') !== FALSE)) OR
749 preg_match("/(script|xss)/i", $str))
750 {
751 $str = preg_replace("#</*(script|xss).*?\>#si", "", $str);
752 }
paulburdick391eb032007-06-27 22:58:24 +0000753 }
754 while($original != $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000755
paulburdick391eb032007-06-27 22:58:24 +0000756 unset($original);
Derek Allarda72b60d2007-01-31 23:56:11 +0000757
758 /*
759 * Remove JavaScript Event Handlers
760 *
761 * Note: This code is a little blunt. It removes
762 * the event handler and anything up to the closing >,
763 * but it's unlikely to be a problem.
764 *
Derek Allard15dcf492008-05-12 21:37:04 +0000765 */
Derek Jones01f72ca2007-05-04 18:19:17 +0000766 $event_handlers = array('onblur','onchange','onclick','onfocus','onload','onmouseover','onmouseup','onmousedown','onselect','onsubmit','onunload','onkeypress','onkeydown','onkeyup','onresize', 'xmlns');
767 $str = preg_replace("#<([^>]+)(".implode('|', $event_handlers).")([^>]*)>#iU", "&lt;\\1\\2\\3&gt;", $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000768
Derek Allarda72b60d2007-01-31 23:56:11 +0000769 /*
770 * Sanitize naughty HTML elements
771 *
772 * If a tag containing any of the words in the list
773 * below is found, the tag gets converted to entities.
774 *
775 * So this: <blink>
776 * Becomes: &lt;blink&gt;
777 *
Derek Allard15dcf492008-05-12 21:37:04 +0000778 */
Derek Jonese3332b02008-05-13 14:44:32 +0000779 $naughty = 'alert|applet|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|layer|link|meta|object|plaintext|style|script|textarea|title|xml|xss';
780 $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000781
Derek Allarda72b60d2007-01-31 23:56:11 +0000782 /*
783 * Sanitize naughty scripting elements
784 *
785 * Similar to above, only instead of looking for
786 * tags it looks for PHP and JavaScript commands
787 * that are disallowed. Rather than removing the
788 * code, it simply converts the parenthesis to entities
789 * rendering the code un-executable.
790 *
791 * For example: eval('some code')
792 * Becomes: eval&#40;'some code'&#41;
793 *
794 */
paulburdick033ef022007-06-26 21:52:52 +0000795 $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $str);
Derek Allard15dcf492008-05-12 21:37:04 +0000796
Derek Allarda72b60d2007-01-31 23:56:11 +0000797 /*
798 * Final clean up
799 *
800 * This adds a bit of extra precaution in case
801 * something got through the above filters
802 *
Derek Allard15dcf492008-05-12 21:37:04 +0000803 */
Derek Allarda72b60d2007-01-31 23:56:11 +0000804 $bad = array(
805 'document.cookie' => '[removed]',
Derek Jones48bb32a2007-07-12 13:10:42 +0000806 'document.write' => '[removed]',
paulburdick033ef022007-06-26 21:52:52 +0000807 '.parentNode' => '[removed]',
808 '.innerHTML' => '[removed]',
Derek Allarda72b60d2007-01-31 23:56:11 +0000809 'window.location' => '[removed]',
Derek Jones48bb32a2007-07-12 13:10:42 +0000810 '-moz-binding' => '[removed]',
Derek Allarda72b60d2007-01-31 23:56:11 +0000811 '<!--' => '&lt;!--',
Derek Jones48bb32a2007-07-12 13:10:42 +0000812 '-->' => '--&gt;',
Derek Jonese3332b02008-05-13 14:44:32 +0000813 '<![CDATA[' => '&lt;![CDATA['
Derek Allarda72b60d2007-01-31 23:56:11 +0000814 );
Derek Jones48bb32a2007-07-12 13:10:42 +0000815
Derek Allarda72b60d2007-01-31 23:56:11 +0000816 foreach ($bad as $key => $val)
817 {
Derek Jones48bb32a2007-07-12 13:10:42 +0000818 $str = str_replace($key, $val, $str);
819 }
820
821 $bad = array(
822 "javascript\s*:" => '[removed]',
823 "expression\s*\(" => '[removed]', // CSS and IE
824 "Redirect\s+302" => '[removed]'
825 );
Derek Allard15dcf492008-05-12 21:37:04 +0000826
Derek Jones48bb32a2007-07-12 13:10:42 +0000827 foreach ($bad as $key => $val)
828 {
829 $str = preg_replace("#".$key."#i", $val, $str);
Derek Allarda72b60d2007-01-31 23:56:11 +0000830 }
Derek Allard15dcf492008-05-12 21:37:04 +0000831
832
Derek Allarda72b60d2007-01-31 23:56:11 +0000833 log_message('debug', "XSS Filtering completed");
834 return $str;
835 }
836
837 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000838
Derek Jones01f72ca2007-05-04 18:19:17 +0000839 /**
Derek Jones53437de2008-05-12 18:07:08 +0000840 * Random Hash for protecting URLs
841 *
842 * @access public
843 * @return string
844 */
845 function xss_hash()
Derek Allard15dcf492008-05-12 21:37:04 +0000846 {
Derek Jones53437de2008-05-12 18:07:08 +0000847 if ($this->xss_hash == '')
848 {
849 if (phpversion() >= 4.2)
850 mt_srand();
851 else
852 mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
Derek Allard15dcf492008-05-12 21:37:04 +0000853
Derek Jones53437de2008-05-12 18:07:08 +0000854 $this->xss_hash = md5(time() + mt_rand(0, 1999999999));
855 }
Derek Allard15dcf492008-05-12 21:37:04 +0000856
Derek Jones53437de2008-05-12 18:07:08 +0000857 return $this->xss_hash;
858 }
859
860 // --------------------------------------------------------------------
Derek Jonese3332b02008-05-13 14:44:32 +0000861
862 /**
863 * Sanitize Naughty HTML
864 *
865 * Callback function for xss_clean() to remove naughty HTML elements
866 *
867 * @access private
868 * @param array
869 * @return string
870 */
871 function _sanitize_naughty_html($matches)
872 {
873 // encode opening brace
874 $str = '&lt;'.$matches[1].$matches[2].$matches[3];
875
876 // encode captured opening or closing brace to prevent recursive vectors
877 if ($matches[4] == '>')
878 {
879 $str .= '&gt;';
880 }
881 elseif ($matches[4] == '<')
882 {
883 $str .= '&lt;';
884 }
Derek Allard15dcf492008-05-12 21:37:04 +0000885
Derek Jonese3332b02008-05-13 14:44:32 +0000886 return $str;
887 }
888
889 // --------------------------------------------------------------------
890
Derek Jones53437de2008-05-12 18:07:08 +0000891 /**
Derek Jones01f72ca2007-05-04 18:19:17 +0000892 * JS Link Removal
893 *
894 * Callback function for xss_clean() to sanitize links
895 * This limits the PCRE backtracks, making it more performance friendly
896 * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
897 * PHP 5.2+ on link-heavy strings
898 *
899 * @access private
900 * @param array
901 * @return string
902 */
903 function _js_link_removal($match)
904 {
905 return preg_replace("#<a.+?href=.*?(alert\(|alert&\#40;|javascript\:|window\.|document\.|\.cookie|<script|<xss).*?\>.*?</a>#si", "", $match[0]);
906 }
Derek Allard15dcf492008-05-12 21:37:04 +0000907
Derek Jones01f72ca2007-05-04 18:19:17 +0000908 /**
909 * JS Image Removal
910 *
911 * Callback function for xss_clean() to sanitize image tags
912 * This limits the PCRE backtracks, making it more performance friendly
913 * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
914 * PHP 5.2+ on image tag heavy strings
915 *
916 * @access private
917 * @param array
918 * @return string
919 */
920 function _js_img_removal($match)
921 {
922 return preg_replace("#<img.+?src=.*?(alert\(|alert&\#40;|javascript\:|window\.|document\.|\.cookie|<script|<xss).*?\>#si", "", $match[0]);
923 }
Derek Allarda72b60d2007-01-31 23:56:11 +0000924
Derek Jones01f72ca2007-05-04 18:19:17 +0000925 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000926
Derek Jones303c9cb2007-07-12 19:12:37 +0000927 /**
928 * Attribute Conversion
929 *
930 * Used as a callback for XSS Clean
931 *
932 * @access public
933 * @param array
934 * @return string
935 */
936 function _attribute_conversion($match)
937 {
938 return str_replace('>', '&lt;', $match[0]);
939 }
Derek Allard15dcf492008-05-12 21:37:04 +0000940
Derek Jones303c9cb2007-07-12 19:12:37 +0000941 // --------------------------------------------------------------------
942
943 /**
944 * HTML Entity Decode Callback
945 *
946 * Used as a callback for XSS Clean
947 *
948 * @access public
949 * @param array
950 * @return string
951 */
952 function _html_entity_decode_callback($match)
953 {
Derek Jones6159d1d2007-07-16 13:04:46 +0000954 global $CFG;
955 $charset = $CFG->item('charset');
Derek Jones303c9cb2007-07-12 19:12:37 +0000956
957 return $this->_html_entity_decode($match[0], strtoupper($charset));
958 }
959
960 // --------------------------------------------------------------------
Derek Allard15dcf492008-05-12 21:37:04 +0000961
Derek Allarda72b60d2007-01-31 23:56:11 +0000962 /**
963 * HTML Entities Decode
964 *
965 * This function is a replacement for html_entity_decode()
966 *
967 * In some versions of PHP the native function does not work
968 * when UTF-8 is the specified character set, so this gives us
969 * a work-around. More info here:
970 * http://bugs.php.net/bug.php?id=25670
971 *
972 * @access private
973 * @param string
974 * @param string
975 * @return string
976 */
977 /* -------------------------------------------------
978 /* Replacement for html_entity_decode()
979 /* -------------------------------------------------*/
Derek Allard15dcf492008-05-12 21:37:04 +0000980
Derek Allarda72b60d2007-01-31 23:56:11 +0000981 /*
982 NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
983 character set, and the PHP developers said they were not back porting the
984 fix to versions other than PHP 5.x.
985 */
Derek Jones303c9cb2007-07-12 19:12:37 +0000986 function _html_entity_decode($str, $charset='UTF-8')
Derek Allarda72b60d2007-01-31 23:56:11 +0000987 {
988 if (stristr($str, '&') === FALSE) return $str;
Derek Allard15dcf492008-05-12 21:37:04 +0000989
Derek Allarda72b60d2007-01-31 23:56:11 +0000990 // The reason we are not using html_entity_decode() by itself is because
991 // while it is not technically correct to leave out the semicolon
992 // at the end of an entity most browsers will still interpret the entity
993 // correctly. html_entity_decode() does not convert entities without
994 // semicolons, so we are left with our own little solution here. Bummer.
Derek Allard15dcf492008-05-12 21:37:04 +0000995
Derek Allarda72b60d2007-01-31 23:56:11 +0000996 if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR version_compare(phpversion(), '5.0.0', '>=')))
997 {
998 $str = html_entity_decode($str, ENT_COMPAT, $charset);
999 $str = preg_replace('~&#x([0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
1000 return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
1001 }
Derek Allard15dcf492008-05-12 21:37:04 +00001002
Derek Allarda72b60d2007-01-31 23:56:11 +00001003 // Numeric Entities
1004 $str = preg_replace('~&#x([0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
1005 $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
Derek Allard15dcf492008-05-12 21:37:04 +00001006
Derek Allarda72b60d2007-01-31 23:56:11 +00001007 // Literal Entities - Slightly slow so we do another check
1008 if (stristr($str, '&') === FALSE)
1009 {
1010 $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
1011 }
Derek Allard15dcf492008-05-12 21:37:04 +00001012
Derek Allarda72b60d2007-01-31 23:56:11 +00001013 return $str;
1014 }
1015
1016}
1017// END Input class
Derek Jones53437de2008-05-12 18:07:08 +00001018
1019/* End of file Input.php */
Derek Jonesa3ffbbb2008-05-11 18:18:29 +00001020/* Location: ./system/libraries/Input.php */