waRequest

Processing user requests to the server

Contents...

Methods

public static function cookie ($name = null, $default = null, $type = null)

Returns information about user's cookie files.

Parameters

Example

waRequest::cookie()

Result

Array
(
    [PHPSESSID] => 50ukl8c8qns02kl02pjmenqkf7
    [_csrf] => 52c10405125ea9.47558260
)

public static function file ($name)

Returns the list of files uploaded by user as an instance of class waRequestFileIterator. When the result of method waRequest::file() is used as an array in a foreach cycle, then each array item represents an instance of waRequestFile class.

Parameters

Example

waRequest::file('photo')->count()

Result

1 //user attempts to upload 1 file using file uploading input element named photo

public static function get ($name = null, $default = null, $type = null)

Returns the contents of the GET request.

Parameters

Example

waRequest::get('id', 0, 'int')

public static function getIp ($get_as_int = false)

Returns user's IP address.

Parameters

Example

waRequest::getIp()

Result

127.0.0.1

Example

waRequest::getIp(true)

Result

2130706433

public static function getLocale ($default = null, $browser_only = false)

Determines user's locale.

Parameters

Example

waRequest::getLocale()

public static function getMethod()

Returns the type of request sent by user.

Example

waRequest::getMethod()

Result

post //user sent a POST request

public static function getTheme()

Returns the id of the design theme used in a frontend page.

Example

waRequest::getTheme()

Result

custom //current frontend page utilizes design theme CUSTOM

public static function getUserAgent()

Returns the contents of server header HTTP_USER_AGENT.

Example

waRequest::getUserAgent()

Result

Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/31.0.1650.63 Chrome/31.0.1650.63 Safari/537.36

public static function isHttps()

Detects HTTPS connections to server.

Example

$is_https = waRequest::isHttps()

public static function isMobile ($check = true)

Determines the use of a mobile device.

Parameters

Example

waRequest::isMobile()

Result

android //user opens a web page with an Android-powered device

public static function issetPost ($name)

Verifies availablility of a value in the POST request.

Parameters

Example

waRequest::issetPost('id')

Result

false //POST request does not contain a field named 'id'

public static function isXMLHttpRequest()

Verifies whether the current request is an AJAX request.

Example

waRequest::isXMLHttpRequest()

Result

true //user sent an AJAX request from a web page

public static function method()

Returns the type of request sent by user. Alias for method getMethod.

Example

waRequest::method()

Result

post //user sent a POST request

public static function param ($name = null, $default = null, $type = null)

Returns additional request parameters.

Parameters

Example

waRequest::param('locale', 'en_US')

Result

en_US

When used in frontend controllers, method waRequest::param() returns values of app settlement (routing) parameters.

Example

waRequest::param('private') //getting value of "Privacy (private settlement)" option in app settlement (routing) settings

public static function post ($name = null, $default = null, $type = null)

Returns the contents of the POST request.

Parameters

Example

waRequest::post('id')

public static function request ($name = null, $default = null, $type = null)

Returns combined contents of the GET and POST requests or the value of the specified request field.

Parameters

Example

waRequest::request('id')

public static function server ($name = null, $default = null, $type = null)

Returns the contents of the $_SERVER array.

Parameters

Example

waRequest::server('HTTP_HOST')

Result

yourdomain.com

public static function setParam ($key, $value = null)

Sets custom values for additional request parameters.

Parameters

Example

waRequest::setParam('locale', 'en_US')