Magic_quotes_gpc function in php
Maybe someone is willing to test those combinations for other php-versions and with magic"s_sybase set to 'on' - let me know.
It took me over 2 days of testing to figure out the exact behavior and creating two functions (one for each php-version) that strips slashes reliably from any array submitted to a script.
Usage:?php unstrippedGET transcribe GET unstrippedpost transcribe post?Commeting out the magic"s_gpc-line will not turn magic"s_gpc off.Escaping of key-strings in GPC-arrays behave different to the escaping of their values.Sorry for this huge amount of text, but it's complete.Is_string GET'myKey true) legend for possible results, kE KeyEscaping.The following function will strip GPC-arrays for php.0.2?php function transcribe(aList, aIsTopLevel true) gpcList array isMagic get_magic"s_gpc foreach (aList as key value) if (is_array(value) living books the berenstain bears get in a fight decodedKey (isMagic decodedValue transcribe(value, false else decodedKey stripslashes(key decodedValue gpcListdecodedKey decodedValue; return gpcList;?TL TopLevel key, tL key is on top level (i.e.Caution: Although magic"s_gpc is flagged as dreprecated the default value is still "ON".VE control chars are prefixed with a backslash -VE value is returned as submitted and needn't to be stripped here we go - the following rules apply 1) P4 MQ AK TL - -KE 2) P4 MQ AK -TL - KE 3) P4 MQ -AK.The following is true for _GET- and _post-arrays.Example (rule 15 When running under php.0.2 having magic"s disabled, gpc-keys on top level containing strings are escaped while their associated values are not.
So you will explicitly have to put magic"s_gpc Off into your.
KE control chars are prefixed with a backslash -KE key is returned as submitted and needn't to be stripped.
After I saw escaped keys, I assumed they're escaped according to the settings of magic"s.
I was unable to compress the decision table more than this).
AK ArrayKey, aK the value of the key is another array (i.e.
' ' are always replaced by when used in keys.
I hope other arrays affected by magic"s behave equally.I did not test the behavior for cases where magic"s_sybase is set.VE ValueEscaping (doesn't apply for array as value).The following function will strip GPC-arrays for php.3.9?php function transcribe(aList, aIsTopLevel true) gpcList array isMagic get_magic"s_gpc foreach (aList as key value) decodedKey (isMagic if (is_array(value) decodedValue transcribe(value, false else decodedValue gpcListdecodedKey decodedValue; return gpcList;?First I expected that keys in submitted gpc-arrays are never escaped.P5 php.0.2, mQ Magi"s GPC, mQ magic"s enabled -MQ magic"s disabled.Legend for possible case combinations, px php version we're using, p4 php.3.9.Hope this saves someones time and nerves.Is_array GET'myKey true) -AK the value is a normal string (i.e._GET'myKey -TL key is nested within another array (i.e.Magic"s_gpcon/off and magic"s_sybaseon/off I made test and your function worked right.The behaviour of these functions is affected by settings.# Title Original Airdate English Airdate Type " The Soul Burial Detective, Karakuraizer is Born " March 31, 2009 July 17, 2011 Filler " Karakuraizer's Last Day " April 7, 2009 July 24, 2011 Filler " Defend Karakura Town!