diff options
author | Ahmad Anbar <aanbar@gmail.com> | 2015-04-06 18:59:53 +0200 |
---|---|---|
committer | Ahmad Anbar <aanbar@gmail.com> | 2015-04-06 18:59:53 +0200 |
commit | 5e50c42ef27261bc7fcb279499ce76cfc2519aa6 (patch) | |
tree | d74d660534b72ddc0b6cda9147cecfb64a225346 /system/core/Input.php | |
parent | ed520408514fff6486788e1543589418d24d885e (diff) | |
parent | 7726b75552f765af94038e47a4a4272ac08c646e (diff) |
Merge remote-tracking branch 'upstream/develop' into develop
Diffstat (limited to 'system/core/Input.php')
-rw-r--r-- | system/core/Input.php | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/system/core/Input.php b/system/core/Input.php index fae3b6c08..12332cf51 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -55,7 +55,7 @@ class CI_Input { * * @var string */ - public $ip_address = FALSE; + protected $ip_address = FALSE; /** * Allow GET array flag @@ -104,14 +104,28 @@ class CI_Input { protected $headers = array(); /** - * Input stream data + * Raw input stream data + * + * Holds a cache of php://input contents + * + * @var string + */ + protected $_raw_input_stream; + + /** + * Parsed input stream data * * Parsed from php://input at runtime * * @see CI_Input::input_stream() * @var array */ - protected $_input_stream = NULL; + protected $_input_stream; + + protected $security; + protected $uni; + + // -------------------------------------------------------------------- /** * Class constructor @@ -313,7 +327,8 @@ class CI_Input { // so we'll need to check if we have already done that first. if ( ! is_array($this->_input_stream)) { - parse_str(file_get_contents('php://input'), $this->_input_stream); + // $this->raw_input_stream will trigger __get(). + parse_str($this->raw_input_stream, $this->_input_stream); is_array($this->_input_stream) OR $this->_input_stream = array(); } @@ -475,9 +490,9 @@ class CI_Input { ) ); - for ($i = 0; $i < 8; $i++) + for ($j = 0; $j < 8; $j++) { - $ip[$i] = intval($ip[$i], 16); + $ip[$j] = intval($ip[$j], 16); } $sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b'; @@ -846,4 +861,27 @@ class CI_Input { : strtolower($this->server('REQUEST_METHOD')); } + // ------------------------------------------------------------------------ + + /** + * Magic __get() + * + * Allows read access to protected properties + * + * @param string $name + * @return mixed + */ + public function __get($name) + { + if ($name === 'raw_input_stream') + { + isset($this->_raw_input_stream) OR $this->_raw_input_stream = file_get_contents('php://input'); + return $this->_raw_input_stream; + } + elseif ($name === 'ip_address') + { + return $this->ip_address; + } + } + } |