Directory Listing

\"Directory\"$Files"; $Size = "Directory"; //Set Size column to "Directory" } else { //This grabs whatever is after the last . in the filename. This is good for files that have multiple periods in it's name $last = substr(strrchr($Files, "."), 1); //Create a list of file types to associate with icons $types = array("jpg", "jpeg", "gif", "png", "php", "mp3", "zip", "psd", "pdf"); //If the filetype of the file in the directory matches one in the types array above then set an icon for it if(in_array($last, $types)) { switch($last) { case "jpg": case "jpeg": case "gif": case "pdf": case "png": $image = "/i/image.png"; break; case "psd": $image = "/i/psd.png"; break; case "php": $image = "/i/php.png"; break; case "mp3": $image = "/i/mp3.png"; break; case "zip": $image = "/i/zip.png"; break; default: $image = "/i/default.png"; break; } } else { //Set a default icon for the filetype $image = "/i/default.png"; } //Create the link to the file with the icon $Name = "\"".$last."$Files"; //Set the filesize of the file $filesize = filesize ($Filename); //Create friendly filesize $Size = have_filesize($filesize); } } //Set name, size and type arrays $FileArray[] = $Name; $SizeArray[] = $Size; $TypeArray[] = $Type; } //Close directory closedir ($Open); // Define the two ways to sort the directory contents $Sort = $_GET['sort']; switch ($Sort) { case "SortByLow": array_multisort ($SizeArray, SORT_ASC, $FileArray); $sorting = "?sort=SortByHigh"; break; case "SortByHigh": array_multisort ($SizeArray, SORT_DESC, $FileArray); $sorting = "?sort=SortByLow"; break; default: array_multisort ($TypeArray, $FileArray, $SizeArray); $sorting = "?sort=SortByLow"; break; } $cl = ""; // Print out the contents of the directory echo ""; ?>