This commit is contained in:
Miles Lott 2001-12-19 20:03:01 +00:00
parent 8d708065f9
commit 561da9b50f

View File

@ -53,34 +53,35 @@
$GLOBALS['phpgw_info']['server']['sanitize_types']['number'] = Array('type' => 'preg_match', 'string' => '/^[0-9]+$/i');
*/
function sanitize($string,$type) {
function sanitize($string,$type)
{
switch ($type)
{
case "bool":
case 'bool':
if ($string == 1 || $string == 0)
{
return True;
}
break;
case "number":
case 'number':
if (preg_match("/^[0-9]+$/i", $string))
{
return True;
}
break;
case "string":
case 'string':
if (preg_match("/^[a-z]+$/i", $string))
{
return True;
}
break;
case "alpha":
case 'alpha':
if (preg_match("/^[a-z0-9 -._]+$/i", $string))
{
return True;
}
break;
case "ip":
case 'ip':
if (eregi("^[0-9]{1,3}(\.[0-9]{1,3}){3}$",$string))
{
$octets = split('\.',$string);
@ -95,19 +96,19 @@
}
return False;
break;
case "file":
case 'file':
if (preg_match("/^[a-z0-9_]+\.+[a-z]+$/i", $string))
{
return True;
}
break;
case "email":
case 'email':
if (eregi("^([[:alnum:]_%+=.-]+)@([[:alnum:]_.-]+)\.([a-z]{2,3}|[0-9]{1,3})$",$string))
{
return True;
}
break;
case "any":
case 'any':
return True;
break;
default :
@ -122,11 +123,11 @@
}
}
function registervar($varname, $valuetype = 'alpha', $posttype = 'post', $allowblank = True)
{
switch ($posttype) {
case "get":
switch ($posttype)
{
case 'get':
$posttype = 'HTTP_GET_VARS';
break;
default :