note 32736 added to function.get-magic-quotes-gpc

From: Date: Thu, 05 Jun 2003 15:19:41 +0000
Subject: note 32736 added to function.get-magic-quotes-gpc
Groups: php.notes 
Request: Send a blank email to php-notes+get-49797@lists.php.net to get a copy of this message
IMHO gpc magic quotes are absolutely ill-featured, here is a way to fight them! :) Place it before any other code that uses $_GET, $_POST or $_COOKIES. Works with multi-dimensional arrays! WARNING: if you choose to stip the slashes, be sure to always add them manually if you insert GPC vars in a SQL-query. addslashes() and mysql_escape_string() are your friends. function & strip_slashes(&$str) { if(is_array($str)) { while(list($key, $val) = each($str)) { $str[$key] = strip_slashes($val); } } else { $str = stripslashes($str); } return $str; } if(get_magic_quotes_gpc()) { strip_slashes($_GET); strip_slashes($_POST); strip_slashes($_COOKIES); } ---- Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32736 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32736&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32736&report=yes

« previous php.notes (#49797) next »