71 lines
1.5 KiB
PHP
Executable File
71 lines
1.5 KiB
PHP
Executable File
<?php
|
|
|
|
namespace RR;
|
|
|
|
class Request{
|
|
|
|
const PARAM_ALPHA = 'alpha';
|
|
const PARAM_ALPHANUM = 'alphanum';
|
|
|
|
const PARAM_INT = 'integer';
|
|
const PARAM_DOUBLE = 'double';
|
|
|
|
public static function requiredParam($parname, $type, $options = Array(), $default = ''){
|
|
// POST has precedence.
|
|
if (isset($_POST[$parname])) {
|
|
$param = $_POST[$parname];
|
|
} else if (isset($_GET[$parname])) {
|
|
$param = $_GET[$parname];
|
|
} else {
|
|
return $default;
|
|
}
|
|
|
|
$param = self::filter($type, $param);
|
|
|
|
foreach ($options as $key => $option){
|
|
self::$key($param, $option);
|
|
}
|
|
return $param;
|
|
}
|
|
|
|
public static function requiredParamArray($parname, $type, $default = '', $options = Array() ){
|
|
|
|
}
|
|
|
|
public static function optionalParam(){
|
|
|
|
}
|
|
|
|
public static function optionalParamArray(){
|
|
|
|
}
|
|
|
|
private static function filter($type, $paramname){
|
|
switch ($type){
|
|
case 'integer':
|
|
if(is_integer($paramname)){
|
|
return $paramname;
|
|
}
|
|
break;
|
|
case 'double':
|
|
if(is_double($paramname)){
|
|
return $paramname;
|
|
}
|
|
break;
|
|
case 'alpha':
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Validations
|
|
*/
|
|
private static function minVal(){
|
|
|
|
}
|
|
|
|
private static function maxVal(){
|
|
|
|
}
|
|
|
|
} |