note 62101 deleted from security.magicquotes by betz

From: Date: Mon, 20 Feb 2006 11:12:39 +0000
Subject: note 62101 deleted from security.magicquotes by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104060@lists.php.net to get a copy of this message
Note Submitter: cully larson ---- Here's a simpler function to turn off magic quotes. It's weird how similar this looks to the previous function, but it was written independtly. <?php /** * Strip slashes from super globals if magic quotes is turned on. */ function removeMagicQuotes( ) { set_magic_quotes_runtime(0); if( ini_get('magic_quotes_gpc') ) { foreach( $GLOBALS as $global_name ) { $$global_name = arrayStripSlashes( $$global_name ); } } } /** * Strip slashes from a string or an array of values. * * @var mixed A string or array to strip slashes from. * * @return mixed The stripped string or array. */ function arrayStripSlashes( $to_strip ) { // if we have an array if( is_array( $to_strip ) ) foreach( $to_strip as $key=>$value ) $to_strip[$key] = arrayStripSlashes( $value ); // if we have a string, strip alshes if( is_string( $to_strip ) ) return stripslashes( $to_strip ); // otherwise, just return to_strip else return $to_strip; } ?>

« previous php.notes (#104060) next »