09-19-2016, 02:12 PM
Allowing arrays in Input.php was a nice addition - I had already done some stuff to work around that and can no go restructure my code to take advantage of US utilities...
However, I note that it only allows for the simplest <input type="x" name="myName[]" /> type of arrays. Going all recursive to handle multi-dimensional arrays is probably out of scope, but allowing indices that are either non-ordered numbers or even text (<input type="x" name="myName[first]" /> <input type="x" name="myName[last]" />) is trivial and is probably needed in a good 20-30{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} of uses when people use arrays in input fields (according to my *very* rough guesstimate in my personal experience which may be wildly off-base).
I haven't run this code, but I think it will take care of it:
NOTE THE NOTE THE
} elseif(isset($_GET[$item])){
/*
If the $_GET item is an array, process each item independently, and return array of sanitized items.
*/
if (is_array($_GET[$item])){
$getItems=array();
foreach ($_GET[$item] as $getItem){
$getItems[]=self:anitize($getItem);
}
return $getItems;
}else{
return self:anitize($_GET[$item]);
}
}
return '';
}
However, I note that it only allows for the simplest <input type="x" name="myName[]" /> type of arrays. Going all recursive to handle multi-dimensional arrays is probably out of scope, but allowing indices that are either non-ordered numbers or even text (<input type="x" name="myName[first]" /> <input type="x" name="myName[last]" />) is trivial and is probably needed in a good 20-30{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} of uses when people use arrays in input fields (according to my *very* rough guesstimate in my personal experience which may be wildly off-base).
I haven't run this code, but I think it will take care of it:
Code:
public static function get($item){
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 $k => $postItem){
Code:
$k =>
Code:
$postItems[$k]=self::sanitize($postItem);
Code:
$k
Code:
}
Code:
return $postItems;
Code:
}else{
Code:
return self::sanitize($_POST[$item]);
Code:
}
} elseif(isset($_GET[$item])){
/*
If the $_GET item is an array, process each item independently, and return array of sanitized items.
*/
if (is_array($_GET[$item])){
$getItems=array();
foreach ($_GET[$item] as $getItem){
$getItems[]=self:anitize($getItem);
}
return $getItems;
}else{
return self:anitize($_GET[$item]);
}
}
return '';
}