Overview

Namespaces

  • None
  • Xmf
    • Database
    • Module
      • Helper
    • Template
  • Xoops
    • Auth
    • Core
      • Cache
      • Database
        • Logging
        • Schema
      • Exception
      • Handler
        • Scheme
      • Kernel
        • Dtype
        • Handlers
        • Model
      • Lists
      • Locale
        • Punic
      • Service
        • Contract
      • Session
      • Text
        • Sanitizer
          • Extensions
      • Theme
        • Plugins
    • Form
    • Html
    • Locale
    • Module
      • Helper
      • Plugin

Classes

  • Assets
  • ComposerUtility
  • Events
  • FilterInput
  • FixedGroups
  • HttpRequest
  • Logger
  • MediaUploader
  • MimeTypes
  • PreloadItem
  • Psr0ClassLoader
  • Psr4ClassLoader
  • Random
  • Registry
  • Request
  • Security
  • XoopsTpl
  • Yaml

Interfaces

  • AttributeInterface
  • Overview
  • Namespace
  • Class
  • Tree

Class HttpRequest

HttpRequest

Namespace: Xoops\Core
Package: Xoops\Core
Category: Xoops\Core\HttpRequest
Copyright: 2011-2015 XOOPS Project (http://xoops.org)
License: GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
Author: trabis lusopoemas@gmail.com
Author: Kazumi Ono onokazu@gmail.com
Author: Richard Griffith richard@geekwright.com
Link: http://xoops.org
Located at oops_lib/Xoops/Core/HttpRequest.php
Methods summary
public static Xoops\Core\HttpRequest
# getInstance( )

get singleton instance, establish the request data on first access

get singleton instance, establish the request data on first access

Returns

Xoops\Core\HttpRequest
public null|string
# getHeader( null|string $name = null )

get a http header for the current request

get a http header for the current request

Parameters

$name
header name

Returns

null|string
public string
# getScheme( )

get the scheme of current request

get the scheme of current request

Returns

string
public string
# getHost( )

get the host from the current request

get the host from the current request

Returns

string
public static null|string
# getUri( )

get the URI of the current request

get the URI of the current request

Returns

null|string
public string
# getReferer( )

get the referer of the current request

get the referer of the current request

Returns

string
public string
# getScriptName( )

get the current script name associated with the request

get the current script name associated with the request

Returns

string
public string
# getDomain( )

Get the domain name and include $tldLength segments of the tld.

Get the domain name and include $tldLength segments of the tld.

Returns

string
Domain name without subdomains
public string
# getSubdomains( )

Get the subdomains for a host.

Get the subdomains for a host.

Returns

string
subdomain portion of host name
public string
# getClientIp( boolean $considerProxy = false )

Get the Client IP address, optionally attempting to peek behind any proxies to get a real routable address.

Get the Client IP address, optionally attempting to peek behind any proxies to get a real routable address.

Parameters

$considerProxy
true to enable proxy tests

Returns

string
public string
# getUrl( )

Return current url

Return current url

Returns

string
public string|boolean
# getEnv( string $name, mixed $default = null )

Gets an environment variable from available sources, and provides emulation for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on IIS, or SCRIPT_NAME in CGI mode). Also exposes some additional custom environment information. Note : code modifications for XOOPS

Gets an environment variable from available sources, and provides emulation for unsupported or inconsistent environment variables (i.e. DOCUMENT_ROOT on IIS, or SCRIPT_NAME in CGI mode). Also exposes some additional custom environment information. Note : code modifications for XOOPS

Parameters

$name
Environment variable name.
$default
default value

Returns

string|boolean
Environment variable setting.

Link

http://book.cakephp.org/2.0/en/core-libraries/global-constants-and-functions.html#env
public static array
# getFiles( string $name )

get files associated with the current request

get files associated with the current request

Parameters

$name
name of file

Returns

array
public boolean
# is( string $type )

Check whether or not a Request is a certain type. Uses the built in detection rules as well as additional rules defined with HttpRequest::addDetector(). Any detector can be called as is($type) or is$Type().

Check whether or not a Request is a certain type. Uses the built in detection rules as well as additional rules defined with HttpRequest::addDetector(). Any detector can be called as is($type) or is$Type().

Parameters

$type
The type of request you want to check.

Returns

boolean
Whether or not the request is the type you are checking.
protected boolean
# detectByEnv( array $detect )

detectByEnv - perform detection on detectors with an 'env' component

detectByEnv - perform detection on detectors with an 'env' component

Parameters

$detect
a detectors array entry to test against

Returns

boolean
true if detect is matched, false if not
protected boolean
# detectByParam( array $detect )

detectByParam - perform detection on detectors with an 'param' component. To match an entry with the name in the 'param' key of the $detect rule must exist in the $params property and be equal to the 'value' entry specified in the $detect array.

detectByParam - perform detection on detectors with an 'param' component. To match an entry with the name in the 'param' key of the $detect rule must exist in the $params property and be equal to the 'value' entry specified in the $detect array.

Parameters

$detect

a detectors array entry to test against. Param entries are of the form array('param' => name, 'value' => value)

Returns

boolean
true if detect is matched, false if not
public
# addDetector( string $name, array $options )

Add a new detector to the list of detectors that a request can use. There are several different formats and types of detectors that can be set.

Environment value comparison

