I know this is a never ending battle, and everyone has different methods and opinions... I need a new method of cleaning/sanitizing the user input in PHP. I've had some random files appear in one of my website directories... I'm not sure if it's due to stolen passwords or what, but clearly my method is not working anymore!!!! I'm sorry that this is probably a duplicate, but I'm tired of my server having vulnerabilities!!!
I currently use this:
function clean($value) {
if (is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = clean($v);
} }
else {
if(get_magic_quotes_gpc() == 1) {
$value = stripslashes($value);
}
$value = trim(htmlspecialchars($value, ENT_QUOTES, "utf-8"));
$value = mres($value);
}
return $value;
}
Then I usually include this at the top of each file:
$POST = clean($_POST);
$GET = clean($_GET);
Please help before flagging me because I can't get blacklisted for spam again!