// Validate numeric input
function isnum($value) {
if (!is_array($value)) {
return (preg_match("/^[0-9]+$/", $value));
} else {
return false;
}
}
// Strip Input Function, prevents <span style="border-bottom: 1px dotted black;">HTML</span> in unwanted places
function stripinput($text) {
if (!is_array($text)) {
$text = stripslash(trim($text));
//$text = preg_replace("/&[^#0-9]/", "&", $text)
$search = array("&", "\"", "'", "\\", '\"', "\'", "<", ">", " ");
$replace = array("&", """, "'", "\", """, "'", "<", ">", " ");
$text = preg_replace("/(&)+(?=\#([0-9]{2,3});)/i", "&", str_replace($search, $replace, $text));
} else {
foreach ($text as $key => $value) {
$text[$key] = stripinput($value);
}
}
return $text;
}
// Prevent any possible XSS attacks via $_GET.
function stripget($check_url) {
$return = false;
if (is_array($check_url)) {
foreach ($check_url as $value) {
if (stripget($value) == true) {
return true;
}
}
} else {
$check_url = str_replace(array("\"", "\'"), array("", ""), urldecode($check_url));
if (preg_match("/<[^<>]+>/i", $check_url)) {
return true;
}
}
return $return;
}