Index of

= 1) { $number /= 10; $multiplier *= 10; } return round($number, $sigdigs) * $multiplier; } // Human-readable filesizes function pretty_filesize($file) { $size = filesize($file); if($size < 1024) { $size = RoundSigDigs($size, 3)." B"; } elseif($size < 1048576) { $size = RoundSigDigs($size/1024, 3)." KB"; } elseif($size < 1073741824) { $size = RoundSigDigs($size/1048576, 3)." MB"; } else { $size = RoundSigDigs($size/1073741824, 3)." GB"; } return $size; } // Collection of file names to ignore $ignore_list = array("index.php", ".", ".htaccess", "directory-script.php", "zip-downloader.php"); // Makes $dirArray into a sorted array with our desired data // See also http://www.php.net/manual/en/function.readdir.php $myDirectory = opendir("."); while(false !== ($entryName = readdir($myDirectory))) { if(is_dir($entryName)) { $dirArray[]=$entryName; } else { $fileArray[]=$entryName; } } closedir($myDirectory); natcasesort($dirArray); natcasesort($fileArray); $dirArray = array_merge($dirArray, $fileArray); $dirArray = array_diff($dirArray, $ignore_list); $dirArray = array_values($dirArray); // reindexes the array so that the zebra striping works // Number of entries in the directory $indexCount = count($dirArray); // Loops through the array of files for($index = 0; $index < $indexCount; $index++) { // Gets file names $name = $dirArray[$index]; $namehref = $dirArray[$index]; // Gets date modifiedY-m-d //$modtime = date("M j Y G:i A", filemtime($dirArray[$index])); $modtime = date("Y-m-d G:i", filemtime($dirArray[$index])); // Deals with directories if(is_dir($dirArray[$index])) { $extn = "dir"; $longextn = "<Directory>"; $size = ""; // Cleans up .. directory if($name == "..") { // directories in private that are just below private if(strpos($index_location,"private") !== false && substr_count($index_location,"/") == 3) { continue; } else { $name = ".. (Parent Directory)"; $extn = "pardir"; } } } // Now we deal with files else { // Gets file extension $extn = pathinfo($dirArray[$index], PATHINFO_EXTENSION); if($extn == "php" && $index_location == "/site/php/") { $namehref = 'http://math.uchicago.edu/~chonoles/viewcode/?page='. str_replace(".php", "", $namehref) . '&lang=php'; } // Prettifies file type switch ($extn) { // Images case "png": $longextn = "PNG Image"; break; case "jpg": $longextn = "JPEG Image"; break; case "jpeg": $longextn = "JPEG Image"; break; case "svg": $longextn = "SVG Image"; break; case "gif": $longextn = "GIF Image"; break; case "ico": $longextn = "Windows Icon"; break; // Zips case "7z": $longextn = "7z Archive"; break; case "zip": $longextn = "ZIP Archive"; break; // Other files case "pdf": $longextn = "PDF Document"; break; case "djvu": $longextn = "DjVu Document"; break; case "djv": $longextn = "DjVu Document"; break; case "dvi": $longextn = "DVI Document"; break; case "epub": $longextn = "EPUB e-Book"; break; case "mobi": $longextn = "MOBI e-Book"; break; case "ps": $longextn = "PostScript Document"; break; case "chm": $longextn = "Compiled HTML Help"; break; case "txt": $longextn = "Text File"; break; case "exe": $longextn = "Windows Executable"; break; case "py": $longextn = "Python File"; break; // Math case "tex": $longextn = "TeX File"; break; case "sty": $longextn = "TeX Package"; break; case "cls": $longextn = "TeX Package"; break; case "nb": $longextn = "Mathematica Notebook"; break; case "m": $longextn = "Mathematica Package"; break; // Office case "doc": $longextn = "Word Document"; break; case "docx": $longextn = "Word Document"; break; case "xls": $longextn = "Excel Spreadsheet"; break; case "xlsx": $longextn = "Excel Spreadsheet"; break; case "ppt": $longextn = "PowerPoint"; break; case "pptx": $longextn = "PowerPoint"; break; case "pps": $longextn = "PowerPoint"; break; case "ppsx": $longextn = "PowerPoint"; break; case "pub": $longextn = "Publisher Document"; break; // Video case "avi": $longextn = "AVI Video"; break; case "wmv": $longextn = "WMV Video"; break; case "mp4": $longextn = "MP4 Video"; break; case "mkv": $longextn = "MKV Video"; break; case "mov": $longextn = "MOV Video"; break; case "m4a": $longextn = "M4A Video"; break; case "mpg": $longextn = "MPG Video"; break; case "mpeg": $longextn = "MPEG Video"; break; case "ogv": $longextn = "OGV Video"; break; // Audio case "mp3": $longextn = "MP3 Audio"; break; case "ogg": $longextn = "OGG Audio"; break; case "aac": $longextn = "AAC Audio"; break; case "flac": $longextn = "FLAC Audio"; break; case "wma": $longextn = "WMA Audio"; break; // Web pages case "html": $longextn = "HTML File"; break; case "htm": $longextn = "HTML File"; break; case "xhtml": $longextn = "HTML File"; break; case "shtml": $longextn = "HTML File"; break; case "php": $longextn = "PHP Script"; break; case "js": $longextn = "Javascript File"; break; case "css": $longextn = "CSS Stylesheet"; break; case "htaccess": $longextn = "Server Config File"; break; case "log": $longextn = "Log File"; break; default: if($extn != "") { $extn = "unkwn"; $longextn = strtoupper($extn)." File"; } else { $extn = "unkwn"; $longextn = "Unknown"; } break; } // Gets and cleans up file size $size = pretty_filesize($dirArray[$index]); $sizekey = filesize($dirArray[$index]); } // For "zebra striping" of output without having to use CSS3 selectors $parity = ($index % 2 == 0) ? (' class="odd"') : (""); // Output echo("\n " . "\n " . "\n " . "\n " . "\n " . "\n " . "\n"); } ?>
Filename Type Size Time Modified
$name$longextn$size$modtime