Hello,
Unfortunately I have several large sites that depend on magic_quotes_gpc to escape variables. But I now want to start converting these sites slowly so that I can eventually turn magic_quotes_gpc off. The only way I have time to do this is to convert pages one at a time as I work on them so I need to be able to disable magic_quotes_gpc at runtime on only those pages that are converted and ready.
This is what I've come up with using an example from this forum and php.net. Does is look like it completely reverses the effects of magic_quotes_gpc? I need this to be fairly rock solid so I don't end up with unexpected data corruption or security problems. Any thoughts... any other rock solid solutions for disabling magic_quotes_gpc on a page by page basis?
<?php
if(get_magic_quotes_gpc()){
function stripslashes_deep($value){
if(is_array($value)){
$value = array_map('stripslashes_deep', $value);
}
elseif(!empty($value) && is_string($value)){
$value = stripslashes($value);
}
return $value;
}
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$_COOKIE = stripslashes_deep($_COOKIE);
$_REQUEST = stripslashes_deep($_REQUEST);
$_SERVER = stripslashes_deep($_SERVER);
$_FILES = stripslashes_deep($_FILES);
$_ENV = stripslashes_deep($_ENV);
if (isset($_SESSION)) { #These are unconfirmed (?)
$_SESSION = stripslashes_deep($_SESSION, '');
}
}
?>
Thank you kindly!
Peter