Commit 98d6987c authored by Penny Leach's avatar Penny Leach
Browse files

added param_alphanumext - a-zA-Z0-9_-.

parent d879ac52
......@@ -578,6 +578,36 @@ function param_alphanum($name) {
throw new ParameterException("Parameter '$name' = '$value' is not an alphanum");
}
/**
* This function returns a GET or POST parameter as an alphanumeric string with optional
* default. If the default isn't specified and the parameter hasn't been sent,
* a ParameterException exception is thrown. Likewise, if the parameter isn't a
* valid alpha string, a ParameterException exception is thrown
*
* Valid characters are a-z and A-Z and 0-9 and _ and - and .
*
* @param string The GET or POST parameter you want returned
* @param mixed [optional] the default value for this parameter
*
* @return string The value of the parameter
*
*/
function param_alphanumext($name) {
$args = func_get_args();
list ($value, $defaultused) = call_user_func_array('_param_retrieve', $args);
if ($defaultused) {
return $value;
}
if (preg_match('/^[a-zA-Z0-9_.-]+$/',$value)) {
return $value;
}
throw new ParameterException("Parameter '$name' = '$value' is not an alphanumext");
}
/**
* This function returns a GET or POST parameter as an array of integers with optional
* default. If the default isn't specified and the parameter hasn't been sent,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment