Input.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * CodeIgniter
  4. *
  5. * An open source application development framework for PHP 5.1.6 or newer
  6. *
  7. * @package CodeIgniter
  8. * @author ExpressionEngine Dev Team
  9. * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
  10. * @license http://codeigniter.com/user_guide/license.html
  11. * @link http://codeigniter.com
  12. * @since Version 1.0
  13. * @filesource
  14. */
  15. // ------------------------------------------------------------------------
  16. /**
  17. * Input Class
  18. *
  19. * Pre-processes global input data for security
  20. *
  21. * @package CodeIgniter
  22. * @subpackage Libraries
  23. * @category Input
  24. * @author ExpressionEngine Dev Team
  25. * @link http://codeigniter.com/user_guide/libraries/input.html
  26. */
  27. class CI_Input {
  28. /**
  29. * IP address of the current user
  30. *
  31. * @var string
  32. */
  33. var $ip_address = FALSE;
  34. /**
  35. * user agent (web browser) being used by the current user
  36. *
  37. * @var string
  38. */
  39. var $user_agent = FALSE;
  40. /**
  41. * If FALSE, then $_GET will be set to an empty array
  42. *
  43. * @var bool
  44. */
  45. var $_allow_get_array = TRUE;
  46. /**
  47. * If TRUE, then newlines are standardized
  48. *
  49. * @var bool
  50. */
  51. var $_standardize_newlines = TRUE;
  52. /**
  53. * Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
  54. * Set automatically based on config setting
  55. *
  56. * @var bool
  57. */
  58. var $_enable_xss = FALSE;
  59. /**
  60. * Enables a CSRF cookie token to be set.
  61. * Set automatically based on config setting
  62. *
  63. * @var bool
  64. */
  65. var $_enable_csrf = FALSE;
  66. /**
  67. * List of all HTTP request headers
  68. *
  69. * @var array
  70. */
  71. protected $headers = array();
  72. /**
  73. * Constructor
  74. *
  75. * Sets whether to globally enable the XSS processing
  76. * and whether to allow the $_GET array
  77. *
  78. * @return void
  79. */
  80. public function __construct()
  81. {
  82. log_message('debug', "Input Class Initialized");
  83. $this->_allow_get_array = (config_item('allow_get_array') === TRUE);
  84. $this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
  85. $this->_enable_csrf = (config_item('csrf_protection') === TRUE);
  86. global $SEC;
  87. $this->security =& $SEC;
  88. // Do we need the UTF-8 class?
  89. if (UTF8_ENABLED === TRUE)
  90. {
  91. global $UNI;
  92. $this->uni =& $UNI;
  93. }
  94. // Sanitize global arrays
  95. $this->_sanitize_globals();
  96. }
  97. // --------------------------------------------------------------------
  98. /**
  99. * Fetch from array
  100. *
  101. * This is a helper function to retrieve values from global arrays
  102. *
  103. * @access private
  104. * @param array
  105. * @param string
  106. * @param bool
  107. * @return string
  108. */
  109. function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
  110. {
  111. if ( ! isset($array[$index]))
  112. {
  113. return FALSE;
  114. }
  115. if ($xss_clean === TRUE)
  116. {
  117. return $this->security->xss_clean($array[$index]);
  118. }
  119. return $array[$index];
  120. }
  121. // --------------------------------------------------------------------
  122. /**
  123. * Fetch an item from the GET array
  124. *
  125. * @access public
  126. * @param string
  127. * @param bool
  128. * @return string
  129. */
  130. function get($index = NULL, $xss_clean = FALSE)
  131. {
  132. // Check if a field has been provided
  133. if ($index === NULL AND ! empty($_GET))
  134. {
  135. $get = array();
  136. // loop through the full _GET array
  137. foreach (array_keys($_GET) as $key)
  138. {
  139. $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
  140. }
  141. return $get;
  142. }
  143. return $this->_fetch_from_array($_GET, $index, $xss_clean);
  144. }
  145. // --------------------------------------------------------------------
  146. /**
  147. * Fetch an item from the POST array
  148. *
  149. * @access public
  150. * @param string
  151. * @param bool
  152. * @return string
  153. */
  154. function post($index = NULL, $xss_clean = FALSE)
  155. {
  156. // Check if a field has been provided
  157. if ($index === NULL AND ! empty($_POST))
  158. {
  159. $post = array();
  160. // Loop through the full _POST array and return it
  161. foreach (array_keys($_POST) as $key)
  162. {
  163. $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
  164. }
  165. return $post;
  166. }
  167. return $this->_fetch_from_array($_POST, $index, $xss_clean);
  168. }
  169. // --------------------------------------------------------------------
  170. /**
  171. * Fetch an item from either the GET array or the POST
  172. *
  173. * @access public
  174. * @param string The index key
  175. * @param bool XSS cleaning
  176. * @return string
  177. */
  178. function get_post($index = '', $xss_clean = FALSE)
  179. {
  180. if ( ! isset($_POST[$index]) )
  181. {
  182. return $this->get($index, $xss_clean);
  183. }
  184. else
  185. {
  186. return $this->post($index, $xss_clean);
  187. }
  188. }
  189. // --------------------------------------------------------------------
  190. /**
  191. * Fetch an item from the COOKIE array
  192. *
  193. * @access public
  194. * @param string
  195. * @param bool
  196. * @return string
  197. */
  198. function cookie($index = '', $xss_clean = FALSE)
  199. {
  200. return $this->_fetch_from_array($_COOKIE, $index, $xss_clean);
  201. }
  202. // ------------------------------------------------------------------------
  203. /**
  204. * Set cookie
  205. *
  206. * Accepts six parameter, or you can submit an associative
  207. * array in the first parameter containing all the values.
  208. *
  209. * @access public
  210. * @param mixed
  211. * @param string the value of the cookie
  212. * @param string the number of seconds until expiration
  213. * @param string the cookie domain. Usually: .yourdomain.com
  214. * @param string the cookie path
  215. * @param string the cookie prefix
  216. * @param bool true makes the cookie secure
  217. * @return void
  218. */
  219. function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
  220. {
  221. if (is_array($name))
  222. {
  223. // always leave 'name' in last place, as the loop will break otherwise, due to $$item
  224. foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item)
  225. {
  226. if (isset($name[$item]))
  227. {
  228. $$item = $name[$item];
  229. }
  230. }
  231. }
  232. if ($prefix == '' AND config_item('cookie_prefix') != '')
  233. {
  234. $prefix = config_item('cookie_prefix');
  235. }
  236. if ($domain == '' AND config_item('cookie_domain') != '')
  237. {
  238. $domain = config_item('cookie_domain');
  239. }
  240. if ($path == '/' AND config_item('cookie_path') != '/')
  241. {
  242. $path = config_item('cookie_path');
  243. }
  244. if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
  245. {
  246. $secure = config_item('cookie_secure');
  247. }
  248. if ( ! is_numeric($expire))
  249. {
  250. $expire = time() - 86500;
  251. }
  252. else
  253. {
  254. $expire = ($expire > 0) ? time() + $expire : 0;
  255. }
  256. setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
  257. }
  258. // --------------------------------------------------------------------
  259. /**
  260. * Fetch an item from the SERVER array
  261. *
  262. * @access public
  263. * @param string
  264. * @param bool
  265. * @return string
  266. */
  267. function server($index = '', $xss_clean = FALSE)
  268. {
  269. return $this->_fetch_from_array($_SERVER, $index, $xss_clean);
  270. }
  271. // --------------------------------------------------------------------
  272. /**
  273. * Fetch the IP Address
  274. *
  275. * @return string
  276. */
  277. public function ip_address()
  278. {
  279. if ($this->ip_address !== FALSE)
  280. {
  281. return $this->ip_address;
  282. }
  283. $proxy_ips = config_item('proxy_ips');
  284. if ( ! empty($proxy_ips))
  285. {
  286. $proxy_ips = explode(',', str_replace(' ', '', $proxy_ips));
  287. foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_X_CLIENT_IP', 'HTTP_X_CLUSTER_CLIENT_IP') as $header)
  288. {
  289. if (($spoof = $this->server($header)) !== FALSE)
  290. {
  291. // Some proxies typically list the whole chain of IP
  292. // addresses through which the client has reached us.
  293. // e.g. client_ip, proxy_ip1, proxy_ip2, etc.
  294. if (strpos($spoof, ',') !== FALSE)
  295. {
  296. $spoof = explode(',', $spoof, 2);
  297. $spoof = $spoof[0];
  298. }
  299. if ( ! $this->valid_ip($spoof))
  300. {
  301. $spoof = FALSE;
  302. }
  303. else
  304. {
  305. break;
  306. }
  307. }
  308. }
  309. $this->ip_address = ($spoof !== FALSE && in_array($_SERVER['REMOTE_ADDR'], $proxy_ips, TRUE))
  310. ? $spoof : $_SERVER['REMOTE_ADDR'];
  311. }
  312. else
  313. {
  314. $this->ip_address = $_SERVER['REMOTE_ADDR'];
  315. }
  316. if ( ! $this->valid_ip($this->ip_address))
  317. {
  318. $this->ip_address = '0.0.0.0';
  319. }
  320. return $this->ip_address;
  321. }
  322. // --------------------------------------------------------------------
  323. /**
  324. * Validate IP Address
  325. *
  326. * @access public
  327. * @param string
  328. * @param string ipv4 or ipv6
  329. * @return bool
  330. */
  331. public function valid_ip($ip, $which = '')
  332. {
  333. $which = strtolower($which);
  334. // First check if filter_var is available
  335. if (is_callable('filter_var'))
  336. {
  337. switch ($which) {
  338. case 'ipv4':
  339. $flag = FILTER_FLAG_IPV4;
  340. break;
  341. case 'ipv6':
  342. $flag = FILTER_FLAG_IPV6;
  343. break;
  344. default:
  345. $flag = '';
  346. break;
  347. }
  348. return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flag);
  349. }
  350. if ($which !== 'ipv6' && $which !== 'ipv4')
  351. {
  352. if (strpos($ip, ':') !== FALSE)
  353. {
  354. $which = 'ipv6';
  355. }
  356. elseif (strpos($ip, '.') !== FALSE)
  357. {
  358. $which = 'ipv4';
  359. }
  360. else
  361. {
  362. return FALSE;
  363. }
  364. }
  365. $func = '_valid_'.$which;
  366. return $this->$func($ip);
  367. }
  368. // --------------------------------------------------------------------
  369. /**
  370. * Validate IPv4 Address
  371. *
  372. * Updated version suggested by Geert De Deckere
  373. *
  374. * @access protected
  375. * @param string
  376. * @return bool
  377. */
  378. protected function _valid_ipv4($ip)
  379. {
  380. $ip_segments = explode('.', $ip);
  381. // Always 4 segments needed
  382. if (count($ip_segments) !== 4)
  383. {
  384. return FALSE;
  385. }
  386. // IP can not start with 0
  387. if ($ip_segments[0][0] == '0')
  388. {
  389. return FALSE;
  390. }
  391. // Check each segment
  392. foreach ($ip_segments as $segment)
  393. {
  394. // IP segments must be digits and can not be
  395. // longer than 3 digits or greater then 255
  396. if ($segment == '' OR preg_match("/[^0-9]/", $segment) OR $segment > 255 OR strlen($segment) > 3)
  397. {
  398. return FALSE;
  399. }
  400. }
  401. return TRUE;
  402. }
  403. // --------------------------------------------------------------------
  404. /**
  405. * Validate IPv6 Address
  406. *
  407. * @access protected
  408. * @param string
  409. * @return bool
  410. */
  411. protected function _valid_ipv6($str)
  412. {
  413. // 8 groups, separated by :
  414. // 0-ffff per group
  415. // one set of consecutive 0 groups can be collapsed to ::
  416. $groups = 8;
  417. $collapsed = FALSE;
  418. $chunks = array_filter(
  419. preg_split('/(:{1,2})/', $str, NULL, PREG_SPLIT_DELIM_CAPTURE)
  420. );
  421. // Rule out easy nonsense
  422. if (current($chunks) == ':' OR end($chunks) == ':')
  423. {
  424. return FALSE;
  425. }
  426. // PHP supports IPv4-mapped IPv6 addresses, so we'll expect those as well
  427. if (strpos(end($chunks), '.') !== FALSE)
  428. {
  429. $ipv4 = array_pop($chunks);
  430. if ( ! $this->_valid_ipv4($ipv4))
  431. {
  432. return FALSE;
  433. }
  434. $groups--;
  435. }
  436. while ($seg = array_pop($chunks))
  437. {
  438. if ($seg[0] == ':')
  439. {
  440. if (--$groups == 0)
  441. {
  442. return FALSE; // too many groups
  443. }
  444. if (strlen($seg) > 2)
  445. {
  446. return FALSE; // long separator
  447. }
  448. if ($seg == '::')
  449. {
  450. if ($collapsed)
  451. {
  452. return FALSE; // multiple collapsed
  453. }
  454. $collapsed = TRUE;
  455. }
  456. }
  457. elseif (preg_match("/[^0-9a-f]/i", $seg) OR strlen($seg) > 4)
  458. {
  459. return FALSE; // invalid segment
  460. }
  461. }
  462. return $collapsed OR $groups == 1;
  463. }
  464. // --------------------------------------------------------------------
  465. /**
  466. * User Agent
  467. *
  468. * @access public
  469. * @return string
  470. */
  471. function user_agent()
  472. {
  473. if ($this->user_agent !== FALSE)
  474. {
  475. return $this->user_agent;
  476. }
  477. $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
  478. return $this->user_agent;
  479. }
  480. // --------------------------------------------------------------------
  481. /**
  482. * Sanitize Globals
  483. *
  484. * This function does the following:
  485. *
  486. * Unsets $_GET data (if query strings are not enabled)
  487. *
  488. * Unsets all globals if register_globals is enabled
  489. *
  490. * Standardizes newline characters to \n
  491. *
  492. * @access private
  493. * @return void
  494. */
  495. function _sanitize_globals()
  496. {
  497. // It would be "wrong" to unset any of these GLOBALS.
  498. $protected = array('_SERVER', '_GET', '_POST', '_FILES', '_REQUEST',
  499. '_SESSION', '_ENV', 'GLOBALS', 'HTTP_RAW_POST_DATA',
  500. 'system_folder', 'application_folder', 'BM', 'EXT',
  501. 'CFG', 'URI', 'RTR', 'OUT', 'IN');
  502. // Unset globals for securiy.
  503. // This is effectively the same as register_globals = off
  504. foreach (array($_GET, $_POST, $_COOKIE) as $global)
  505. {
  506. if ( ! is_array($global))
  507. {
  508. if ( ! in_array($global, $protected))
  509. {
  510. global $$global;
  511. $$global = NULL;
  512. }
  513. }
  514. else
  515. {
  516. foreach ($global as $key => $val)
  517. {
  518. if ( ! in_array($key, $protected))
  519. {
  520. global $$key;
  521. $$key = NULL;
  522. }
  523. }
  524. }
  525. }
  526. // Is $_GET data allowed? If not we'll set the $_GET to an empty array
  527. if ($this->_allow_get_array == FALSE)
  528. {
  529. $_GET = array();
  530. }
  531. else
  532. {
  533. if (is_array($_GET) AND count($_GET) > 0)
  534. {
  535. foreach ($_GET as $key => $val)
  536. {
  537. $_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
  538. }
  539. }
  540. }
  541. // Clean $_POST Data
  542. if (is_array($_POST) AND count($_POST) > 0)
  543. {
  544. foreach ($_POST as $key => $val)
  545. {
  546. $_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
  547. }
  548. }
  549. // Clean $_COOKIE Data
  550. if (is_array($_COOKIE) AND count($_COOKIE) > 0)
  551. {
  552. // Also get rid of specially treated cookies that might be set by a server
  553. // or silly application, that are of no use to a CI application anyway
  554. // but that when present will trip our 'Disallowed Key Characters' alarm
  555. // http://www.ietf.org/rfc/rfc2109.txt
  556. // note that the key names below are single quoted strings, and are not PHP variables
  557. unset($_COOKIE['$Version']);
  558. unset($_COOKIE['$Path']);
  559. unset($_COOKIE['$Domain']);
  560. foreach ($_COOKIE as $key => $val)
  561. {
  562. $_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
  563. }
  564. }
  565. // Sanitize PHP_SELF
  566. $_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
  567. // CSRF Protection check on HTTP requests
  568. if ($this->_enable_csrf == TRUE && ! $this->is_cli_request())
  569. {
  570. $this->security->csrf_verify();
  571. }
  572. log_message('debug', "Global POST and COOKIE data sanitized");
  573. }
  574. // --------------------------------------------------------------------
  575. /**
  576. * Clean Input Data
  577. *
  578. * This is a helper function. It escapes data and
  579. * standardizes newline characters to \n
  580. *
  581. * @access private
  582. * @param string
  583. * @return string
  584. */
  585. function _clean_input_data($str)
  586. {
  587. if (is_array($str))
  588. {
  589. $new_array = array();
  590. foreach ($str as $key => $val)
  591. {
  592. $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
  593. }
  594. return $new_array;
  595. }
  596. /* We strip slashes if magic quotes is on to keep things consistent
  597. NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
  598. it will probably not exist in future versions at all.
  599. */
  600. if ( ! is_php('5.4') && get_magic_quotes_gpc())
  601. {
  602. $str = stripslashes($str);
  603. }
  604. // Clean UTF-8 if supported
  605. if (UTF8_ENABLED === TRUE)
  606. {
  607. $str = $this->uni->clean_string($str);
  608. }
  609. // Remove control characters
  610. $str = remove_invisible_characters($str);
  611. // Should we filter the input data?
  612. if ($this->_enable_xss === TRUE)
  613. {
  614. $str = $this->security->xss_clean($str);
  615. }
  616. // Standardize newlines if needed
  617. if ($this->_standardize_newlines == TRUE)
  618. {
  619. if (strpos($str, "\r") !== FALSE)
  620. {
  621. $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str);
  622. }
  623. }
  624. return $str;
  625. }
  626. // --------------------------------------------------------------------
  627. /**
  628. * Clean Keys
  629. *
  630. * This is a helper function. To prevent malicious users
  631. * from trying to exploit keys we make sure that keys are
  632. * only named with alpha-numeric text and a few other items.
  633. *
  634. * @access private
  635. * @param string
  636. * @return string
  637. */
  638. function _clean_input_keys($str)
  639. {
  640. if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
  641. {
  642. exit('Disallowed Key Characters.');
  643. }
  644. // Clean UTF-8 if supported
  645. if (UTF8_ENABLED === TRUE)
  646. {
  647. $str = $this->uni->clean_string($str);
  648. }
  649. return $str;
  650. }
  651. // --------------------------------------------------------------------
  652. /**
  653. * Request Headers
  654. *
  655. * In Apache, you can simply call apache_request_headers(), however for
  656. * people running other webservers the function is undefined.
  657. *
  658. * @param bool XSS cleaning
  659. *
  660. * @return array
  661. */
  662. public function request_headers($xss_clean = FALSE)
  663. {
  664. // Look at Apache go!
  665. if (function_exists('apache_request_headers'))
  666. {
  667. $headers = apache_request_headers();
  668. }
  669. else
  670. {
  671. $headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
  672. foreach ($_SERVER as $key => $val)
  673. {
  674. if (strncmp($key, 'HTTP_', 5) === 0)
  675. {
  676. $headers[substr($key, 5)] = $this->_fetch_from_array($_SERVER, $key, $xss_clean);
  677. }
  678. }
  679. }
  680. // take SOME_HEADER and turn it into Some-Header
  681. foreach ($headers as $key => $val)
  682. {
  683. $key = str_replace('_', ' ', strtolower($key));
  684. $key = str_replace(' ', '-', ucwords($key));
  685. $this->headers[$key] = $val;
  686. }
  687. return $this->headers;
  688. }
  689. // --------------------------------------------------------------------
  690. /**
  691. * Get Request Header
  692. *
  693. * Returns the value of a single member of the headers class member
  694. *
  695. * @param string array key for $this->headers
  696. * @param boolean XSS Clean or not
  697. * @return mixed FALSE on failure, string on success
  698. */
  699. public function get_request_header($index, $xss_clean = FALSE)
  700. {
  701. if (empty($this->headers))
  702. {
  703. $this->request_headers();
  704. }
  705. if ( ! isset($this->headers[$index]))
  706. {
  707. return FALSE;
  708. }
  709. if ($xss_clean === TRUE)
  710. {
  711. return $this->security->xss_clean($this->headers[$index]);
  712. }
  713. return $this->headers[$index];
  714. }
  715. // --------------------------------------------------------------------
  716. /**
  717. * Is ajax Request?
  718. *
  719. * Test to see if a request contains the HTTP_X_REQUESTED_WITH header
  720. *
  721. * @return boolean
  722. */
  723. public function is_ajax_request()
  724. {
  725. return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
  726. }
  727. // --------------------------------------------------------------------
  728. /**
  729. * Is cli Request?
  730. *
  731. * Test to see if a request was made from the command line
  732. *
  733. * @return bool
  734. */
  735. public function is_cli_request()
  736. {
  737. return (php_sapi_name() === 'cli' OR defined('STDIN'));
  738. }
  739. }
  740. /* End of file Input.php */
  741. /* Location: ./system/core/Input.php */