[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> WebRequest.php (summary)

Deal with importing all those nasty globals and things Copyright © 2003 Brion Vibber <[email protected]> https://www.mediawiki.org/

File Size: 1486 lines (40 kb)
Included or required:0 times
Referenced: 4 times
Includes or requires: 0 files

Defines 4 classes

WebRequest:: (53 methods):
  __construct()
  getPathInfo()
  detectServer()
  detectProtocol()
  getProtocol()
  interpolateTitle()
  extractTitle()
  normalizeUnicode()
  getGPCVal()
  getVal()
  setVal()
  unsetVal()
  getArray()
  getIntArray()
  getInt()
  getIntOrNull()
  getFloat()
  getBool()
  getFuzzyBool()
  getCheck()
  getText()
  getValues()
  getValueNames()
  getQueryValues()
  getRawQueryString()
  getRawPostString()
  getRawInput()
  getMethod()
  wasPosted()
  checkSessionCookie()
  getCookie()
  getRequestURL()
  getFullRequestURL()
  appendQuery()
  appendQueryValue()
  appendQueryArray()
  getLimitOffset()
  getFileTempname()
  getUploadError()
  getFileName()
  getUpload()
  response()
  initHeaders()
  getAllHeaders()
  getHeader()
  getSessionData()
  setSessionData()
  checkUrlExtension()
  doSecurityRedirect()
  getAcceptLang()
  getRawIP()
  getIP()
  setIP()

WebRequestUpload:: (7 methods):
  __construct()
  exists()
  getName()
  getSize()
  getTempName()
  getError()
  isIniSizeOverflow()

FauxRequest:: (21 methods):
  __construct()
  notImplemented()
  getText()
  getValues()
  getQueryValues()
  getMethod()
  wasPosted()
  getCookie()
  checkSessionCookie()
  getRequestURL()
  getProtocol()
  getHeader()
  setHeader()
  getSessionData()
  setSessionData()
  getSessionArray()
  getRawQueryString()
  getRawPostString()
  getRawInput()
  checkUrlExtension()
  getRawIP()

DerivativeRequest:: (10 methods):
  __construct()
  getCookie()
  checkSessionCookie()
  getHeader()
  getAllHeaders()
  getSessionData()
  setSessionData()
  getAcceptLang()
  getIP()
  getProtocol()


Class: WebRequest  - X-Ref

The WebRequest class encapsulates getting at data passed in the
URL or via a POSTed form 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.

__construct()   X-Ref
Cached URL protocol


getPathInfo( $want = 'all' )   X-Ref
Extract relevant query arguments from the http request uri's path
to be merged with the normal php provided query arguments.
Tries to use the REQUEST_URI data if available and parses it
according to the wiki's configuration looking for any known pattern.

If the REQUEST_URI is not provided we'll fall back on the PATH_INFO
provided by the server if any and use that to set a 'title' parameter.

param: string $want If this is not 'all', then the function
return: array Any query arguments found in path matches.

detectServer()   X-Ref
Work out an appropriate URL prefix containing scheme and host, based on
information detected from $_SERVER

return: string

detectProtocol()   X-Ref
Detect the protocol from $_SERVER.
This is for use prior to Setup.php, when no WebRequest object is available.
At other times, use the non-static function getProtocol().

return: array

getProtocol()   X-Ref
Get the current URL protocol (http or https)

return: string

interpolateTitle()   X-Ref
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.


extractTitle( $path, $bases, $key = false )   X-Ref
URL rewriting function; tries to extract page title and,
optionally, one other fixed parameter value from a URL path.

param: string $path The URL path given from the client
param: array $bases One or more URLs, optionally with $1 at the end
param: string $key If provided, the matching key in $bases will be
return: array Array of URL variables to interpolate; empty if no match

normalizeUnicode( $data )   X-Ref
Recursively normalizes UTF-8 strings in the given array.

param: string|array $data
return: array|string Cleaned-up version of the given

getGPCVal( $arr, $name, $default )   X-Ref
Fetch a value from the given array or return $default if it's not set.

param: array $arr
param: string $name
param: mixed $default
return: mixed

getVal( $name, $default = null )   X-Ref
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().

param: string $name
param: string $default Optional default (or null)
return: string

setVal( $key, $value )   X-Ref
Set an arbitrary value into our get/post data.

param: string $key Key name to use
param: mixed $value Value to set
return: mixed Old value if one was present, null otherwise

unsetVal( $key )   X-Ref
Unset an arbitrary value from our get/post data.

param: string $key Key name to use
return: mixed Old value if one was present, null otherwise

getArray( $name, $default = null )   X-Ref
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.

param: string $name
param: array $default Optional default (or null)
return: array

getIntArray( $name, $default = null )   X-Ref
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.

param: string $name
param: array $default Option default (or null)
return: array Array of ints

getInt( $name, $default = 0 )   X-Ref
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.

param: string $name
param: int $default
return: int

getIntOrNull( $name )   X-Ref
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.

param: string $name
return: int|null

getFloat( $name, $default = 0.0 )   X-Ref
Fetch a floating point value from the input or return $default if not set.
Guaranteed to return a float; non-numeric input will typically
return 0.

param: string $name
param: float $default
return: float

getBool( $name, $default = false )   X-Ref
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.

param: string $name
param: bool $default
return: bool

getFuzzyBool( $name, $default = false )   X-Ref
Fetch a boolean value from the input or return $default if not set.
Unlike getBool, the string "false" will result in boolean false, which is
useful when interpreting information sent from JavaScript.

param: string $name
param: bool $default
return: bool

getCheck( $name )   X-Ref
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.

param: string $name
return: bool

getText( $name, $default = '' )   X-Ref
Fetch a text string from the given array or return $default if it's not
set. Carriage returns are 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).

