07-15-2017, 04:27 PM
Sorry, I knew I should have pasted all the code! I also saw a flaw in the logic I gave you. I've modified my own class though so I've gone back to the original US version; it'll be untested but should hopefully work without errors:
Code:
public static function get($item, $bypassSanitize = false){
Code:
if (isset($_POST[$item])) {
Code:
/*
Code:
If the $_POST item is an array, process each item independently, and return array of sanitized items.
Code:
*/
Code:
if (is_array($_POST[$item])){
Code:
$postItems=array();
Code:
foreach ($_POST[$item] as $postItem){
Code:
if (!$bypassSanitize) $postItem = self::sanitize($postItem);
Code:
$postItems[] = $postItem;
Code:
}
Code:
return $postItems;
Code:
}else{
Code:
if (!$bypassSanitize) $postItem = self::sanitize($_POST[$item]);
Code:
return $postItem;
Code:
}
Code:
} elseif(isset($_GET[$item])){
Code:
/*
Code:
If the $_GET item is an array, process each item independently, and return array of sanitized items.
Code:
*/
Code:
if (is_array($_GET[$item])){
Code:
$getItems=array();
Code:
foreach ($_GET[$item] as $getItem){
Code:
if (!$bypassSanitize) $getItem = self::sanitize($getItem);
Code:
$getItems[] = $getItem;
Code:
}
Code:
return $getItems;
Code:
}else{
Code:
if (!$bypassSanitize) $getItem = self::sanitize($_GET[$item]);
Code:
return $getItem;
Code:
}
Code:
}
Code:
return '';
Code:
}