skip to Main Content

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

Answers


  1. 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' *
    
    
    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search