An environment value comparison, compares a value fetched from env() to a known value the environment value is equality checked against the provided value. e.g addDetector('post', array('env' => 'REQUEST_METHOD', 'value' => 'POST'))

Pattern value comparison

Pattern value comparison allows you to compare a value fetched from env() to a regular expression. e.g addDetector('iphone', array('env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i'));

Option based comparison

Option based comparisons use a list of options to create a regular expression. Subsequent calls to add an already defined options detector will merge the options. e.g addDetector('mobile', array('env' => 'HTTP_USER_AGENT', 'options' => array('Fennec')));

Callback detectors

Callback detectors allow you to provide a 'callback' type to handle the check. The callback will receive the request object as its only parameter. e.g addDetector('custom', array('callback' => array('SomeClass', 'someMethod')));

Request parameter detectors

Allows for custom detectors on the request parameters. e.g addDetector('post', array('param' => 'requested', 'value' => 1)

Add a new detector to the list of detectors that a request can use. There are several different formats and types of detectors that can be set.

Environment value comparison

An environment value comparison, compares a value fetched from env() to a known value the environment value is equality checked against the provided value. e.g addDetector('post', array('env' => 'REQUEST_METHOD', 'value' => 'POST'))

Pattern value comparison

Pattern value comparison allows you to compare a value fetched from env() to a regular expression. e.g addDetector('iphone', array('env' => 'HTTP_USER_AGENT', 'pattern' => '/iPhone/i'));

Option based comparison

Option based comparisons use a list of options to create a regular expression. Subsequent calls to add an already defined options detector will merge the options. e.g addDetector('mobile', array('env' => 'HTTP_USER_AGENT', 'options' => array('Fennec')));

Callback detectors

Callback detectors allow you to provide a 'callback' type to handle the check. The callback will receive the request object as its only parameter. e.g addDetector('custom', array('callback' => array('SomeClass', 'someMethod')));

Request parameter detectors

Allows for custom detectors on the request parameters. e.g addDetector('post', array('param' => 'requested', 'value' => 1)

Parameters

$name
The name of the detector.
$options
The options for the detector definition. See above.
public boolean
# clientAcceptsType( string $mediaType )

Determine if a client accepts a given media type

Determine if a client accepts a given media type

Parameters

$mediaType
The content type to check for.

Returns

boolean
true if client accepts the media type, otherwise false
public array
# getAcceptMediaTypes( )

getAcceptMediaTypes returns the http-accept header as an array of media types arranged by specified preference

getAcceptMediaTypes returns the http-accept header as an array of media types arranged by specified preference

Returns

array

associative array of preference (numeric weight >0 <=1.0 ) keyed by media types, and sorted by preference

public array
# getAcceptedLanguages( )

getAcceptedLanguages returns the http-accept-language header as an array of language codes arranged by specified preference

getAcceptedLanguages returns the http-accept-language header as an array of language codes arranged by specified preference

Returns

array

associative array of preference (numeric weight >0 <=1.0 ) keyed by language code, and sorted by preference

Properties summary
protected array $params
#
protected array $detectors

The built in detectors used with is() can be modified with addDetector(). There are several ways to specify a detector, see HttpRequest::addDetector() for the various formats and ways to define detectors.

The built in detectors used with is() can be modified with addDetector(). There are several ways to specify a detector, see HttpRequest::addDetector() for the various formats and ways to define detectors.

# array( 'get' => array('env' => 'REQUEST_METHOD', 'value' => 'GET'), 'post' => array('env' => 'REQUEST_METHOD', 'value' => 'POST'), 'put' => array('env' => 'REQUEST_METHOD', 'value' => 'PUT'), 'delete' => array('env' => 'REQUEST_METHOD', 'value' => 'DELETE'), 'head' => array('env' => 'REQUEST_METHOD', 'value' => 'HEAD'), 'options' => array('env' => 'REQUEST_METHOD', 'value' => 'OPTIONS'), 'safemethod'=> array('env' => 'REQUEST_METHOD', 'options' => array('GET', 'HEAD')), 'ssl' => array('env' => 'HTTPS', 'value' => 1), 'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'), 'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'), 'mobile' => array( 'env' => 'HTTP_USER_AGENT', 'options' => array( 'Android', 'AvantGo', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' ) ), 'robot' => array( 'env' => 'HTTP_USER_AGENT', 'options' => array( /* The most common ones. */ 'Googlebot', 'msnbot', 'Slurp', 'Yahoo', /* The rest alphabetically. */ 'Arachnoidea', 'ArchitextSpider', 'Ask Jeeves', 'B-l-i-t-z-Bot', 'Baiduspider', 'BecomeBot', 'cfetch', 'ConveraCrawler', 'ExtractorPro', 'FAST-WebCrawler', 'FDSE robot', 'fido', 'geckobot', 'Gigabot', 'Girafabot', 'grub-client', 'Gulliver', 'HTTrack', 'ia_archiver', 'InfoSeek', 'kinjabot', 'KIT-Fireball', 'larbin', 'LEIA', 'lmspider', 'Lycos_Spider', 'Mediapartners-Google', 'MuscatFerret', 'NaverBot', 'OmniExplorer_Bot', 'polybot', 'Pompos', 'Scooter', 'Teoma', 'TheSuBot', 'TurnitinBot', 'Ultraseek', 'ViolaBot', 'webbandit', 'www\\.almaden\\.ibm\\.com\\/cs\\/crawler', 'ZyBorg', ) ), )
API documentation generated by ApiGen