Methods
-
cookie
Returns information about user's cookie files.
-
file
Returns the list of files uploaded by user.
-
get
Returns the contents of the GET request.
-
getIp
Returns user's IP address.
-
getLocale
Determines user's locale.
-
getMethod
Returns the type of request sent by user.
-
getPostMaxSize
Returns server’s POST request size limitation.
-
getTheme
Returns the id of the design theme used in a frontend page.
-
getUploadMaxFilesize
Returns server’s uploaded file size limitation.
-
getUserAgent
Returns the contents of server header
HTTP_USER_AGENT. -
isHttps
Detects HTTPS connections to server.
-
isMobile
Determines the use of a mobile device.
-
issetPost
Verifies availability of a value in the POST request.
-
isXMLHttpRequest
Verifies whether the current request is an AJAX request.
-
method
Returns the type of request sent by user. Alias for method getMethod.
-
param
Returns additional request parameters.
-
post
Returns the contents of the POST request.
-
request
Returns combined contents of the GET and POST requests or the value of the specified request field.
-
server
Returns the contents of the
$_SERVERarray. -
setParam
Sets custom values for additional request parameters.
-
toBytes
Returns the number of bytes corresponding to a string representation of a numeric parameter value.
public static function cookie ($name = null, $default = null, $type = null)
Returns information about user's cookie files.
Parameters
-
$name
Cookierecord id. If not specified, all cookie data received from user is returned. -
$default
The default value, which is returned if no value is found for the cookie record specified in
$nameparameter. -
$type
Data type to which the cookie record value must be converted. Acceptable data types are these:
int: integerstring: stringstring_trim: string with whitespace characters removed from its beginning and endarray_int: array of integersarray: array of values of arbitrary type
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
-
$name
Id of the form field which is used to upload files to the server, matches the value of the
nameattribute of HTML tag<input type="file">.
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
-
$name
GET request field name. If not specified, entire contents of the GET request are returned.
-
$default
The default value, which is returned if no value is found for the request field specified in
$nameparameter. -
$type
Data type to which the request field value must be converted. Acceptable data types are described for method cookie.
Example
waRequest::get('id', 0, 'int')
public static function getIp ($get_as_int = false)
Returns user's IP address.
Parameters
-
$get_as_int
Flag requiring to return the IP address expressed as an integer number.
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
-
$default
Default value, which is returned if user's locale cannot be determined. If
trueis specified, then the same value is used for$browser_onlyparameter. -
$browser_only
Flag requiring to determine user's locale using browser headers only and to ignore additional request parameters set using method setParam.
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 getPostMaxSize()
Returns server’s POST request size limitation in bytes.
Example
waRequest::getPostMaxSize()
Result
20971520
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 getUploadMaxFilesize()
Returns server’s uploaded file size limitation in bytes.
Example
waRequest::getUploadMaxFilesize()
Result
20971520
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
-
$check
Flag requiring to check and update the value of field
nomobilein user's PHP session. If set totrue, the following actions are performed:- If the GET request contains variable named
nomobilewith a value equivalent totrue, then fieldnomobilein user's PHP session is set totrue. If the value of this variable is equivalent tofalse, then fieldnomobileis removed from user's session. - If the GET request contains no variable named
nomobileand does contain a variable namedmobilewith a value equivalent totrue, then fieldnomobileis removed from user's session. - If, upon execution of the above actions, the value of field
nomobilein user's PHP session is equal totrue, then the method returnsfalse. Otherwise the method continues its operation so as if the value of this flag were equal tofalse.
If the flag's value is set to
false, the use of a mobile device is determined by the contents of headerHTTP_USER_AGENT. If such use is determined, the method returns of the following identifiers:androidblackberryiphoneoperapalmwindowsgeneric
- If the GET request contains variable named
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
-
$name
Name of a POST request field.
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
-
$name
Request parameter name. If not specified, the method returns the values of all available parameters.
-
$default
Default value, which is returned if no value is set for the specified parameter.
-
$type
Data type to which the value of the specified parameter must be converted. Acceptable data types are described for method cookie.
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
-
$name
Request item name. If not specified, the method returns the values of all available request items.
-
$default
Default value, which is returned if no value is set for the specified request item.
-
$type
Data type to which the value of the specified parameter must be converted. Acceptable data types are described for method cookie.
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
-
$name
Request item name. If not specified, the method returns the values of all available request items.
-
$default
Default value, which is returned if no value is set for the specified request item.
-
$type
Data type to which the value of the specified parameter must be converted. Acceptable data types are described for method cookie.
Example
waRequest::request('id')
public static function server ($name = null, $default = null, $type = null)
Returns the contents of the $_SERVER array.
Parameters
-
$name
Request item name. If not specified, the method returns the values of all available request items.
-
$default
Default value, which is returned if no value is set for the specified request item.
-
$type
Data type to which the value of the specified parameter must be converted. Acceptable data types are described for method cookie.
Example
waRequest::server('HTTP_HOST')
Result
yourdomain.com
public static function setParam ($key, $value = null)
Sets custom values for additional request parameters.
Parameters
-
$key
Parameter name.
-
$value
Parameter value. If not specified, default value
nullis set.
Example
waRequest::setParam('locale', 'en_US')
public static function toBytes ($str)
Returns the number of bytes corresponding to a string representation of a numeric parameter value.
Parameters
-
$str
String representation of a numeric parameter value; e.g., “50K”, “20M” or “1G” (only values with letters “K”, “M” and “G” are supported).
Example
waRequest::toBytes('50K')
Result
51200









