|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Copyright © 2021 ExacTI Technology Solutions. All rights reserved.
|
|
|
|
* GPLv3 General License.
|
|
|
|
* https://exacti.com.br
|
|
|
|
* Phacil PHP Framework - https://github.com/exacti/phacil-framework
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Phacil\Framework;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Request class with escaped values.
|
|
|
|
*
|
|
|
|
* @package Phacil\Framework
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
final class Request {
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public $get = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public $post = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public $cookie = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public $files = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public $server = array();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
public $request = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated since version 2.0, to be removed in 3.0.
|
|
|
|
* @var array|string|false
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public $method;
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
static protected $_GET = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
static protected $_POST = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
static protected $_REQUEST = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
static protected $_COOKIE = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
static protected $_FILES = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string
|
|
|
|
*/
|
|
|
|
static protected $_SERVER = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @var array|string|false
|
|
|
|
*/
|
|
|
|
static protected $_METHOD;
|
|
|
|
|
|
|
|
/** @return void */
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function __construct() {
|
|
|
|
self::$_GET = $this->clean($_GET);
|
|
|
|
self::$_POST = $this->clean($_POST);
|
|
|
|
self::$_REQUEST = $this->clean($_REQUEST);
|
|
|
|
self::$_COOKIE = $this->clean($_COOKIE);
|
|
|
|
self::$_FILES = $this->clean($_FILES);
|
|
|
|
self::$_SERVER = $this->clean($_SERVER);
|
|
|
|
self::$_METHOD = (isset(self::$_SERVER['REQUEST_METHOD'])) ? $this->clean(self::$_SERVER['REQUEST_METHOD']) : false;
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
|
|
|
|
$this->get =& self::$_GET;
|
|
|
|
$this->post =& self::$_POST;
|
|
|
|
$this->request =& self::$_REQUEST;
|
|
|
|
$this->cookie =& self::$_COOKIE;
|
|
|
|
$this->files =& self::$_FILES;
|
|
|
|
$this->server =& self::$_SERVER;
|
|
|
|
$this->method =& self::$_METHOD;
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|array $data
|
|
|
|
* @return array|string
|
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function clean($data) {
|
|
|
|
if (is_array($data)) {
|
|
|
|
foreach ($data as $key => $value) {
|
|
|
|
unset($data[$key]);
|
|
|
|
|
|
|
|
$data[$this->clean($key)] = $this->clean($value);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$data = htmlspecialchars($data, ENT_COMPAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return POST values from $_POST or $_FILES.
|
|
|
|
*
|
|
|
|
* @param string $key (optional)
|
|
|
|
* @param mixed $value (optional)
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function POST($key = null, $value = null){
|
|
|
|
if($value !== null)
|
|
|
|
self::$_POST[$key] = $value;
|
|
|
|
|
|
|
|
return $key ? (isset(self::$_POST[$key]) ? self::$_POST[$key] : null) : self::$_POST;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return GET values from $_GET.
|
|
|
|
*
|
|
|
|
* @param string $key (optional)
|
|
|
|
* @param mixed $value (optional)
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function GET($key = null, $value = null){
|
|
|
|
if ($value !== null)
|
|
|
|
self::$_GET[$key] = $value;
|
|
|
|
|
|
|
|
return $key ? (isset(self::$_GET[$key]) ? self::$_GET[$key] : null) : self::$_GET;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return REQUEST values from $_REQUEST.
|
|
|
|
*
|
|
|
|
* @param string $key (optional)
|
|
|
|
* @param mixed $value (optional)
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function REQUEST($key = null, $value = null){
|
|
|
|
if ($value !== null)
|
|
|
|
self::$_REQUEST[$key] = $value;
|
|
|
|
|
|
|
|
return $key ? (isset(self::$_REQUEST[$key]) ? self::$_REQUEST[$key] : null) : self::$_REQUEST;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return FILES values from $_FILES.
|
|
|
|
*
|
|
|
|
* @param string $key (optional) If null return all values.
|
|
|
|
* @param mixed $value (optional) If not null, set the value for this key.
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function FILES($key = null, $value = null){
|
|
|
|
if ($value !== null)
|
|
|
|
self::$_FILES[$key] = $value;
|
|
|
|
|
|
|
|
return $key ? (isset(self::$_FILES[$key]) ? self::$_FILES[$key] : null) : self::$_FILES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return COOKIE values from $_COOKIE.
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param mixed $value
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function COOKIE($key = null, $value = null){
|
|
|
|
if ($value !== null)
|
|
|
|
self::$_COOKIE[$key] = $value;
|
|
|
|
|
|
|
|
return $key ? (isset(self::$_COOKIE[$key]) ? self::$_COOKIE[$key] : null) : self::$_COOKIE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return SERVER values from $_SERVER.
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param mixed $value
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function SERVER($key = null, $value = null){
|
|
|
|
if ($value !== null)
|
|
|
|
self::$_SERVER[$key] = $value;
|
|
|
|
|
|
|
|
return $key ? (isset(self::$_SERVER[$key]) ? self::$_SERVER[$key] : null) : self::$_SERVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return HTTP method from $_SERVER['REQUEST_METHOD'].
|
|
|
|
*
|
|
|
|
* @return string|false|null
|
|
|
|
*
|
|
|
|
* @since 2.0.0
|
|
|
|
*/
|
|
|
|
static public function METHOD(){
|
|
|
|
return self::$_METHOD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isPOST() {
|
|
|
|
return $this->is('POST');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isGET() {
|
|
|
|
return $this->is('GET');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isHEAD() {
|
|
|
|
return $this->is('HEAD');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isPUT() {
|
|
|
|
return $this->is('PUT');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isDELETE() {
|
|
|
|
return $this->is('DELETE');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isCONNECT() {
|
|
|
|
return $this->is('CONNECT') ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isOPTIONS() {
|
|
|
|
return $this->is('OPTIONS') ;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isTRACE() {
|
|
|
|
return $this->is('TRACE');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function isPATCH() {
|
|
|
|
return $this->is('PATCH');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $method
|
|
|
|
* @return bool
|
|
|
|
* @since 1.5.0
|
|
|
|
*/
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
public function is($method){
|
|
|
|
return (self::$_METHOD == $method);
|
PHP SESSION Prefix and IP check, engine constants and user_constants as a function for better memory usage, add SQLite 3 driver, new loader for aditional database method, new REST HTPP method check, updated template engines: Mustache 2.13, Smarty 3.1.34, Twig 1.42.5, Twig 2.12.5, add Twig 3 support to PHP 7.2+, define Dwoo template as deprecated, Caches and captcha bugfix in PHP 5.4.x
5 years ago
|
|
|
}
|
|
|
|
}
|