note 69357 rejected from function.mysql-real-escape-string by colder

From: Date: Sat, 02 Sep 2006 11:29:09 +0000
Subject: note 69357 rejected from function.mysql-real-escape-string by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116609@lists.php.net to get a copy of this message
Note Submitter: Ultimater at gmail dot com ---- Ahh... php at rebel dot com dot au, you are right. There is a big different between magic_quotes_runtime and magic_quotes_gpc. What I'm looking for is really a set_magic_quotes_gpc function however there is none. However we can alter the super global variables and simulate the function very closely. Behold set_magic_quotes_gpc: <?php function set_magic_quotes_gpc($arg1){ global $MAGIC_QUOTES_GPC; if(!$MAGIC_QUOTES_GPC) $MAGIC_QUOTES_GPC=get_magic_quotes_gpc()?"ON":"OFF"; global $_GET,$_POST,$_COOKIE,$_REQUEST; global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_COOKIE_VARS; if(!$arg1 && $MAGIC_QUOTES_GPC=="ON"){ $_GET=array_map("stripslashes",$_GET); $_POST=array_map("stripslashes",$_POST); $_COOKIE=array_map("stripslashes",$_COOKIE); $_REQUEST=array_map("stripslashes",$_REQUEST); $HTTP_POST_VARS=array_map("stripslashes",$HTTP_POST_VARS); $HTTP_GET_VARS=array_map("stripslashes",$HTTP_GET_VARS); $HTTP_COOKIE_VARS=array_map("stripslashes",$HTTP_COOKIE_VARS); $MAGIC_QUOTES_GPC="OFF"; } elseif($arg1 && $MAGIC_QUOTES_GPC=="OFF"){ $_GET=array_map("addslashes",$_GET); $_POST=array_map("addslashes",$_POST); $_COOKIE=array_map("addslashes",$_COOKIE); $_REQUEST=array_map("addslashes",$_REQUEST); $HTTP_POST_VARS=array_map("addslashes",$HTTP_POST_VARS); $HTTP_GET_VARS=array_map("addslashes",$HTTP_GET_VARS); $HTTP_COOKIE_VARS=array_map("addslashes",$HTTP_COOKIE_VARS); $MAGIC_QUOTES_GPC="ON"; } } ?>

« previous php.notes (#116609) next »