php - magic_quotes_gpc off on sharehosting with $_POST Array -
it's pain in *** magic quote on on share server, , giving on upload php.ini overwrite share host php.ini, because other problem occurr, (pdo in configure not loaded , ect) tried .htaccess give 500 error.
so have found solution pretty , works how turn off magic quotes on shared hosting?
if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) ) { $_post = array_map( 'stripslashes', $_post ); $_get = array_map( 'stripslashes', $_get ); $_cookie = array_map( 'stripslashes', $_cookie ); }
until start post array server
<select name="gropu[]"> <option value="1">2</option> <option value="2">1</option> <option value="3">3</option> </select>
then have following errro
warning: stripslashes() expects parameter 1 string, array given in index.php on line 18
please me on this, annoying me while developing ok on localhost , once upload server wrong...
i run on initialization:
// attempt disable 'magic quotes' @ runtime @ini_set('magic_quotes_runtime', 0); @ini_set('magic_quotes_sybase', 0); // strip slashes if didn't work if(get_magic_quotes_gpc()){ function _strip_slashes_ref(&$var){ $var = stripslashes($var); } array_walk_recursive($_post, '_strip_slashes_ref'); array_walk_recursive($_get, '_strip_slashes_ref'); array_walk_recursive($_cookie, '_strip_slashes_ref'); array_walk_recursive($_request, '_strip_slashes_ref'); }
magic quotes removed in 5.4, might want if:
version_compare(php_version, '5.4.0') < 0
Comments
Post a Comment