UrlRequst Class Reference
[General]

Include files. More...

List of all members.

Static Public Member Functions

static set ($attributeName_, $value_)
 Set a value to the URL argument.
static setDefault ($attributeName_, $value_)
 Set an default value of an URL argument.
static isSetArg ($attributeName_)
 Return true if the argument is present on the URL (_REQUEST).
static get ($attributeName_)
 Return an argument from the URL with now validation.
static getDateTime ($attributeName_)
 Return an argument from the URL and validate it to be a date or dateTime.
static getBool ($attributeName_)
 Return an argument from the URL and validate it to be boolean.
static getString ($attributeName_)
 Return an argument from the URL and validate it to be string.
static getInt ($attributeName_)
 Return an argument from the URL and validate it to be integer.


Detailed Description

Include files.

Used to get and validate URL variables.

The variables will be retrieved from HTTP POST, HTTP GET and HTTP Cookies.

All variables are validated to prevent any kind of variable injection. All POST, GET or Cookie variables should be cleaned with the this class.

 UrlRequst::dateTime('startTime');
 echo(UrlRequst::get('startTime'));

Author:
Daniel Lindh <[email protected]>

Definition at line 25 of file UrlRequest.class.php.


Member Function Documentation

static UrlRequst::get ( attributeName_  )  [static]

Return an argument from the URL with now validation.

Parameters:
$attributeName_ - string -
Returns:
mixed

Definition at line 78 of file UrlRequest.class.php.

Referenced by getBool(), getDateTime(), getInt(), and getString().

00079   {
00080     return $_REQUEST[$attributeName_];
00081   }

static UrlRequst::getBool ( attributeName_  )  [static]

Return an argument from the URL and validate it to be boolean.

A valid boolean is case insensitive true, false, yes, no, 1 and 0.

If nothing is entered in the parameter false will be returned.

Parameters:
$attributeName_ - bool -

Definition at line 109 of file UrlRequest.class.php.

References get(), and isSetArg().

00110   {
00111     if (UrlRequst::isSetArg($attributeName_))
00112     {
00113       switch (strtolower(UrlRequst::get($attributeName_)))
00114       {
00115         case 'true':
00116         case 'yes':
00117         case '1':
00118           return true;
00119 
00120         case 'false':
00121         case 'no':
00122         case '0':
00123           return false;
00124 
00125         default:
00126           die('Invalid parameter for ' . $attributeName_);
00127       }
00128     }
00129     else
00130     {
00131       return false;
00132     }
00133   }

static UrlRequst::getDateTime ( attributeName_  )  [static]

Return an argument from the URL and validate it to be a date or dateTime.

Parameters:
$attributeName_ - dateTime -

Definition at line 88 of file UrlRequest.class.php.

References get(), and isValidDate().

00089   {
00090     if (!isValidDate(UrlRequst::get($attributeName_)))
00091     {
00092       return false;
00093     }
00094     else
00095     {
00096       return UrlRequst::get($attributeName_);
00097     }
00098   }

static UrlRequst::getInt ( attributeName_  )  [static]

Return an argument from the URL and validate it to be integer.

If nothing is entered in the parameter NULL will be returned.

Parameters:
$attributeName_ - string -

Definition at line 161 of file UrlRequest.class.php.

References get().

00162   {
00163     if (!ctype_digit(UrlRequst::get($attributeName_)))
00164     {
00165       return false;
00166     }
00167     else
00168     {
00169       return UrlRequst::get($attributeName_);
00170     }
00171   }

static UrlRequst::getString ( attributeName_  )  [static]

Return an argument from the URL and validate it to be string.

If nothing is entered in the parameter NULL will be returned.

Parameters:
$attributeName_ - string -

Definition at line 142 of file UrlRequest.class.php.

References get(), and isSetArg().

00143   {
00144     if (UrlRequst::isSetArg($attributeName_))
00145     {
00146       return UrlRequst::get($attributeName_);
00147     }
00148     else
00149     {
00150       return null;
00151     }
00152   }

static UrlRequst::isSetArg ( attributeName_  )  [static]

Return true if the argument is present on the URL (_REQUEST).

Returns:
- boolean -

Definition at line 60 of file UrlRequest.class.php.

Referenced by getBool(), getString(), and setDefault().

00061   {
00062     if (array_key_exists($attributeName_, $_REQUEST))
00063     {
00064       return true;
00065     }
00066     else
00067     {
00068       return false;
00069     }
00070   }

static UrlRequst::set ( attributeName_,
value_ 
) [static]

Set a value to the URL argument.

Parameters:
$attributeName_ - string -
$value_ - string -

Definition at line 33 of file UrlRequest.class.php.

Referenced by UTUrlRequest::_testGetBool(), UTUrlRequest::_testgetInt(), and UTUrlRequest::_testGetString().

00034   {
00035     $_REQUEST[$attributeName_] = $value_;
00036   }

static UrlRequst::setDefault ( attributeName_,
value_ 
) [static]

Set an default value of an URL argument.

If the argument is not present on the URL (_REQUEST), this default value will be returned by all getters in this class.

Parameters:
$attributeName_ - string -
$value_ - string -

Definition at line 47 of file UrlRequest.class.php.

References isSetArg().

Referenced by UTUrlRequest::_testGet(), UTUrlRequest::_testGetDateTime(), and UTUrlRequest::_testGetString().

00048   {
00049     if (!UrlRequst::isSetArg($attributeName_))
00050     {
00051       $_REQUEST[$attributeName_] = $value_;
00052     }
00053   }


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

Generated on Wed May 6 23:28:24 2009 for fareofficelib by  doxygen 1.5.8