ipn-code-samples
ipn-code-samples copied to clipboard
get_magic_qoutes_gpc Deprecated.
So I have the following code from the PayPalIPN php file. When running a test submit in sandbox mode, with error reporting on, I get an error. IPN block of code:
$get_magic_quotes_exists = false; if (function_exists('get_magic_quotes_gpc')) { $get_magic_quotes_exists = true; } foreach ($myPost as $key => $value) { if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) { $value = urlencode(stripslashes($value)); } else { $value = urlencode($value); } $req .= "&$key=$value"; }
Error
Deprecated: Function get_magic_quotes_gpc() is deprecated
PHP version 7.4.0+ purely because that's when it got deprecated. Any suggestions?
From PHP 5.4 get_magic_quotes_gpc() "Always returns FALSE because the magic quotes feature was removed from PHP."
edit this:
// Build the body of the verification post request, adding the _notify-validate command.
$req = 'cmd=_notify-validate';
$get_magic_quotes_exists = false;
if (function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
to this:
// Build the body of the verification post request, adding the _notify-validate command.
$req = 'cmd=_notify-validate';
foreach ($myPost as $key => $value) {
$value = urlencode($value);
$req .= "&$key=$value";
}
and everything will work in PHP 7.4