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);
      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.


Share This Post


  1. nock says:

    woo amigo me sorprendes y tus publicaciones me salvaron de pagar , extra a mi host por brindarme soporte de php 5.6 con tu truco pude resolver fácilmente gracias genio , un abrazo y Bendiciones me gustaría darte un donativo es algo simbólico pero de corazón y en forma de gratitud escríbeme a mi correo

    • Beau says:

      Gracias por tus buenos comentarios. Me alegra que esta solución te haya funcionado.

      Thank you for your nice comments. I am glad this fix worked for you.

  2. Mircea says:

    Thank you for taking the time to share this workaround! It saved me from running two separate web servers on the same local computer.

  3. Thierry says:

    Hi sir.
    Recently my ISP want me to change to php 8.1 or to pay for keeping php 7.4 version
    Unfortunatly autoindex seems to not working on php 8.1.
    I try some fix, but my knowledge are limited. ;(

    Can you help me to update the script for use with php 8.1 and for the futur php 8.2 ?

    • Beau says:

      Updating AutoIndex to PHP 8.x will take a good amount of time. I have this on my task list. I cannot tell you when I can update the script. I am in the same situation with my ISPs, all of them seem to be ready to stop providing PHP 7.4. I will let you know when I get the time to update the script.

    • Beau says:

      Thank you for posting this. I posted an article in my blog giving you credit for sharing this with me. Thank you for your support and help.

Leave a Reply

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

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