Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZHTTPTool Class Reference
Utility classes » HTTP utilities

Provides access to HTTP post,get and session variables. More...

## Public Member Functions
| __construct ()
| setPostVariable ( $var, $value)
| postVariable ( $var, $fallbackValue=null)
| hasPostVariable ( $var)
| setGetVariable ( $var, $value)
| getVariable ( $var, $fallbackValue=null)
| hasGetVariable ( $var)
| hasVariable ( $var)
| variable ( $var, $fallbackValue=null)
| attributes ()
| hasAttribute ( $attr)
| attribute ( $attr)
| createPostVarsFromImageButtons ()
| setSessionVariable ( $name, $value)
| removeSessionVariable ( $name)
| hasSessionVariable ( $name, $forceStart=true)
& | sessionVariable ( $name, $fallbackValue=null)
| sessionID ()
| setSessionID ( $sessionKey)

## Static Public Member Functions
static | instance ()
static | sendHTTPRequest ( $uri, $port=false, $postParameters=false, $userAgent='eZ Publish', $passthrough=true, array $cookies=array())
static | parseHTTPResponse (&$response, &$header, &$body)
static | username ()
static | password ()
static | createRedirectUrl ( $path, $parameters=array())
static | redirect ( $path, $parameters=array(), $status=false, $encodeURL=true, $returnRedirectObject=false)
static | headerVariable ( $headerName, $headerData)
static | getDataByURL ( $url, $justCheckURL=false, $userAgent=false, $forceGetRequest=false)

## Public Attributes
| $UseFullUrl

## Detailed Description

Provides access to HTTP post,get and session variables.

See PHP manual on Predefined Variables for more information.

Definition at line 23 of file ezhttptool.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZHTTPTool::__construct | ( |  | ) |

Initializes the class. Use eZHTTPTool::instance to get a single instance.

Definition at line 32 of file ezhttptool.php.

## Member Function Documentation

## ◆ attribute()

eZHTTPTool::attribute | ( |  | $attr | ) |

Returns
  the value for the attribute $attr or null if the attribute does not exist.

Definition at line 170 of file ezhttptool.php.

## ◆ attributes()

eZHTTPTool::attributes | ( |  | ) |

Returns
  the attributes for this object.

Definition at line 154 of file ezhttptool.php.

Referenced by hasAttribute().

## ◆ createPostVarsFromImageButtons()

eZHTTPTool::createPostVarsFromImageButtons | ( |  | ) |

Definition at line 635 of file ezhttptool.php.

## ◆ createRedirectUrl()

static eZHTTPTool::createRedirectUrl | ( |  | $path,
|  |  | $parameters = `array()`
| ) |  |
| static

Sends a redirect path to the browser telling it to load the new path. By default only $path is required, other parameters will be fetched automatically to create a HTTP/1.1 compatible header. The input $parameters may contain the following keys.

- host - the name of the host, default will fetch the currenty hostname
- protocol - which protocol to use, default will use HTTP
- port - the port on the host
- username - a username which is required to login on the site
- password - if username is supplied this password will be used for authentication

The path may be specified relativily `rel/ative`, from root `/a/root`, with hostname change `//myhost`.com/a/root/rel/ative, with protocol `http://myhost.com/a/root/rel/ative`. Also port may be placed in the path string. It is recommended that the path only contain a plain root path and instead send the rest as optional parameters, the support for different kinds of paths is only incase you get URLs externally which contains any of the above cases.

Note
  The redirection does not happen immedietaly and the script execution will continue.

Definition at line 488 of file ezhttptool.php.

References eZSys\hostname(), eZSys\isSSLNow(), eZSys\serverProtocol(), and eZSys\serverVariable().

Referenced by redirect().

## ◆ getDataByURL()

static eZHTTPTool::getDataByURL | ( |  | $url,
|  |  | $justCheckURL = `false`,
|  |  | $userAgent = `false`,
|  |  | $forceGetRequest = `false`
| ) |  |
| static

Parameters

  string | $url | url to get data from
  bool | $justCheckURL | if true, we should check url only not downloading data.
  string | $userAgent | override userAgent request header
  bool | $forceGetRequest | if true, force curl to perform a 'GET' request even if just checking url.

Returns
  string|bool data from $url, false if invalid URL.

Definition at line 739 of file ezhttptool.php.

Referenced by eZRSSImport\getRSSVersion(), and eZStaticCache\storeCache().

## ◆ getVariable()

eZHTTPTool::getVariable | ( |  | $var,
|  |  | $fallbackValue = `null`
| ) |  |

Returns
  the HTTP get variable $var, or $fallbackValue if the get variable does not exist, or null if $fallbackValue is omitted.

See also
  variable

Definition at line 87 of file ezhttptool.php.

References eZDebug\writeWarning().

## ◆ hasAttribute()

eZHTTPTool::hasAttribute | ( |  | $attr | ) |

Returns
  true if the attribute $attr exist.

Definition at line 162 of file ezhttptool.php.

References attributes().

## ◆ hasGetVariable()

