| 9 | |
| 10 | /* |
| 11 | * Clean up the mess PHP has created with its funky quoting everything! |
| 12 | * This block has been taken from b2evolution's _param.funcs.php file. |
| 13 | */ |
| 14 | if( get_magic_quotes_gpc() ) |
| 15 | { // That stupid PHP behaviour consisting of adding slashes everywhere is unfortunately on |
| 16 | |
| 17 | if( in_array( strtolower(ini_get('magic_quotes_sybase')), array('on', '1', 'true', 'yes') ) ) |
| 18 | { // overrides "magic_quotes_gpc" and only replaces single quotes with themselves ( "'" => "''" ) |
| 19 | /** |
| 20 | * @ignore |
| 21 | */ |
| 22 | function remove_magic_quotes( $mixed ) |
| 23 | { |
| 24 | if( is_array( $mixed ) ) |
| 25 | { |
| 26 | foreach($mixed as $k => $v) |
| 27 | { |
| 28 | $mixed[$k] = remove_magic_quotes( $v ); |
| 29 | } |
| 30 | } |
| 31 | elseif( is_string($mixed) ) |
| 32 | { |
| 33 | // echo 'Removing slashes '; |
| 34 | $mixed = str_replace( '\'\'', '\'', $mixed ); |
| 35 | } |
| 36 | return $mixed; |
| 37 | } |
| 38 | } |
| 39 | else |
| 40 | { |
| 41 | /** |
| 42 | * Remove quotes from input. |
| 43 | * This handles magic_quotes_gpc and magic_quotes_sybase PHP settings/variants. |
| 44 | * |
| 45 | * NOTE: you should not use it directly, but one of the param-functions! |
| 46 | * |
| 47 | * @param mixed string or array (function is recursive) |
| 48 | * @return mixed Value, with magic quotes removed |
| 49 | */ |
| 50 | function remove_magic_quotes( $mixed ) |
| 51 | { |
| 52 | if( is_array( $mixed ) ) |
| 53 | { |
| 54 | foreach($mixed as $k => $v) |
| 55 | { |
| 56 | $mixed[$k] = remove_magic_quotes( $v ); |
| 57 | } |
| 58 | } |
| 59 | elseif( is_string($mixed) ) |
| 60 | { |
| 61 | // echo 'Removing slashes '; |
| 62 | $mixed = stripslashes( $mixed ); |
| 63 | } |
| 64 | return $mixed; |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | else |
| 69 | { |
| 70 | /** |
| 71 | * @ignore |
| 72 | */ |
| 73 | function remove_magic_quotes( $mixed ) |
| 74 | { |
| 75 | return $mixed; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | |
| 80 | |