note 55196 added to function.get-magic-quotes-gpc
| From: | php-general at lists dot php dot net | Date: | Wed, 27 Jul 2005 13:09:37 +0000 |
| Subject: | note 55196 added to function.get-magic-quotes-gpc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-92551@lists.php.net to get a copy of this message | ||
Depending the server config, magic-quotes are the better thing to make unportable scripts, they are
*evil*. So I systematicaly execute the following undo_magic_quotes( ), then I simply use
mysql_real_escape_string( ), htmlentities( ), etc. when I need.
<?php
function undo_magic_quotes( ) {
if ( get_magic_quotes_gpc( ) ) {
$_GET = array_map_recursive('stripslashes', $_GET) ;
$_POST = array_map_recursive('stripslashes', $_POST) ;
$_COOKIE = array_map_recursive('stripslashes', $_COOKIE) ;
$_REQUEST = array_map_recursive('stripslashes', $_REQUEST) ;
}
}
if ( ! function_exists('array_map_recursive') ) {
function array_map_recursive($function, $data) {
foreach ( $data as $i => $item ) {
$data[$i] = is_array($item)
? array_map_recursive($function, $item)
: $function($item) ;
}
return $data ;
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55196
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55196&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55196&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55196&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55196&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55196&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55196&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55196&report=yes
Search -- http://master.php.net/manage/user-notes.php