Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
URequest Class Reference

Http Request utilities, wrapper for accessing to $_GET, $_POST and php://input. More...

+ Inheritance diagram for URequest:

Static Public Member Functions

static setValuesToObject ($object, $values=null)
 Affects member to member the values of the associative array $values to the members of the object $object Used for example to retrieve the variables posted and assign them to the members of an object.
 
static setGetValuesToObject ($object)
 Affects member to member the values of $_GET to the members of the object $object $object must have accessors to each members.
 
static setPostValuesToObject ($object)
 Affects member to member the values of $_POST to the members of the object $object $object must have accessors to each members.
 
static getPost ($function='htmlentities')
 Call a cleaning function on the post.
 
static getInput ()
 Returns the query data, for PUT, DELETE PATCH methods.
 
static getDatas ()
 Returns the query data, regardless of the method.
 
static set (string $key, $value=true)
 Adds a value in request at $key position.
 
static getDefaultLanguage ()
 Copyright © 2008 Darrin Yeager https://www.dyeager.org/ Licensed under BSD license.
 
static setLocale (string $locale)
 
static get (string $key, $default=NULL)
 Returns the value of the $key variable passed by the get method or $default if the $key variable does not exist.
 
static getBoolean (string $key)
 Returns a boolean at the key position in request.
 
static post (string $key, $default=NULL)
 Returns the value of the $key variable passed by the post method or $default if the $key variable does not exist.
 
static getUrl ($url)
 
static getUrlParts ()
 
static getMethod ()
 Returns the http method.
 
static getOrigin ()
 Returns the request origin.
 
static cleanUrl ($url)
 
static getRealInput ($source='post')
 Fix up PHP's messing up input containing dots, etc.
 
static getRealGET ()
 
static getRealPOST ()
 
static password_hash (string $key, string $algo=PASSWORD_DEFAULT)
 Creates a password hash for a posted value at $key position.
 
static password_verify (string $passwordKey, string $hash)
 Verifies that a posted password matches a hash at $passwordKey position.
 
static parseURI (string $uri, string $basedir)
 Internal use for async servers (Swoole and Workerman).
 
static filter (string $key, int $type=\INPUT_POST, int $filter=\FILTER_DEFAULT, $default=null)
 Gets a specific external variable by name and optionally filters it.
 
static filterPost (string $key, int $filter=\FILTER_DEFAULT, $default=null)
 Gets a specific POST variable by name and optionally filters it.
 
static filterGet (string $key, int $filter=\FILTER_DEFAULT, $default=null)
 Gets a specific GET variable by name and optionally filters it.
 
- Static Public Member Functions inherited from URequestTesterTrait
static filled ($key)
 Tests if a value is present on the request and is not empty.
 
static has ($key)
 Tests if a value is present on the request.
 
static isAjax ()
 Returns true if the request is an Ajax request.
 
static isPost ()
 Returns true if the request is sent by the POST method.
 
static isCrossSite ()
 Returns true if the request is cross site.
 
static isJSON ()
 Returns true if request contentType is set to json.
 
static getContentType ()
 Returns the request content-type header.
 

Static Private Member Functions

static parseDefaultLanguage ($http_accept, $deflang='en')
 
static _parseURI (string $uri, string $basedir)
 

Static Private Attributes

static $uriInfos
 

Detailed Description

Http Request utilities, wrapper for accessing to $_GET, $_POST and php://input.

Ubiquity\utils\http$URequest This class is part of Ubiquity

Author
jcheron myadd.nosp@m.ress.nosp@m.mail@.nosp@m.gmai.nosp@m.l.com
Version
1.1.4

Definition at line 18 of file URequest.php.

Member Function Documentation

◆ _parseURI()

static _parseURI ( string  $uri,
string  $basedir 
)
staticprivate

Definition at line 336 of file URequest.php.

◆ cleanUrl()

static cleanUrl (   $url)
static

Definition at line 229 of file URequest.php.

◆ filter()

static filter ( string  $key,
int  $type = \INPUT_POST,
int  $filter = \FILTER_DEFAULT,
  $default = null 
)
static

Gets a specific external variable by name and optionally filters it.

Parameters
string$key
int$type
int$filter
mixed | null$default
Returns
mixed|null

Definition at line 310 of file URequest.php.

◆ filterGet()

static filterGet ( string  $key,
int  $filter = \FILTER_DEFAULT,
  $default = null 
)
static

Gets a specific GET variable by name and optionally filters it.

Parameters
string$key
int$filter
mixed | null$default
Returns
mixed|null

Definition at line 332 of file URequest.php.

◆ filterPost()

static filterPost ( string  $key,
int  $filter = \FILTER_DEFAULT,
  $default = null 
)
static

Gets a specific POST variable by name and optionally filters it.

Parameters
string$key
int$filter
mixed | null$default
Returns
mixed|null

