Here, a handle sanitize function that our guys coded for eoCMS.
function unregister_globals(){
#checks if register globals is on
if (!ini_get('register_globals')){
return false;
}
foreach (func_get_args() as $name){
foreach ($GLOBALS[$name] as $key=>$value){
if (isset($GLOBALS[$key]))
unset($GLOBALS[$key]);
}
}
}
unregister_globals('_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', '_SESSION');
function Sanitize($data_to_sanitize) {
$data_to_sanitize = htmlspecialchars($data_to_sanitize, ENT_QUOTES);
//checks to see if magic quotes is off, only lazy people have it on :P
if (!get_magic_quotes_gpc())
$data_to_sanitize = addslashes($data_to_sanitize); //if it isnt we use addslashes
return $data_to_sanitize;
}
function Sanitize_Array($value) {
$value = is_array($value) ? array_map('Sanitize_Array', $value) : Sanitize($value);
return $value;
}
$_POST = array_map('Sanitize_Array', $_POST);
$_GET = array_map('Sanitize_Array', $_GET);
$_COOKIE = array_map('Sanitize_Array', $_COOKIE);
$_REQUEST = array_map('Sanitize_Array', $_REQUEST);
$_SERVER = array_map('Sanitize_Array', $_SERVER);
We are proud to say we and eoCMS has never been hacked. (eoCMS is the content management system we've been working on.)
Temporarly away from the Phoenix Sentry.