blob: c2db94d64ca4bf2b1383102a8d063acc1f1e9a69 [file] [log] [blame]
Derek Allard2067d1a2008-11-13 22:59:24 +00001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
Greg Aker741de1c2010-11-10 14:52:57 -06005 * An open source application development framework for PHP 5.1.6 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
7 * @package CodeIgniter
8 * @author ExpressionEngine Dev Team
Greg Aker0711dc82011-01-05 10:49:40 -06009 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
Derek Allard2067d1a2008-11-13 22:59:24 +000010 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
12 * @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
26 * @author ExpressionEngine Dev Team
27 * @link http://codeigniter.com/user_guide/libraries/input.html
28 */
29class CI_Input {
Derek Allard2067d1a2008-11-13 22:59:24 +000030
Derek Jones69fc4fc2010-03-02 13:36:31 -060031 var $ip_address = FALSE;
32 var $user_agent = FALSE;
33 var $_allow_get_array = FALSE;
34 var $_standardize_newlines = TRUE;
35 var $_enable_xss = FALSE; // Set automatically based on config setting
36 var $_enable_csrf = FALSE; // Set automatically based on config setting
37
Greg Akerec2f5712010-11-15 16:22:12 -060038 protected $headers = array();
39
40
Derek Allard2067d1a2008-11-13 22:59:24 +000041 /**
Greg Akera9263282010-11-10 15:26:43 -060042 * Constructor
43 *
44 * Sets whether to globally enable the XSS processing
45 * and whether to allow the $_GET array
46 *
47 */
48 public function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000049 {
50 log_message('debug', "Input Class Initialized");
51
Derek Jones69fc4fc2010-03-02 13:36:31 -060052 $this->_allow_get_array = (config_item('enable_query_strings') === TRUE) ? TRUE : FALSE;
53 $this->_enable_xss = (config_item('global_xss_filtering') === TRUE) ? TRUE : FALSE;
54 $this->_enable_csrf = (config_item('csrf_protection') === TRUE) ? TRUE : FALSE;
55
56 // Do we need to load the security class?
57 if ($this->_enable_xss == TRUE OR $this->_enable_csrf == TRUE)
58 {
59 $this->security =& load_class('Security');
60 }
61
Pascal Krieteaaec1e42011-01-20 00:01:21 -050062 // Do we need the UTF-8 class?
Derek Jones69fc4fc2010-03-02 13:36:31 -060063 if (UTF8_ENABLED === TRUE)
64 {
65 global $UNI;
66 $this->uni =& $UNI;
67 }
68
69 // Sanitize global arrays
Derek Allard2067d1a2008-11-13 22:59:24 +000070 $this->_sanitize_globals();
71 }
72
73 // --------------------------------------------------------------------
74
75 /**
Greg Akera9263282010-11-10 15:26:43 -060076 * Fetch from array
77 *
78 * This is a helper function to retrieve values from global arrays
79 *
80 * @access private
81 * @param array
82 * @param string
83 * @param bool
84 * @return string
85 */
Derek Allard2067d1a2008-11-13 22:59:24 +000086 function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
87 {
88 if ( ! isset($array[$index]))
89 {
90 return FALSE;
91 }
92
93 if ($xss_clean === TRUE)
94 {
Derek Jones69fc4fc2010-03-02 13:36:31 -060095 $_security =& load_class('Security');
96 return $_security->xss_clean($array[$index]);
Derek Allard2067d1a2008-11-13 22:59:24 +000097 }
98
99 return $array[$index];
100 }
101
102 // --------------------------------------------------------------------
103
104 /**
105 * Fetch an item from the GET array
106 *
107 * @access public
108 * @param string
109 * @param bool
110 * @return string
111 */
112 function get($index = '', $xss_clean = FALSE)
113 {
114 return $this->_fetch_from_array($_GET, $index, $xss_clean);
115 }
116
117 // --------------------------------------------------------------------
118
119 /**
120 * Fetch an item from the POST array
121 *
122 * @access public
123 * @param string
124 * @param bool
125 * @return string
126 */
127 function post($index = '', $xss_clean = FALSE)
128 {
129 return $this->_fetch_from_array($_POST, $index, $xss_clean);
130 }
131
Derek Jones69fc4fc2010-03-02 13:36:31 -0600132
Derek Allard2067d1a2008-11-13 22:59:24 +0000133 // --------------------------------------------------------------------
134
135 /**
136 * Fetch an item from either the GET array or the POST
137 *
138 * @access public
139 * @param string The index key
140 * @param bool XSS cleaning
141 * @return string
142 */
143 function get_post($index = '', $xss_clean = FALSE)
144 {
145 if ( ! isset($_POST[$index]) )
146 {
147 return $this->get($index, $xss_clean);
148 }
149 else
150 {
151 return $this->post($index, $xss_clean);
152 }
153 }
154
155 // --------------------------------------------------------------------
156
157 /**
158 * Fetch an item from the COOKIE array
159 *
160 * @access public
161 * @param string
162 * @param bool
163 * @return string
164 */
165 function cookie($index = '', $xss_clean = FALSE)
166 {
167 return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
168 }
169
Derek Jones69fc4fc2010-03-02 13:36:31 -0600170 // ------------------------------------------------------------------------
171
172 /**
173 * Set cookie
174 *
175 * Accepts six parameter, or you can submit an associative
176 * array in the first parameter containing all the values.
177 *
178 * @access public
179 * @param mixed
180 * @param string the value of the cookie
181 * @param string the number of seconds until expiration
182 * @param string the cookie domain. Usually: .yourdomain.com
183 * @param string the cookie path
184 * @param string the cookie prefix
185 * @return void
186 */
187 function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
188 {
189 if (is_array($name))
190 {
191 foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item)
192 {
193 if (isset($name[$item]))
194 {
195 $$item = $name[$item];
196 }
197 }
198 }
199
200 if ($prefix == '' AND config_item('cookie_prefix') != '')
201 {
202 $prefix = config_item('cookie_prefix');
203 }
204 if ($domain == '' AND config_item('cookie_domain') != '')
205 {
206 $domain = config_item('cookie_domain');
207 }
208 if ($path == '/' AND config_item('cookie_path') != '/')
209 {
210 $path = config_item('cookie_path');
211 }
212
213 if ( ! is_numeric($expire))
214 {
215 $expire = time() - 86500;
216 }
217 else
218 {
219 if ($expire > 0)
220 {
221 $expire = time() + $expire;
222 }
223 else
224 {
225 $expire = 0;
226 }
227 }
Robin Sowelld6d9f452011-02-11 15:31:27 -0500228
229 $secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 0;
Derek Jones69fc4fc2010-03-02 13:36:31 -0600230
Robin Sowelld6d9f452011-02-11 15:31:27 -0500231 setcookie($prefix.$name, $value, $expire, $path, $domain, $secure_cookie);
Derek Jones69fc4fc2010-03-02 13:36:31 -0600232 }
233
Derek Allard2067d1a2008-11-13 22:59:24 +0000234 // --------------------------------------------------------------------
235
236 /**
237 * Fetch an item from the SERVER array
238 *
239 * @access public
240 * @param string
241 * @param bool
242 * @return string
243 */
244 function server($index = '', $xss_clean = FALSE)
245 {
246 return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
247 }
248
249 // --------------------------------------------------------------------
250
251 /**
252 * Fetch the IP Address
253 *
254 * @access public
255 * @return string
256 */
257 function ip_address()
258 {
259 if ($this->ip_address !== FALSE)
260 {
261 return $this->ip_address;
262 }
Barry Mienydd671972010-10-04 16:33:58 +0200263
Derek Jones42b2e172009-02-05 16:59:45 +0000264 if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR'))
Derek Jonesc5972282009-02-04 21:40:20 +0000265 {
Derek Jones42b2e172009-02-05 16:59:45 +0000266 $proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY);
Derek Jonesc5972282009-02-04 21:40:20 +0000267 $proxies = is_array($proxies) ? $proxies : array($proxies);
Derek Allard2067d1a2008-11-13 22:59:24 +0000268
Derek Jonesc5972282009-02-04 21:40:20 +0000269 $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
270 }
271 elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
Derek Allard2067d1a2008-11-13 22:59:24 +0000272 {
273 $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
274 }
275 elseif ($this->server('REMOTE_ADDR'))
276 {
277 $this->ip_address = $_SERVER['REMOTE_ADDR'];
278 }
279 elseif ($this->server('HTTP_CLIENT_IP'))
280 {
281 $this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
282 }
283 elseif ($this->server('HTTP_X_FORWARDED_FOR'))
284 {
285 $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
286 }
287
288 if ($this->ip_address === FALSE)
289 {
290 $this->ip_address = '0.0.0.0';
291 return $this->ip_address;
292 }
293
Robin Sowell76b369e2010-03-19 11:15:28 -0400294 if (strpos($this->ip_address, ',') !== FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000295 {
296 $x = explode(',', $this->ip_address);
Derek Jonesc5972282009-02-04 21:40:20 +0000297 $this->ip_address = trim(end($x));
Derek Allard2067d1a2008-11-13 22:59:24 +0000298 }
299
300 if ( ! $this->valid_ip($this->ip_address))
301 {
302 $this->ip_address = '0.0.0.0';
303 }
304
305 return $this->ip_address;
306 }
307
308 // --------------------------------------------------------------------
309
310 /**
311 * Validate IP Address
312 *
313 * Updated version suggested by Geert De Deckere
Barry Mienydd671972010-10-04 16:33:58 +0200314 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000315 * @access public
316 * @param string
317 * @return string
318 */
319 function valid_ip($ip)
320 {
321 $ip_segments = explode('.', $ip);
322
323 // Always 4 segments needed
324 if (count($ip_segments) != 4)
325 {
326 return FALSE;
327 }
328 // IP can not start with 0
329 if ($ip_segments[0][0] == '0')
330 {
331 return FALSE;
332 }
333 // Check each segment
334 foreach ($ip_segments as $segment)
335 {
Barry Mienydd671972010-10-04 16:33:58 +0200336 // IP segments must be digits and can not be
Derek Allard2067d1a2008-11-13 22:59:24 +0000337 // longer than 3 digits or greater then 255
338 if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
339 {
340 return FALSE;
341 }
342 }
343
344 return TRUE;
345 }
346
347 // --------------------------------------------------------------------
348
349 /**
350 * User Agent
351 *
352 * @access public
353 * @return string
354 */
355 function user_agent()
356 {
357 if ($this->user_agent !== FALSE)
358 {
359 return $this->user_agent;
360 }
361
362 $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
363
364 return $this->user_agent;
365 }
366
367 // --------------------------------------------------------------------
368
369 /**
Derek Jones69fc4fc2010-03-02 13:36:31 -0600370 * Sanitize Globals
Derek Allard2067d1a2008-11-13 22:59:24 +0000371 *
Derek Jones69fc4fc2010-03-02 13:36:31 -0600372 * This function does the following:
373 *
374 * Unsets $_GET data (if query strings are not enabled)
375 *
376 * Unsets all globals if register_globals is enabled
377 *
378 * Standardizes newline characters to \n
379 *
380 * @access private
381 * @return void
Derek Allard2067d1a2008-11-13 22:59:24 +0000382 */
Derek Jones69fc4fc2010-03-02 13:36:31 -0600383 function _sanitize_globals()
Derek Allard2067d1a2008-11-13 22:59:24 +0000384 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600385 // It would be "wrong" to unset any of these GLOBALS.
Greg Akerec2f5712010-11-15 16:22:12 -0600386 $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST',
387 '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
388 'system_folder', 'application_folder', 'BM', 'EXT',
389 'CFG', 'URI', 'RTR', 'OUT', 'IN');
Derek Allard2067d1a2008-11-13 22:59:24 +0000390
Barry Mienydd671972010-10-04 16:33:58 +0200391 // Unset globals for securiy.
Derek Jones69fc4fc2010-03-02 13:36:31 -0600392 // This is effectively the same as register_globals = off
393 foreach (array($_GET, $_POST, $_COOKIE) as $global)
Derek Allard2067d1a2008-11-13 22:59:24 +0000394 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600395 if ( ! is_array($global))
Derek Allard2067d1a2008-11-13 22:59:24 +0000396 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600397 if ( ! in_array($global, $protected))
398 {
399 global $$global;
400 $$global = NULL;
401 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000402 }
Derek Jones69fc4fc2010-03-02 13:36:31 -0600403 else
404 {
405 foreach ($global as $key => $val)
406 {
407 if ( ! in_array($key, $protected))
408 {
409 global $$key;
410 $$key = NULL;
411 }
412 }
413 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000414 }
415
Derek Jones69fc4fc2010-03-02 13:36:31 -0600416 // Is $_GET data allowed? If not we'll set the $_GET to an empty array
417 if ($this->_allow_get_array == FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000418 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600419 $_GET = array();
Derek Allard2067d1a2008-11-13 22:59:24 +0000420 }
421 else
422 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600423 if (is_array($_GET) AND count($_GET) > 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000424 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600425 foreach($_GET as $key => $val)
426 {
427 $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
428 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000429 }
430 }
431
Derek Jones69fc4fc2010-03-02 13:36:31 -0600432 // Clean $_POST Data
433 if (is_array($_POST) AND count($_POST) > 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000434 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600435 foreach($_POST as $key => $val)
436 {
437 $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
438 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000439 }
440
Derek Jones69fc4fc2010-03-02 13:36:31 -0600441 // Clean $_COOKIE Data
442 if (is_array($_COOKIE) AND count($_COOKIE) > 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000443 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600444 // Also get rid of specially treated cookies that might be set by a server
445 // or silly application, that are of no use to a CI application anyway
446 // but that when present will trip our 'Disallowed Key Characters' alarm
447 // http://www.ietf.org/rfc/rfc2109.txt
448 // note that the key names below are single quoted strings, and are not PHP variables
449 unset($_COOKIE['$Version']);
450 unset($_COOKIE['$Path']);
451 unset($_COOKIE['$Domain']);
452
453 foreach($_COOKIE as $key => $val)
454 {
455 $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
456 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000457 }
458
Derek Jones69fc4fc2010-03-02 13:36:31 -0600459 // Sanitize PHP_SELF
460 $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
461
462
463 // CSRF Protection check
464 if ($this->_enable_csrf == TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000465 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600466 $this->security->csrf_verify();
Derek Allard2067d1a2008-11-13 22:59:24 +0000467 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000468
Derek Jones69fc4fc2010-03-02 13:36:31 -0600469 log_message('debug', "Global POST and COOKIE data sanitized");
Derek Allard2067d1a2008-11-13 22:59:24 +0000470 }
471
472 // --------------------------------------------------------------------
473
474 /**
Derek Jones69fc4fc2010-03-02 13:36:31 -0600475 * Clean Input Data
Derek Allard2067d1a2008-11-13 22:59:24 +0000476 *
Derek Jones69fc4fc2010-03-02 13:36:31 -0600477 * This is a helper function. It escapes data and
478 * standardizes newline characters to \n
Derek Allard2067d1a2008-11-13 22:59:24 +0000479 *
480 * @access private
481 * @param string
Derek Allard2067d1a2008-11-13 22:59:24 +0000482 * @return string
483 */
Derek Jones69fc4fc2010-03-02 13:36:31 -0600484 function _clean_input_data($str)
Derek Allard2067d1a2008-11-13 22:59:24 +0000485 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600486 if (is_array($str))
Derek Allard2067d1a2008-11-13 22:59:24 +0000487 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600488 $new_array = array();
489 foreach ($str as $key => $val)
490 {
491 $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
492 }
493 return $new_array;
Derek Allard2067d1a2008-11-13 22:59:24 +0000494 }
495
Derek Jones69fc4fc2010-03-02 13:36:31 -0600496 // We strip slashes if magic quotes is on to keep things consistent
497 if (get_magic_quotes_gpc())
Derek Allard2067d1a2008-11-13 22:59:24 +0000498 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600499 $str = stripslashes($str);
500 }
501
502 // Clean UTF-8 if supported
503 if (UTF8_ENABLED === TRUE)
504 {
505 $str = $this->uni->clean_string($str);
506 }
507
508 // Should we filter the input data?
509 if ($this->_enable_xss === TRUE)
510 {
511 $str = $this->security->xss_clean($str);
512 }
513
514 // Standardize newlines if needed
515 if ($this->_standardize_newlines == TRUE)
516 {
517 if (strpos($str, "\r") !== FALSE)
518 {
519 $str = str_replace(array("\r\n", "\r"), "\n", $str);
520 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000521 }
522
523 return $str;
524 }
525
526 // --------------------------------------------------------------------
527
528 /**
Derek Jones69fc4fc2010-03-02 13:36:31 -0600529 * Clean Keys
Derek Allard2067d1a2008-11-13 22:59:24 +0000530 *
Derek Jones69fc4fc2010-03-02 13:36:31 -0600531 * This is a helper function. To prevent malicious users
532 * from trying to exploit keys we make sure that keys are
533 * only named with alpha-numeric text and a few other items.
Derek Allard2067d1a2008-11-13 22:59:24 +0000534 *
Derek Jones69fc4fc2010-03-02 13:36:31 -0600535 * @access private
Derek Allard2067d1a2008-11-13 22:59:24 +0000536 * @param string
537 * @return string
538 */
Derek Jones69fc4fc2010-03-02 13:36:31 -0600539 function _clean_input_keys($str)
Derek Allard2067d1a2008-11-13 22:59:24 +0000540 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600541 if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
Derek Allard2067d1a2008-11-13 22:59:24 +0000542 {
Derek Jones69fc4fc2010-03-02 13:36:31 -0600543 exit('Disallowed Key Characters.');
Derek Allard2067d1a2008-11-13 22:59:24 +0000544 }
545
Derek Jones69fc4fc2010-03-02 13:36:31 -0600546 // Clean UTF-8 if supported
547 if (UTF8_ENABLED === TRUE)
548 {
549 $str = $this->uni->clean_string($str);
550 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000551
Derek Jones69fc4fc2010-03-02 13:36:31 -0600552 return $str;
553 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000554
Greg Akerec2f5712010-11-15 16:22:12 -0600555 // --------------------------------------------------------------------
556
557 /**
558 * Request Headers
559 *
560 * In Apache, you can simply call apache_request_headers(), however for
561 * people running other webservers the function is undefined.
562 *
563 * @return array
564 */
565 public function request_headers($xss_clean = FALSE)
566 {
567 // Look at Apache go!
568 if (function_exists('apache_request_headers'))
569 {
570 $headers = apache_request_headers();
571 }
572 else
573 {
574 $headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
575
576 foreach ($_SERVER as $key => $val)
577 {
578 if (strncmp($key, 'HTTP_', 5) === 0)
579 {
580 $headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean);
581 }
582 }
583 }
584
585 // take SOME_HEADER and turn it into Some-Header
586 foreach ($headers as $key => $val)
587 {
588 $key = str_replace('_', ' ', strtolower($key));
589 $key = str_replace(' ', '-', ucwords($key));
590
591 $this->headers[$key] = $val;
592 }
593
594 return $this->headers;
595 }
596
597 // --------------------------------------------------------------------
598
599 /**
600 * Get Request Header
601 *
602 * Returns the value of a single member of the headers class member
603 *
604 * @param string array key for $this->headers
605 * @param boolean XSS Clean or not
606 * @return mixed FALSE on failure, string on success
607 */
608 public function get_request_header($index, $xss_clean = FALSE)
609 {
610 if (empty($this->headers))
611 {
612 $this->request_headers();
613 }
614
615 if ( ! isset($this->headers[$index]))
616 {
617 return FALSE;
618 }
619
620 if ($xss_clean === TRUE)
621 {
622 $_security =& load_class('Security');
623 return $_security->xss_clean($this->headers[$index]);
624 }
625
626 return $this->headers[$index];
627 }
628
Greg Aker081ac9d2010-11-22 14:42:53 -0600629 // --------------------------------------------------------------------
630
631 /**
632 * Is ajax Request?
633 *
634 * Test to see if a request contains the HTTP_X_REQUESTED_WITH header
635 *
636 * @return boolean
637 */
638 public function is_ajax_request()
639 {
Greg Aker2fae66e2010-12-09 15:49:34 -0600640 return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
Greg Aker081ac9d2010-11-22 14:42:53 -0600641 }
642
Derek Allard2067d1a2008-11-13 22:59:24 +0000643}
644// END Input class
645
646/* End of file Input.php */
Derek Jonesc68dfbf2010-03-02 12:59:23 -0600647/* Location: ./system/core/Input.php */