<?
class requestCookie extends requestVars{ function requestCookie(){
$this->source = &$_COOKIE; }
}
class requestGet extends requestVars{function requestGet(){
$this->source = &$_GET;}
}
class requestPost extends requestVars{function requestPost(){
$this->source = &$_POST;}
}
class requestVars{
var $source =
array(); function requestVars(){
$this->source = &$_REQUEST; }
function getVarInt($param, $default = 0){
if (isset($this->source[$param]))
{ return
(int)$this->source[$param]; }else
return $default; }
function getVarFloat($param, $default = 0){
if (isset($this->source[$param]))
{ return
(float)$this->source[$param]; }else
return $default; }
function getVarAlpha($param ,$max , $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z]+$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarAlphaSpace($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z]([A-Za-z\s]*[A-Za-z])*$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarAlphaNum($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z][A-Za-z0-9]*$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarAlphaNumSpace($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z]([A-Za-z0-9\s]*[A-Za-z0-9])*$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarAlpha_Num($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z]([A-Za-z0-9_]*[A-Za-z0-9])*$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarAlpha_NumSpace($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z]([A-Za-z0-9\s_]*[A-Za-z0-9])*$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarAlphaOrNum($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[A-Za-z0-9]([A-Za-z0-9\s]*[A-Za-z0-9])*$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVarString($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ preg_match("/^[\(\)\/\'\"\,\.\-\$\&\£\s@\?#_a-zA-Z\d]+$/",$this->source[$param],$arr);
if (!empty($arr))
return substr($arr[0],0,$max);
}
return $default; }
function getVar($param, $max, $default = NULL){
if (isset($this->source[$param]))
{ return substr(htmlentities($this->source[$param]),0,$max);
}
return $default; }
}
?>
|