How to Upgrade AutoIndex to PHP 7

I posted back in September 2017 that I am a fan of the AutoIndex 2.2.4 PHP script. See my post “Bootsrap 3 Responsive Template for AutoIndex PHP Script“.

Many ISPs and web designers are moving to PHP  7.x, the current version of PHP.  Unfortunately this causes AutoIndex 2.2.4 to stop working. It will throw an error referring to a magic_quotes function call on line 122 of the index.php file:

Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime()

The magic_quotes function was taken out of PHP 7.x. But have no fear, it turns out that the solution is not too difficult.  

      1. Make a backup copy of the original index.php in case something goes wrong.
      2. Open index.php in your editor and find lines 116 to 122 which should look like:
        if (@get_magic_quotes_gpc())
        //remove any slashes added by the "magic quotes" setting
        {
        $_GET = array_map('stripslashes', $_GET);
        $_POST = array_map('stripslashes', $_POST);
        }
        @set_magic_quotes_runtime(0);
      3. Disable these lines by remarking them out with /* at the beginning and */ at the end like this:
        /* if (@get_magic_quotes_gpc())
        //remove any slashes added by the "magic quotes" setting
        {
        $_GET = array_map('stripslashes', $_GET);
        $_POST = array_map('stripslashes', $_POST);
        }
        @set_magic_quotes_runtime(0); */
      4. Save the file and close your editor.
      5. Now flush your browser cache, run your AutoIndex page, and start testing.

This fix worked for me. I tested the change in Firefox, Chrome, Edge, and Internet Explorer. So far there have been no problems. Let me know if this works for you.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress spam blocked by CleanTalk.

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Warning: strpos(): Offset not contained in string in /var/www/html/bso.blog/b15/wp-content/plugins/page-title-splitter/pts.php on line 470