eZHTTPTool::hasGetVariable | ( |  | $var | ) |

Returns
  true if the HTTP get variable $var exist.

See also
  hasVariable

Definition at line 106 of file ezhttptool.php.

## ◆ hasPostVariable()

eZHTTPTool::hasPostVariable | ( |  | $var | ) |

Returns
  true if the HTTP post variable $var exist.

See also
  hasVariable

Definition at line 69 of file ezhttptool.php.

Referenced by eZHTTPPersistence\fetchElement(), eZBinaryFileType\isDeletingFile(), and eZHTTPPersistence\splitSelected().

## ◆ hasSessionVariable()

eZHTTPTool::hasSessionVariable | ( |  | $name,
|  |  | $forceStart = `true`
| ) |  |

Check if session variable $name exists

Parameters

  string | $name |
  bool | $forceStart | Force session start if true (default)

Returns
  bool|null Null if session has not started and $forceStart is false

Definition at line 692 of file ezhttptool.php.

## ◆ hasVariable()

eZHTTPTool::hasVariable | ( |  | $var | ) |

Returns
  true if the HTTP post/get variable $var exists.

See also
  hasPostVariable

Definition at line 115 of file ezhttptool.php.

## ◆ headerVariable()

static eZHTTPTool::headerVariable | ( |  | $headerName,
|  |  | $headerData
| ) |  |
| static

Sets the header variable $headerName to have the data $headerData.

Note
  Calls PHPs header() with a constructed string.

Definition at line 630 of file ezhttptool.php.

Referenced by redirect().

## ◆ instance()

static eZHTTPTool::instance | ( |  | ) |
| static

Return a unique instance of the eZHTTPTool class

Returns
  eZHTTPTool

Definition at line 189 of file ezhttptool.php.

Referenced by eZContentBrowse\__construct(), eZContentUpload\__construct(), eZWizardBase\__construct(), eZUser\_loginUser(), eZModule\actionParameter(), eZURLOperator\applyQuotes(), eZContentBrowse\browse(), eZSearch\buildSearchArray(), eZContentClass\canInstantiateClassList(), eZUser\checkUser(), eZUserLoginHandler\checkUser(), eZContentUpload\cleanup(), eZUser\cleanup(), eZContentUpload\cleanupAll(), eZTemplateCompiler\compilationFilename(), eZContentObjectTreeNodeOperations\copy(), eZWizardBaseClassLoader\createClass(), eZModule\currentAction(), eZBasket\currentBasket(), eZWishList\currentWishList(), eZCollaborationItemHandler\customInput(), eZObjectRelationListType\customObjectAttributeHTTPAction(), eZMultiOption2Type\editTemplate(), eZContentObjectEditHandler\executeInputHandlers(), eZRole\expireCache(), eZDefaultShopAccountHandler\fetchAccountInformation(), eZUserDiscountRule\fetchIDListByUserID(), eZContentObject\fetchInput(), eZContentObject\fixupInput(), eZUserLoginHandler\forceLogin(), eZPaymentGatewayType\getCurrentGatewayType(), eZContentObject\handleAllCustomHTTPActions(), eZContentObject\handleCustomHTTPActions(), eZModule\hasActionParameter(), eZCollaborationItemHandler\hasCustomInput(), eZUser\instance(), eZCollaborationItemHandler\isCustomAction(), eZPreferences\isStoredInSession(), eZLDAPUser\loginUser(), eZTextFileUser\loginUser(), eZUser\logoutCurrent(), eZURLOperator\modify(), eZUserLoginHandler\preCheck(), eZRedirectManager\redirectURI(), eZContentBrowse\result(), eZUserLoginHandler\sessionCleanup(), eZPreferences\sessionCleanup(), eZContentUpload\setResult(), eZModuleOperationInfo\storeBodyMemento(), eZPreferences\storedSessionValue(), eZPreferences\storeInSession(), eZContentUpload\upload(), eZURLOperator\urlTransformation(), eZContentObject\validateInput(), eZContentObjectEditHandler\validateInputHandlers(), eZPreferences\value(), and eZPreferences\values().

## ◆ parseHTTPResponse()

static eZHTTPTool::parseHTTPResponse | ( | & | $response,
|  | & | $header,
|  | & | $body
| ) |  |
| static

Definition at line 384 of file ezhttptool.php.

## ◆ password()

static eZHTTPTool::password | ( |  | ) |
| static

Returns password from HTTP authentication or false if not logged in. See http://en.php.net/features.http-auth why you can‘t safely use $_SERVER['PHP_AUTH_PW’].

Definition at line 446 of file ezhttptool.php.

## ◆ postVariable()

eZHTTPTool::postVariable | ( |  | $var,
|  |  | $fallbackValue = `null`
| ) |  |

Returns
  the HTTP post variable $var, or $fallbackValue if the post variable does not exist , or null if $fallbackValue is omitted.

See also
  variable

Definition at line 50 of file ezhttptool.php.

References eZDebug\writeWarning().

Referenced by eZHTTPPersistence\fetchElement(), eZBinaryFileType\isDeletingFile(), and eZHTTPPersistence\splitSelected().

