<?php
function ListFolder($path)
{
    //using the opendir function
    $dir_handle = @opendir($path) or die("Unable to open $path");
    
    //Leave only the lastest folder name
    $dirname = end(explode("/", $path));
    
    //display the target folder.
    while (false !== ($file = readdir($dir_handle))) 
    {
        if($file!="." && $file!=".." && strpos($file, "php") === false)
        {
            if (is_dir($path."/".$file))
            {
                //If folder, get contents of folder.
                ListFolder($path."/".$file);
            }
            else
            {
                //Display path with file.
                echo "<Contents><Key>".substr($path, 2)."/".$file."</Key>";
				echo "<LastModified>".date("Y-m-d\TH:i:s.000\Z", filemtime($path."/".$file))."</LastModified>";
				echo "<Size>".filesize($path."/".$file)."</Size></Contents>";
            }
        }
    }
    
    //closing the directory
    closedir($dir_handle);
}

header('Content-Type: text/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<ListBucketResult xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">
    <Name>MinecraftResources</Name>
    <Prefix></Prefix>
    <Marker></Marker>
    <MaxKeys>1000</MaxKeys>
    <IsTruncated>false</IsTruncated>";
ListFolder(".");
echo "</ListBucketResult>";