* @license PHP License * @package WB * @subpackage base */ WBClass::load( 'WBRequest' ); /** * HTTP request class * * Collect HTTP request data and check protocol * * @version 1.0.0 * @package WB * @subpackage base */ class WBRequest_Http extends WBRequest { /** * constructor * * - Collect request parameter from GET and POST (not COOKIES!) * - Import meta data from $_SERVER * - Set path to $_SERVER['PATH_INFO'] * - Check for HTTPS */ public function __construct() { parent::__construct(); $import = $_REQUEST; $this->import($import); $this->_meta = $_SERVER; if(!empty($_SERVER['PATH_INFO'])) { $this->_path = $_SERVER['PATH_INFO']; } else if( $this->has('path')) { $this->_path = $this->get('path'); } $this->protocol = WBParam::get('wb/request/http/protocol/default','http'); if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS'])) { $this->protocol = 'https'; $this->encryption = 'ssl'; } } /** * Strip slashes recusively * * @deprecated as magic quotes is no longer supported in PHP 7 * @param array $list */ protected function stripSlashes(&$list) { foreach ($list as &$l) { if (is_string($l)) { $l = stripslashes($l); } else if (is_array($l)) { $this->stripSlashes($l); } } } /** * receive raw request data * * Support for compressed raw body content. * This actually extends the capabilities of browsers * * @return string */ public function getRaw() { $encoding = $this->getMeta('HTTP_CONTENT_ENCODING'); // deflate if ($encoding == 'deflate') { return gzinflate(file_get_contents('php://input')); } // gzip if ($encoding == 'gzip') { $stream = gzopen('php://input', 'r'); return stream_get_contents($stream); } // stream return file_get_contents('php://input'); } }