-2

I have been trying to eliminate a deprecated PHP function (get_magic_quotes_gpc()) from impress pages CMS and all efforts proved abortive.

There is this section of the code that has the deprecated function.

public function fixMagicQuotes()
{
   if (!get_magic_quotes_gpc()) {
        return;
    }

    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list($key, $val) = each($process)) {
        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] = & $process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
}

All I need is to remove the deprecated function from the application logic.

I have tried stripslashes(), removed the function itself but its either the page goes blank or it throws more error.

Please note: I have checked the alternative URL (PHP 7.4 deprecated get_magic_quotes_gpc function alternative) and there was no concrete solution regarding fixing this error, especially with respect to Impress Page CMS.

Is there any other alternatives that can help in solving this issue?

Thanks

  • @admin, I feel this is unfair. If you read thoroughly, the alternative solution that you provided (Which I have also checked through in-depth) has no concrete solution to the question. I am asking this question particularly for Impress page cms user. please, kindly review this negative score and re-open the question. Thank you –  Jul 16 '23 at 10:46
  • ***You need to remove every mention of this function from your code and do not replace it with anything else*** IS all the solution you need. – Your Common Sense Jul 16 '23 at 10:54
  • Thank you @common sense. As stated above, removing all the code/or commenting the code block rendered the site empty. Is there any further solution you can propose? –  Jul 16 '23 at 10:56
  • Please remember, Stack Overflow is a Q&A site, not a free to use Help Desk. It does answer questions, but doesn't solve problems for you. Your question is answered. While your problem you have to work out yourself. If, for some reason, your site goes blank, that's another question. Which is too, [already answered](https://stackoverflow.com/questions/845021/how-can-i-get-useful-error-messages-in-php) on Stack Overflow. If a site goes blank, then look for the error message, read it, and fix the error. – Your Common Sense Jul 16 '23 at 11:00
  • Sigh.. Trust me, I have tried many options, and for me coming here to post means I have exhausted my options. I understand that this is not a Helpdesk but a knowledge-gathering/sharing platform. I even got a posting ban because of this question and it got me really sad. however, thanks for your input and suggestion. @YourCommonSense –  Jul 16 '23 at 11:10

1 Answers1

0

As reported in the PHP manual, (in the latest versions of PHP) get_magic_quotes_gpc() returns always false and it was removed as of PHP 8.0.0 So you can empty or comment all the content of your fixMagicQuotes() function and everyting should work:

public function fixMagicQuotes()
{
/*
   if (!get_magic_quotes_gpc()) {
        return;
    }

    $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
    while (list($key, $val) = each($process)) {
        foreach ($val as $k => $v) {
            unset($process[$key][$k]);
            if (is_array($v)) {
                $process[$key][stripslashes($k)] = $v;
                $process[] = & $process[$key][stripslashes($k)];
            } else {
                $process[$key][stripslashes($k)] = stripslashes($v);
            }
        }
    }
    unset($process);
*/  
}

Note that also the each() function used in the while loop is deprecated and it was removed as of PHP 8.0.0

Pippo
  • 2,173
  • 2
  • 3
  • 16
  • Hi @pippo,Thanks for the response. I commented out the magic_quote and the site went completely blank. –  Jul 16 '23 at 10:52
  • @Olasunkanmi Let me understand better: when you leave fixMagicQuotes() as in the original format, apart from the message for the deprecated function, everything else works? – Pippo Jul 16 '23 at 13:53
  • With the fixMagicQuotes(), it shows an error. this is the urlhttps://theclearmindset.com/ When I commented it out, the page does not show anymore. –  Jul 16 '23 at 21:29
  • @Olasunkanmi Which version of PHP is installed in your system? – Pippo Jul 16 '23 at 21:43