get_magic_quotes_gpc going away, how to bulk update the code

84 Views Asked by At

I have thousands of instances of calls to get_magic_quotes_gpc. Since get_magic_quotes_gpc is going away, I found a recommendation to simply replace call with "false".

Then the code:

if (get_magic_quotes_gpc()) {
    $cell = stripslashes($cell);
}

would become:

if (false) {
    $cell = stripslashes($cell);
}

This would require finding and replacing each instance.

I have made a few updates to test the one-at-time solution but is there a bulk or universal solution or do I have to hire additional programmers to sift thru the files? Otherwise when PHP V8 comes along, there are going to be a lot crashes.

2

There are 2 best solutions below

0
cp1 On

Can be done in a single shell command:


$ sed -i 's/get_magic_quotes_gpc()/false/g' *

Or, to apply this only to .php files:


find . -type f -name '*.php' -print0 | xargs -0 sed -i 's/get_magic_quotes_gpc()/false/g' *

0
Phil On

You could always define your own replacement function in a globally included file...

if (!function_exists('get_magic_quotes_gpc')) {
    function get_magic_quotes_gpc() {
        return false;
    }
}

https://3v4l.org/9C6Ui