param: string $name
param: string $default Optional
return: string

getValues()   X-Ref
Extracts the given named values into an array.
If no arguments are given, returns all input values.
No transformation is performed on the values.

return: array

getValueNames( $exclude = array()   X-Ref
Returns the names of all input values excluding those in $exclude.

param: array $exclude
return: array

getQueryValues()   X-Ref
Get the values passed in the query string.
No transformation is performed on the values.

return: array

getRawQueryString()   X-Ref
Return the contents of the Query with no decoding. Use when you need to
know exactly what was sent, e.g. for an OAuth signature over the elements.

return: string

getRawPostString()   X-Ref
Return the contents of the POST with no decoding. Use when you need to
know exactly what was sent, e.g. for an OAuth signature over the elements.

return: string

getRawInput()   X-Ref
Return the raw request body, with no processing. Cached since some methods
disallow reading the stream more than once. As stated in the php docs, this
does not work with enctype="multipart/form-data".

return: string

getMethod()   X-Ref
Get the HTTP method used for this request.

return: string

wasPosted()   X-Ref
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.

return: bool

checkSessionCookie()   X-Ref
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).

return: bool

getCookie( $key, $prefix = null, $default = null )   X-Ref
Get a cookie from the $_COOKIE jar

param: string $key The name of the cookie
param: string $prefix A prefix to use for the cookie name, if not $wgCookiePrefix
param: mixed $default What to return if the value isn't found
return: mixed Cookie value or $default if the cookie not set

getRequestURL()   X-Ref
Return the path and query string portion of the request URI.
This will be suitable for use as a relative link in HTML output.

return: string

getFullRequestURL()   X-Ref
Return the request URI with the canonical service and hostname, path,
and query string. This will be suitable for use as an absolute link
in HTML or other output.

If $wgServer is protocol-relative, this will return a fully
qualified URL with the protocol that was used for this request.

return: string

appendQuery( $query )   X-Ref
Take an arbitrary query and rewrite the present URL to include it

param: string $query Query string fragment; do not include initial '?'
return: string

appendQueryValue( $key, $value, $onlyquery = false )   X-Ref

param: string $key
param: string $value
param: bool $onlyquery
return: string

appendQueryArray( $array, $onlyquery = false )   X-Ref
Appends or replaces value of query variables.

param: array $array Array of values to replace/add to query
param: bool $onlyquery Whether to only return the query string and not the complete URL
return: string

getLimitOffset( $deflimit = 50, $optionname = 'rclimit' )   X-Ref
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.

param: int $deflimit Limit to use if no input and the user hasn't set the option.
param: string $optionname To specify an option other than rclimit to pull from.
return: array First element is limit, second is offset

getFileTempname( $key )   X-Ref
Return the path to the temporary file where PHP has stored the upload.

param: string $key
return: string|null String or null if no such file.

getUploadError( $key )   X-Ref
Return the upload error or 0

param: string $key
return: int

getFileName( $key )   X-Ref
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.

param: string $key
return: string|null String or null if no such file.

getUpload( $key )   X-Ref
Return a WebRequestUpload object corresponding to the key

param: string $key
return: WebRequestUpload

response()   X-Ref
Return a handle to WebResponse style object, for setting cookies,
headers and other stuff, for Request being worked on.

return: WebResponse

initHeaders()   X-Ref
Initialise the header list


getAllHeaders()   X-Ref
Get an array containing all request headers

return: array Mapping header name to its value

getHeader( $name )   X-Ref
Get a request header, or false if it isn't set

param: string $name Case-insensitive header name
return: string|bool False on failure

