I am looking to run all posted data to my pages through a screen of htmlspecialchars and mysql_real_escape_string and then convert $_POST['fieldname'] to $fieldname for use in my coding.
I want to include this filter as an include at the top of every page I run.
I just seem to be running into problems.
first I run:
if(!get_magic_quotes_gpc())
{
$GET = array_map('htmlspecialchars', $GET);
$POST = array_map('htmlspecialchars', $POST);
$COOKIE = array_map('htmlspecialchars', $COOKIE);
$GET = array_map('mysql_real_escape_string', $GET);
$POST = array_map('mysql_real_escape_string', $POST);
$COOKIE = array_map('mysql_real_escape_string', $COOKIE);
}
else
{
$GET = array_map('stripslashes', $GET);
$POST = array_map('stripslashes', $POST);
$COOKIE = array_map('stripslashes', $COOKIE);
$GET = array_map('htmlspecialchars', $GET);
$POST = array_map('htmlspecialchars', $POST);
$COOKIE = array_map('htmlspecialchars', $COOKIE);
$GET = array_map('mysql_real_escape_string', $GET);
$POST = array_map('mysql_real_escape_string', $POST);
$COOKIE = array_map('mysql_real_escape_string', $COOKIE);
}
next i run:
foreach ($_POST as $key => $value) {
$$key = $value;
}
}
If I am correct, that should take something like <a href="here.com"> to
<a href="here.com"l>
thus saving me from nasty hacking attempts.
Is this correct? When I try this cycle of input management the data going into my database has not been run through htmlspecialchars from the looks of it.
I am trying to convert a site from Register_globals_on to register_globals_off and need a simple way to cycle through and clean all POSTed data.
Help!?!?
Thanks!