1

I'm getting a 500 error whilst using PHP to try and get the folder structure for my site, I'm new to PHP and most of what I've done with it is self taught or researched, and this time neither of those could help me solve this.

I am hosting my website with Plesk, using their hosting panel to manage it and I am currently making an 'Admin' area of my site, and wanted to list the structure of my images folder on this. I have tried many different php scripts and all return a 500 error, the log also shows no detail, PHP is enabled and working on my site as I'm using it elsewhere.

My current script is below, I got it here, and edited it for my use. My PHP version is 5.4. Any help would be greatly appreciated.

<?php
  function listFolderFiles($dir){
      $ffs = scandir($dir);
      echo '<ol>';
      foreach($ffs as $ff){
        if($ff != '.' && $ff != '..'){
            echo '<li>'.$ff;
            if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);
            echo '</li>';
        }
      }
      echo '</ol>';
    }

    listFolderFiles('Content/images');
?>
Community
  • 1
  • 1
JakeGilesPhillips
  • 163
  • 1
  • 1
  • 11
  • If you get a http status 500 upon a php script execution then _certainly_ the http servers error log file will show some details. – arkascha Feb 09 '17 at 14:10
  • as @arkascha said, there should be something in error log, but as I'm looking at 'Content/images' - is your path correct? Shouldn't it be './content/images' – Jan Rydrych Feb 09 '17 at 14:13
  • This is all i see in my logs `2017-02-09 14:10:40 W3SVC532 N1NWVPWEB006 188.121.43.37 POST /Admin/php-scripts/getFolderStructure.php - 80 - 212.30.17.62 HTTP/1.1 Mozilla/5.0+(Windows+NT+6.1;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/56.0.2924.87+Safari/537.36 PHPSESSID=jm9ge6162smg2ai1pik6dqmll3 http://www.*MYWEBSITE*.co.uk/Admin/Home.html www.*MYWEBSITE*.co.uk 500 0 0 1676 514 46` – JakeGilesPhillips Feb 09 '17 at 14:13
  • @HonzaRydrych Why should that make a difference? Both a relative paths... – arkascha Feb 09 '17 at 14:14
  • 2
    @JakeGp No, that is the _access_ log file. You need to take a look into the _error_ log file. They are separate. – arkascha Feb 09 '17 at 14:15
  • sorry @arkascha, corrected – Jan Rydrych Feb 09 '17 at 14:16
  • 1
    error 500 with this script might be an error linked to the configuration, like a bad directive in a .htaccess file or such, because the script works perfectly fine here. Have you tried with a different path, like accessing a simple subfolder 'Content' (is uppercase correct here?), or accessing the php script with the function commented (to be sure that it is the guilty here)? – Kaddath Feb 09 '17 at 14:26
  • Hi yeah, I have tried using the script with it commented, and no matter what folder it still errors. I believe you're right regarding a bad directive, I'm currently trying to get my head around how that works, also with plesk its hard to access these things – JakeGilesPhillips Feb 09 '17 at 14:30

0 Answers0