## ◆ redirect()

static eZHTTPTool::redirect | ( |  | $path,
|  |  | $parameters = `array()`,
|  |  | $status = `false`,
|  |  | $encodeURL = `true`,
|  |  | $returnRedirectObject = `false`
| ) |  |
| static

Performs an HTTP redirect.

Parameters

  string | $path | The path to redirect to
  array | $parameters | See createRedirectUrl(). Defaults to empty array.
  bool | $status | The HTTP status code as a string (code + text, e.g. "302 Found"). Defaults to false.
  bool | $encodeURL | Encodes the URL. This should normally be true, but may be set to false to avoid double encoding when redirect() is called twice. Defaults to true
  bool | $returnRedirectObject | If true, will return an ezpKernelRedirect object.

Returns
  null|ezpKernelRedirect

Definition at line 593 of file ezhttptool.php.

References createRedirectUrl(), eZURI\encodeURL(), and headerVariable().

Referenced by eZUserLoginHandler\checkUser(), and eZUser\instance().

## ◆ removeSessionVariable()

eZHTTPTool::removeSessionVariable | ( |  | $name | ) |

Unset the session variable $name

Parameters

  string | $name |

Returns
  bool

Definition at line 680 of file ezhttptool.php.

## ◆ sendHTTPRequest()

static eZHTTPTool::sendHTTPRequest | ( |  | $uri,
|  |  | $port = `false`,
|  |  | $postParameters = `false`,
|  |  | $userAgent = `'eZ Publish'`,
|  |  | $passthrough = `true`,
|  | array | $cookies = `array()`
| ) |  |
| static

Sends a http request to the specified host. Using https:// requires compiled in OpenSSL support.

Parameters

  string | $uri | http/https address or only path to send request to current eZ Publish instance examples: http://ez.no, https://secure.ez.no or content/view/full/2
  int | false | $port | Which port to connect to, default 80, uses port in $uri if present when $port = false
  array | false | $postParameters | Optional post parameters array, if no post parameters are present, a GET request will be sent
  string | $userAgent | User agent string, default will be 'eZ Publish'
  bool | $passthrough | Will send result directly to client, default: true
  array | $cookies | Optional hash of cookie name => values to add to http header

Returns
  string|false String if http request, or false if an error occurs. If $passthrough = true, program will end here and send result directly to client.

Definition at line 214 of file ezhttptool.php.

References eZExecution\cleanExit().

## ◆ sessionID()

eZHTTPTool::sessionID | ( |  | ) |

Return the session id

Returns
  string

Definition at line 715 of file ezhttptool.php.

## ◆ sessionVariable()

& eZHTTPTool::sessionVariable | ( |  | $name,
|  |  | $fallbackValue = `null`
| ) |  |

Get session variable $name

Parameters

  string | $name |
  mixed | $fallbackValue | Return this if session has not started OR name is undefined if null(default), then force start session and return null if undefined.

Returns
  mixed ByRef

Definition at line 705 of file ezhttptool.php.

## ◆ setGetVariable()

eZHTTPTool::setGetVariable | ( |  | $var,
|  |  | $value
| ) |  |

Sets the get variable $var to $value.

See also
  getVariable

Definition at line 78 of file ezhttptool.php.

## ◆ setPostVariable()

eZHTTPTool::setPostVariable | ( |  | $var,
|  |  | $value
| ) |  |

Sets the post variable $var to $value.

See also
  postVariable

Definition at line 41 of file ezhttptool.php.

## ◆ setSessionID()

eZHTTPTool::setSessionID | ( |  | $sessionKey | ) |

Sets a new session id

Parameters

  string | $sessionKey | Allowed characters in the range a-z A-Z 0-9 , (comma) and - (minus)

Returns
  string Current(old) session id

Definition at line 726 of file ezhttptool.php.

## ◆ setSessionVariable()

eZHTTPTool::setSessionVariable | ( |  | $name,
|  |  | $value
| ) |  |

Sets the session variable $name to value $value.

Parameters

  string | $name |
  mixed | $value |

Definition at line 669 of file ezhttptool.php.

## ◆ username()

static eZHTTPTool::username | ( |  | ) |
| static

Returns username from HTTP authentication or false if not logged in. See http://en.php.net/features.http-auth why you can‘t safely use $_SERVER['PHP_AUTH_USER’].

Definition at line 421 of file ezhttptool.php.

## ◆ variable()

eZHTTPTool::variable | ( |  | $var,
|  |  | $fallbackValue = `null`
| ) |  |

Returns
  the HTTP post/get variable $var, or $fallbackValue if the post/get variable does not exist , or null if $fallbackValue is omitted.

See also
  postVariable

Definition at line 132 of file ezhttptool.php.

References eZDebug\writeWarning().

## Member Data Documentation

## ◆ $UseFullUrl

eZHTTPTool::$UseFullUrl

Definition at line 28 of file ezhttptool.php.

The documentation for this class was generated from the following file:

- ezhttptool.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.