Class WebRequest

Description

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.

Located in /includes/WebRequest.php (line 37)


	
			
Direct descendents
Class Description
 class FauxRequest WebRequest clone which takes values from a provided array.
Method Summary
 WebRequest WebRequest ()
 string appendQuery (string $query)
 string escapeAppendQuery (string $query)
 array &fix_magic_quotes (array &$arr)
 bool getBool (string $name, [bool $default = false])
 bool getCheck (string $name)
 string getFileName (string $key)
 integer getFileSize (string $key)
 string getFileTempname (string $key)
 string getFullRequestURL ()
 string getGPCText (array &$arr, string $name, string $default)
 mixed getGPCVal (array &$arr, string $name, mixed $default)
 int getInt (string $name, int $default)
 array getLimitOffset ([int $deflimit = 50], [string $optionname = 'rclimit'])
 string getRequestURL ()
 string getText (string $name, [string $default = ''])
 mixed getVal (string $name, [mixed $default = NULL])
 void getValues ()
 mixed normalizeUnicode (array $data)
 bool wasPosted ()
Methods
Constructor WebRequest (line 38)
WebRequest WebRequest ()
appendQuery (line 293)

Take an arbitrary query and rewrite the present URL to include it

string appendQuery (string $query)
  • string $query: Query string fragment; do not include initial '?'

Redefined in descendants as:
checkMagicQuotes (line 73)

If magic_quotes_gpc option is on, run the global arrays through fix_magic_quotes to strip out the stupid dlashes.

WARNING: This should only be done once! Running a second time could damage the values.

  • private:
void checkMagicQuotes ()
checkSessionCookie (line 267)

Returns true if there is a session cookie set.

This does not necessarily mean that the user is logged in!

bool checkSessionCookie ()

Redefined in descendants as:
escapeAppendQuery (line 312)

HTML-safe version of appendQuery().

string escapeAppendQuery (string $query)
  • string $query: Query string fragment; do not include initial '?'
fix_magic_quotes (line 55)

Recursively strips slashes from the given array; used for undoing the evil that is magic_quotes_gpc.

  • return: the original array
  • private:
array &fix_magic_quotes (array &$arr)
  • array &$arr: will be modified
getBool (line 195)

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.

bool getBool (string $name, [bool $default = false])
  • string $name
  • bool $default
getCheck (line 206)

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.

bool getCheck (string $name)
  • string $name
getFileName (line 377)

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.

  • return: or NULL if no such file.
string getFileName (string $key)
  • string $key
getFileSize (line 359)

Return the size of the upload, or 0.

integer getFileSize (string $key)
  • string $key
getFileTempname (line 347)

Return the path to the temporary file where PHP has stored the upload.

  • return: or NULL if no such file.
string getFileTempname (string $key)
  • string $key
getFullRequestURL (line 283)

Return the request URI with the canonical service and hostname.

string getFullRequestURL ()
getGPCText (line 151)

Fetch a value from the given array or return $default if it's not set.

\r is stripped from the text, and with some language modules there is an input transliteration applied.

  • private:
string getGPCText (array &$arr, string $name, string $default)
  • array &$arr
  • string $name
  • string $default
getGPCVal (line 122)

Fetch a value from the given array or return $default if it's not set.

  • private:
mixed getGPCVal (array &$arr, string $name, mixed $default)
  • array &$arr
  • string $name
  • mixed $default
getInt (line 183)

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.

int getInt (string $name, int $default)
  • string $name
  • int $default
getLimitOffset (line 325)

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.

  • return: first element is limit, second is offset
array getLimitOffset ([int $deflimit = 50], [string $optionname = 'rclimit'])
  • int $deflimit: Limit to use if no input and the user hasn't set the option.
  • string $optionname: To specify an option other than rclimit to pull from.
getRequestURL (line 275)

Return the path portion of the request URI.

string getRequestURL ()

Redefined in descendants as:
getText (line 223)

Fetch a text string from the given array or return $default if it's not set. \r 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.

string getText (string $name, [string $default = ''])
  • string $name
  • string $default: optional

Redefined in descendants as:
getVal (line 171)

Fetch a value from the input or return $default if it's not set.

Value may be of a string or array, and is not altered.

mixed getVal (string $name, [mixed $default = NULL])
  • string $name
  • mixed $default: optional default (or NULL)

Redefined in descendants as:
getValues (line 232)

Extracts the given named values into an array.

If no arguments are given, returns all input values. No transformation is performed on the values.

void getValues ()

Redefined in descendants as:
normalizeUnicode (line 93)

Recursively normalizes strings in the given array.

For Latin-1, strips illegal XML characters only. For Unicode, marks illegal chars and normalizes to form C.

  • return: cleaned-up version of the given
  • private:
mixed normalizeUnicode (array $data)
  • array $data: string or array
wasPosted (line 257)

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.

bool wasPosted ()

Redefined in descendants as:

Documentation generated on Sun, 20 Mar 2005 19:37:02 -0800 by phpDocumentor 1.3.0RC3