getSessionData( $key )   X-Ref
Get data from $_SESSION

param: string $key Name of key in $_SESSION
return: mixed

setSessionData( $key, $data )   X-Ref
Set session data

param: string $key Name of key in $_SESSION
param: mixed $data

checkUrlExtension( $extWhitelist = array()   X-Ref
Check if Internet Explorer will detect an incorrect cache extension in
PATH_INFO or QUERY_STRING. If the request can't be allowed, show an error
message or redirect to a safer URL. Returns true if the URL is OK, and
false if an error message has been shown and the request should be aborted.

param: array $extWhitelist
return: bool

doSecurityRedirect( $url )   X-Ref
Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in
IE 6. Returns true if it was successful, false otherwise.

param: string $url
return: bool

getAcceptLang()   X-Ref
Parse the Accept-Language header sent by the client into an array

return: array Array( languageCode => q-value ) sorted by q-value in

getRawIP()   X-Ref
Fetch the raw IP from the request

return: string

getIP()   X-Ref
Work out the IP address based on various globals
For trusted proxies, use the XFF client IP (first of the chain)

return: string

setIP( $ip )   X-Ref

param: string $ip
return: void

Class: WebRequestUpload  - X-Ref

Object to access the $_FILES array

__construct( $request, $key )   X-Ref
Constructor. Should only be called by WebRequest

param: WebRequest $request The associated request
param: string $key Key in $_FILES array (name of form field)

exists()   X-Ref
Return whether a file with this name was uploaded.

return: bool

getName()   X-Ref
Return the original filename of the uploaded file

return: string|null Filename or null if non-existent

getSize()   X-Ref
Return the file size of the uploaded file

return: int File size or zero if non-existent

getTempName()   X-Ref
Return the path to the temporary file

return: string|null Path or null if non-existent

getError()   X-Ref
Return the upload error. See link for explanation
http://www.php.net/manual/en/features.file-upload.errors.php

return: int One of the UPLOAD_ constants, 0 if non-existent

isIniSizeOverflow()   X-Ref
Returns whether this upload failed because of overflow of a maximum set
in php.ini

return: bool

Class: FauxRequest  - X-Ref

WebRequest clone which takes values from a provided array.

__construct( $data = array()   X-Ref

param: array $data Array of *non*-urlencoded key => value pairs, the
param: bool $wasPosted Whether to treat the data as POST
param: array|null $session Session array or null
param: string $protocol 'http' or 'https'

notImplemented( $method )   X-Ref

param: string $method

getText( $name, $default = '' )   X-Ref

param: string $name
param: string $default
return: string

getValues()   X-Ref

return: array

getQueryValues()   X-Ref

return: array

getMethod()   X-Ref
No description

wasPosted()   X-Ref

return: bool

getCookie( $key, $prefix = null, $default = null )   X-Ref
No description

checkSessionCookie()   X-Ref
No description

getRequestURL()   X-Ref
No description

getProtocol()   X-Ref
No description

getHeader( $name )   X-Ref

param: string $name The name of the header to get (case insensitive).
return: bool|string

setHeader( $name, $val )   X-Ref

param: string $name
param: string $val

getSessionData( $key )   X-Ref

param: string $key
return: array|null

setSessionData( $key, $data )   X-Ref

param: string $key
param: array $data

getSessionArray()   X-Ref

return: array|mixed|null

getRawQueryString()   X-Ref
FauxRequests shouldn't depend on raw request data (but that could be implemented here)

return: string

getRawPostString()   X-Ref
FauxRequests shouldn't depend on raw request data (but that could be implemented here)

return: string

getRawInput()   X-Ref
FauxRequests shouldn't depend on raw request data (but that could be implemented here)

return: string

checkUrlExtension( $extWhitelist = array()   X-Ref

param: array $extWhitelist
return: bool

getRawIP()   X-Ref

return: string

Class: DerivativeRequest  - X-Ref

Similar to FauxRequest, but only fakes URL parameters and method
(POST or GET) and use the base request for the remaining stuff
(cookies, session and headers).

__construct( WebRequest $base, $data, $wasPosted = false )   X-Ref

param: WebRequest $base
param: array $data Array of *non*-urlencoded key => value pairs, the
param: bool $wasPosted Whether to treat the data as POST

getCookie( $key, $prefix = null, $default = null )   X-Ref
No description

checkSessionCookie()   X-Ref
No description

getHeader( $name )   X-Ref
No description

getAllHeaders()   X-Ref
No description

getSessionData( $key )   X-Ref
No description

setSessionData( $key, $data )   X-Ref
No description

getAcceptLang()   X-Ref
No description

getIP()   X-Ref
No description

getProtocol()   X-Ref
No description



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1