# Released under the terms of the MIT license # ### configuration # Show the local path. Disable this for security reasons. define('SHOW_PATH', FALSE); # Show a link to the parent directory ('..'). define('SHOW_PARENT_LINK', FALSE); # Show "hidden" directories and files, i.e. those whose names # start with a dot. define('SHOW_HIDDEN_ENTRIES', FALSE); ### /configuration function get_grouped_entries($path) { list($dirs, $files) = collect_directories_and_files($path); $dirs = filter_directories($dirs); $files = filter_files($files); return array_merge( array_fill_keys($dirs, TRUE), array_fill_keys($files, FALSE)); } function collect_directories_and_files($path) { # Retrieve directories and files inside the given path. # Also, `scandir()` already sorts the directory entries. $entries = scandir($path); return array_partition($entries, function($entry) { return is_dir($entry); }); } function array_partition($array, $predicate_callback) { # Partition elements of an array into two arrays according # to the boolean result from evaluating the predicate. $results = array_fill_keys(array(1, 0), array()); foreach ($array as $element) { array_push( $results[(int) $predicate_callback($element)], $element); } return array($results[1], $results[0]); } function filter_directories($dirs) { # Exclude directories. Adjust as necessary. return array_filter($dirs, function($dir) { return $dir != '.' # current directory && (SHOW_PARENT_LINK || $dir != '..') # parent directory && !is_hidden($dir); }); } function filter_files($files) { # Exclude files. Adjust as necessary. return array_filter($files, function($file) { return !is_hidden($file) && substr($file, -4) != '.php'; # PHP scripts }); } function is_hidden($entry) { return !SHOW_HIDDEN_ENTRIES && substr($entry, 0, 1) == '.' # Name starts with a dot. && $entry != '.' # Ignore current directory. && $entry != '..'; # Ignore parent directory. } $path = __DIR__ . '/'; $entries = get_grouped_entries($path); ?> My Work - EquationRoom
    "); $path = $_SERVER["PHP_SELF"]; $parts = explode('/',$path); if (count($parts) < 2) { echo("Home"); } else { #echo("Home"); #echo ("Home » "); for ($i = 1; $i < count($parts)-1; $i++) { if (!strstr($parts[$i],".")) { echo("". str_replace('-', ' ', $parts[$i])." ยป "); } else { #$str = $parts[$i]; #$pos = strrpos($str,"."); #$parts[$i] = substr($str, 0, $pos); #echo str_replace('-', ' ', $parts[$i]); }; }; }; echo(""); foreach ($entries as $entry => $is_dir) { $class_name = $is_dir ? 'directory' : 'file'; $escaped_entry = htmlspecialchars($entry); printf('
  1. %s
  2. ' . "\n", $class_name, $escaped_entry, $escaped_entry); } ?>