Definition at line 321 of file URequest.php.

◆ get()

static get ( string  $key,
  $default = NULL 
)
static

Returns the value of the $key variable passed by the get method or $default if the $key variable does not exist.

Parameters
string$key
mixed$defaultreturn value by default
Returns
string

Definition at line 168 of file URequest.php.

◆ getBoolean()

static getBoolean ( string  $key)
static

Returns a boolean at the key position in request.

Parameters
string$keythe key to add or set
Returns
boolean

Definition at line 178 of file URequest.php.

◆ getDatas()

static getDatas ( )
static

Returns the query data, regardless of the method.

Returns
array

Definition at line 86 of file URequest.php.

◆ getDefaultLanguage()

static getDefaultLanguage ( )
static

Copyright © 2008 Darrin Yeager https://www.dyeager.org/ Licensed under BSD license.

https://www.dyeager.org/downloads/license-bsd.txt

Definition at line 120 of file URequest.php.

◆ getInput()

static getInput ( )
static

Returns the query data, for PUT, DELETE PATCH methods.

Definition at line 77 of file URequest.php.

◆ getMethod()

static getMethod ( )
static

Returns the http method.

Returns
string

Definition at line 215 of file URequest.php.

◆ getOrigin()

static getOrigin ( )
static

Returns the request origin.

Returns
string

Definition at line 224 of file URequest.php.

◆ getPost()

static getPost (   $function = 'htmlentities')
static

Call a cleaning function on the post.

Parameters
string$functionthe cleaning function, default htmlentities
Returns
array

Definition at line 70 of file URequest.php.

◆ getRealGET()

static getRealGET ( )
static

Definition at line 254 of file URequest.php.

◆ getRealInput()

static getRealInput (   $source = 'post')
static

Fix up PHP's messing up input containing dots, etc.

$source can be either 'post' or 'get'

Parameters
string$source
Returns
string[]
See also
https://stackoverflow.com/questions/68651/can-i-get-php-to-stop-replacing-characters-in-get-or-post-arrays#68667

Definition at line 242 of file URequest.php.

◆ getRealPOST()

static getRealPOST ( )
static

Definition at line 258 of file URequest.php.

◆ getUrl()

static getUrl (   $url)
static

Definition at line 197 of file URequest.php.

◆ getUrlParts()

static getUrlParts ( )
static

Definition at line 206 of file URequest.php.

◆ parseDefaultLanguage()

static parseDefaultLanguage (   $http_accept,
  $deflang = 'en' 
)
staticprivate

Definition at line 127 of file URequest.php.

◆ parseURI()

static parseURI ( string  $uri,
string  $basedir 
)
static

Internal use for async servers (Swoole and Workerman).

Parameters
string$uri
string$basedir
Returns
array

Definition at line 298 of file URequest.php.

◆ password_hash()

static password_hash ( string  $key,
string  $algo = PASSWORD_DEFAULT 
)
static

Creates a password hash for a posted value at $key position.

Parameters
string$key
string$algo
Returns
string|boolean

Definition at line 269 of file URequest.php.

◆ password_verify()

static password_verify ( string  $passwordKey,
string  $hash 
)
static

Verifies that a posted password matches a hash at $passwordKey position.

Parameters
string$passwordKey
string$hash
Returns
bool
Since
2.4.0

Definition at line 285 of file URequest.php.

◆ post()

static post ( string  $key,
  $default = NULL 
)
static

Returns the value of the $key variable passed by the post method or $default if the $key variable does not exist.

Parameters
string$key
mixed$defaultreturn value by default
Returns
mixed

Definition at line 193 of file URequest.php.

◆ set()

static set ( string  $key,
  $value = true 
)
static

Adds a value in request at $key position.

Parameters
string$key
mixed$value
Returns
mixed

Definition at line 110 of file URequest.php.

◆ setGetValuesToObject()

static setGetValuesToObject (   $object)
static

Affects member to member the values of $_GET to the members of the object $object $object must have accessors to each members.

Parameters
object$object

Definition at line 50 of file URequest.php.

◆ setLocale()

static setLocale ( string  $locale)
static

Definition at line 150 of file URequest.php.

◆ setPostValuesToObject()

static setPostValuesToObject (   $object)
static

Affects member to member the values of $_POST to the members of the object $object $object must have accessors to each members.

Parameters
object$object

Definition at line 60 of file URequest.php.

◆ setValuesToObject()

static setValuesToObject (   $object,
  $values = null 
)
static

Affects member to member the values of the associative array $values to the members of the object $object Used for example to retrieve the variables posted and assign them to the members of an object.

Parameters
object$object
array$values

Definition at line 31 of file URequest.php.

Field Documentation

◆ $uriInfos

$uriInfos
staticprivate

Definition at line 23 of file URequest.php.


The documentation for this class was generated from the following file: