Inherited by FauxRequest.
Public Member Functions | |
__construct () | |
interpolateTitle () | |
Check for title, action, and/or variant data in the URL and interpolate it into the GET variables. | |
& | fix_magic_quotes (&$arr) |
Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc. | |
checkMagicQuotes () | |
If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stupid slashes. | |
normalizeUnicode ($data) | |
Recursively normalizes UTF-8 strings in the given array. | |
getGPCVal ($arr, $name, $default) | |
Fetch a value from the given array or return $default if it's not set. | |
getVal ($name, $default=NULL) | |
Fetch a scalar from the input or return $default if it's not set. | |
setVal ($key, $value) | |
Set an aribtrary value into our get/post data. | |
getArray ($name, $default=NULL) | |
Fetch an array from the input or return $default if it's not set. | |
getIntArray ($name, $default=NULL) | |
Fetch an array of integers, or return $default if it's not set. | |
getInt ($name, $default=0) | |
Fetch an integer value from the input or return $default if not set. | |
getIntOrNull ($name) | |
Fetch an integer value from the input or return null if empty. | |
getBool ($name, $default=false) | |
Fetch a boolean value from the input or return $default if not set. | |
getCheck ($name) | |
Return true if the named value is set in the input, whatever that value is (even "0"). | |
getText ($name, $default= '') | |
Fetch a text string from the given array or return $default if it's not set. | |
getValues () | |
Extracts the given named values into an array. | |
wasPosted () | |
Returns true if the present request was reached by a POST operation, false otherwise (GET, HEAD, or command-line). | |
checkSessionCookie () | |
Returns true if there is a session cookie set. | |
getRequestURL () | |
Return the path portion of the request URI. | |
getFullRequestURL () | |
Return the request URI with the canonical service and hostname. | |
appendQuery ($query) | |
Take an arbitrary query and rewrite the present URL to include it. | |
escapeAppendQuery ($query) | |
HTML-safe version of appendQuery(). | |
appendQueryValue ($key, $value, $onlyquery=false) | |
appendQueryArray ($array, $onlyquery=false) | |
Appends or replaces value of query variables. | |
getLimitOffset ($deflimit=50, $optionname= 'rclimit') | |
Check for limit and offset parameters on the input, and return sensible defaults if not given. | |
getFileTempname ($key) | |
Return the path to the temporary file where PHP has stored the upload. | |
getFileSize ($key) | |
Return the size of the upload, or 0. | |
getUploadError ($key) | |
Return the upload error or 0. | |
getFileName ($key) | |
Return the original filename of the uploaded file, as reported by the submitting user agent. | |
response () | |
Return a handle to WebResponse style object, for setting cookies, headers and other stuff, for Request being worked on. | |
getHeader ($name) | |
Get a request header, or false if it isn't set. | |
getSessionData ($key) | |
setSessionData ($key, $data) | |
Public Attributes | |
$data = array() | |
$headers | |
Private Member Functions | |
extractTitle ($path, $bases, $key=false) | |
Internal URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value from a URL path. | |
Private Attributes | |
$_response |
Some entry points may use this file without first enabling the autoloader. The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form, handling remove of "magic quotes" slashes, stripping illegal input characters and normalizing Unicode sequences.
Usually this is used via a global singleton, $wgRequest. You should not create a second WebRequest object; make a FauxRequest object if you want to pass arbitrary data to some function in place of the web input.
Definition at line 45 of file WebRequest.php.
WebRequest::__construct | ( | ) |
WebRequest::appendQuery | ( | $ | query | ) |
Take an arbitrary query and rewrite the present URL to include it.
$query | String: query string fragment; do not include initial '?' |
Reimplemented in FauxRequest.
Definition at line 478 of file WebRequest.php.
References $wgTitle.
Referenced by escapeAppendQuery().
WebRequest::appendQueryArray | ( | $ | array, | |
$ | onlyquery = false | |||
) |
Appends or replaces value of query variables.
$array | Array of values to replace/add to query | |
$onlyquery | Bool: whether to only return the query string and not the complete URL |
Definition at line 518 of file WebRequest.php.
References $wgTitle, and wfArrayToCGI().
Referenced by appendQueryValue().
WebRequest::appendQueryValue | ( | $ | key, | |
$ | value, | |||
$ | onlyquery = false | |||
) |
WebRequest::checkMagicQuotes | ( | ) |
If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stupid slashes.
WARNING: This should only be done once! Running a second time could damage the values.
Definition at line 184 of file WebRequest.php.
References $_SERVER, and fix_magic_quotes().
Referenced by __construct().
WebRequest::checkSessionCookie | ( | ) |
Returns true if there is a session cookie set.
This does not necessarily mean that the user is logged in!
If you want to check for an open session, use session_id() instead; that will also tell you if the session was opened during the current request (in which case the cookie will be sent back to the client at the end of the script run).
Reimplemented in FauxRequest.
Definition at line 425 of file WebRequest.php.
WebRequest::escapeAppendQuery | ( | $ | query | ) |
HTML-safe version of appendQuery().
$query | String: query string fragment; do not include initial '?' |
Definition at line 503 of file WebRequest.php.
References appendQuery().
WebRequest::extractTitle | ( | $ | path, | |
$ | bases, | |||
$ | key = false | |||
) | [private] |
Internal URL rewriting function; tries to extract page title and, optionally, one other fixed parameter value from a URL path.
$path | string: the URL path given from the client | |
$bases | array: one or more URLs, optionally with $1 at the end | |
$key | string: if provided, the matching key in $bases will be passed on as the value of this URL parameter |
Definition at line 140 of file WebRequest.php.
Referenced by interpolateTitle().
& WebRequest::fix_magic_quotes | ( | &$ | arr | ) |
Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc.
$arr | array: will be modified |
Definition at line 166 of file WebRequest.php.
References $key.
Referenced by checkMagicQuotes().
WebRequest::getArray | ( | $ | name, | |
$ | default = NULL | |||
) |
Fetch an array from the input or return $default if it's not set.
If source was scalar, will return an array with a single element. If no source and no default, returns NULL.
$name | string | |
$default | array: optional default (or NULL) |
Definition at line 282 of file WebRequest.php.
References $name, and getGPCVal().
Referenced by getIntArray().
WebRequest::getBool | ( | $ | name, | |
$ | default = false | |||
) |
Fetch a boolean value from the input or return $default if not set.
Guaranteed to return true or false, with normal PHP semantics for boolean interpretation of strings.
$name | string | |
$default | bool |
Definition at line 343 of file WebRequest.php.
References $name, and getVal().
Referenced by FormOptions::fetchValuesFromRequest().
WebRequest::getCheck | ( | $ | name | ) |
Return true if the named value is set in the input, whatever that value is (even "0").
Return false if the named value is not set. Example use is checking for the presence of check boxes in forms.
$name | string |
Definition at line 354 of file WebRequest.php.
WebRequest::getFileName | ( | $ | key | ) |
Return the original filename of the uploaded file, as reported by the submitting user agent.
HTML-style character entities are interpreted and normalized to Unicode normalization form C, in part to deal with weird input from Safari with non-ASCII filenames.
Other than this the name is not verified for being a safe filename.
$key | String: |
Definition at line 600 of file WebRequest.php.
References $key, $name, UtfNormal::cleanUp(), Sanitizer::decodeCharReferences(), and wfDebug().
WebRequest::getFileSize | ( | $ | key | ) |
Return the size of the upload, or 0.
$key | String: |
Definition at line 570 of file WebRequest.php.
References $key.
WebRequest::getFileTempname | ( | $ | key | ) |
Return the path to the temporary file where PHP has stored the upload.
$key | String: |
Definition at line 558 of file WebRequest.php.
References $key.
WebRequest::getFullRequestURL | ( | ) |
Return the request URI with the canonical service and hostname.
Definition at line 468 of file WebRequest.php.
References $wgServer, and getRequestURL().
WebRequest::getGPCVal | ( | $ | arr, | |
$ | name, | |||
$ | default | |||
) |
Fetch a value from the given array or return $default if it's not set.
$arr | array | |
$name | string | |
$default | mixed |
Definition at line 221 of file WebRequest.php.
References $data, $name, $wgContLang, and normalizeUnicode().
Referenced by getArray(), and getVal().
WebRequest::getHeader | ( | $ | name | ) |
Get a request header, or false if it isn't set.
$name | String: case-insensitive header name |
Reimplemented in FauxRequest.
Definition at line 630 of file WebRequest.php.
WebRequest::getInt | ( | $ | name, | |
$ | default = 0 | |||
) |
Fetch an integer value from the input or return $default if not set.
Guaranteed to return an integer; non-numeric input will typically return 0.
$name | string | |
$default | int |
Definition at line 317 of file WebRequest.php.
References $name, and getVal().
Referenced by FormOptions::fetchValuesFromRequest(), and getLimitOffset().
WebRequest::getIntArray | ( | $ | name, | |
$ | default = NULL | |||
) |
Fetch an array of integers, or return $default if it's not set.
If source was scalar, will return an array with a single element. If no source and no default, returns NULL. If an array is returned, contents are guaranteed to be integers.
$name | string | |
$default | array: option default (or NULL) |
Definition at line 301 of file WebRequest.php.
References $name, and getArray().
WebRequest::getIntOrNull | ( | $ | name | ) |
Fetch an integer value from the input or return null if empty.
Guaranteed to return an integer or null; non-numeric input will typically return null.
$name | string |
Definition at line 328 of file WebRequest.php.
References $name, and getVal().
Referenced by FormOptions::fetchValuesFromRequest().
WebRequest::getLimitOffset | ( | $ | deflimit = 50 , |
|
$ | optionname = 'rclimit' | |||
) |
Check for limit and offset parameters on the input, and return sensible defaults if not given.
The limit must be positive and is capped at 5000. Offset must be positive but is not capped.
$deflimit | Integer: limit to use if no input and the user hasn't set the option. | |
$optionname | String: to specify an option other than rclimit to pull from. |
Definition at line 536 of file WebRequest.php.
WebRequest::getRequestURL | ( | ) |
Return the path portion of the request URI.
Reimplemented in FauxRequest.
Definition at line 433 of file WebRequest.php.
References $_SERVER.
Referenced by getFullRequestURL().
WebRequest::getSessionData | ( | $ | key | ) |
WebRequest::getText | ( | $ | name, | |
$ | default = '' | |||
) |
Fetch a text string from the given array or return $default if it's not set.
is stripped from the text, and with some language modules there is an input transliteration applied. This should generally be used for form <textarea> and <input> fields. Used for user-supplied freeform text input (for which input transformations may be required - e.g. Esperanto x-coding).
$name | string | |
$default | string: optional |
Reimplemented in FauxRequest.
Definition at line 373 of file WebRequest.php.
References $name, $wgContLang, and getVal().
Referenced by FormOptions::fetchValuesFromRequest().
WebRequest::getUploadError | ( | $ | key | ) |
Return the upload error or 0.
$key | String: |
Definition at line 582 of file WebRequest.php.
References $key.
WebRequest::getVal | ( | $ | name, | |
$ | default = NULL | |||
) |
Fetch a scalar from the input or return $default if it's not set.
Returns a string. Arrays are discarded. Useful for non-freeform text inputs (e.g. predefined internal text keys selected by a drop-down menu). For freeform input, see getText().
$name | string | |
$default | string: optional default (or NULL) |
Definition at line 249 of file WebRequest.php.
References $name, and getGPCVal().
Referenced by getBool(), getCheck(), getInt(), getIntOrNull(), FauxRequest::getText(), getText(), and getValues().
WebRequest::getValues | ( | ) |
Extracts the given named values into an array.
If no arguments are given, returns all input values. No transformation is performed on the values.
Reimplemented in FauxRequest.
Definition at line 385 of file WebRequest.php.
WebRequest::interpolateTitle | ( | ) |
Check for title, action, and/or variant data in the URL and interpolate it into the GET variables.
This should only be run after $wgContLang is available, as we may need the list of language variants to determine available variant URLs.
Definition at line 68 of file WebRequest.php.
References $_SERVER, $key, $path, $url, $wgActionPaths, $wgArticlePath, $wgContLang, $wgScript, $wgUsePathInfo, $wgVariantArticlePath, and extractTitle().
WebRequest::normalizeUnicode | ( | $ | data | ) |
Recursively normalizes UTF-8 strings in the given array.
$data | string or array |
Definition at line 201 of file WebRequest.php.
References $data, $key, and UtfNormal::cleanUp().
Referenced by getGPCVal().
WebRequest::response | ( | ) |
Return a handle to WebResponse style object, for setting cookies, headers and other stuff, for Request being worked on.
Definition at line 618 of file WebRequest.php.
WebRequest::setSessionData | ( | $ | key, | |
$ | data | |||
) |
WebRequest::setVal | ( | $ | key, | |
$ | value | |||
) |
Set an aribtrary value into our get/post data.
$key | string Key name to use | |
$value | mixed Value to set |
Definition at line 267 of file WebRequest.php.
References $key.
WebRequest::wasPosted | ( | ) |
Returns true if the present request was reached by a POST operation, false otherwise (GET, HEAD, or command-line).
Note that values retrieved by the object may come from the GET URL etc even on a POST request.
Reimplemented in FauxRequest.
Definition at line 410 of file WebRequest.php.
References $_SERVER.
WebRequest::$_response [private] |
Definition at line 48 of file WebRequest.php.
WebRequest::$data = array() |
Definition at line 46 of file WebRequest.php.
Referenced by FauxRequest::FauxRequest(), getGPCVal(), normalizeUnicode(), and setSessionData().
WebRequest::$headers |
Definition at line 47 of file WebRequest.php.