potsky / PimpMyLog

🍭 Log viewer for your web server
http://pimpmylog.com
GNU General Public License v3.0
594 stars 89 forks source link

Fixes the message get_magic_quotes_gpc() is deprecated for PHP 7.4 #149

Closed alebak closed 1 year ago

alebak commented 3 years ago

Check if PHP is a version lower than 7.4 to execute the get_magic_quotes_gpc function.

fix #148

EHLOVader commented 1 year ago

This appears to still be an issue, in fact in 8 get_magic_quotes_gpc was removed so it is a fatal error now.

I can see why the PR might not have been merged though, the check of magic quotes status should still be done, so it should check for version first then it needs to call get_magic_quotes_gpc

/*
|--------------------------------------------------------------------------
| Disable magic quotes
|--------------------------------------------------------------------------
|
| PHP 5.2 and 5.3 can have magic quotes enabled on the whole PHP install.
| http://support.pimpmylog.com/discussions/problems/56-regex-tester-match-is-not-a-valid-associative-array
|
*/
if (  version_compare(PHP_VERSION, '7.4', '<') &&
      get_magic_quotes_gpc() )
{
    $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 );
}

This needs a whole new PR and remote branch right?