Created
April 17, 2024 04:39
-
-
Save EllieTheYeen/99a0e4bf28ff524c7e77b11d0f4e93c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Access-Control-Allow-Origin: *'); | |
header('Content-Type: text/html; charset=utf8'); | |
?> | |
<html> | |
<body> | |
<head> | |
<title>Smol</title> | |
<style> | |
html {background-color: #000000; color: #ffffff;} | |
</style> | |
</head> | |
<body> | |
<?php | |
error_reporting(E_ALL); | |
ini_set("display_errors", 1); | |
$no = ['.', '..', 'index.php']; | |
$scan = array_diff(scandir('.'), $no); | |
$dirs = array_filter($scan, "is_dir"); | |
$scan = call_user_func_array("array_merge", array_map(function($d) use($no) { return array_map(function($e) use($d) { return "$d/$e"; }, array_diff(scandir($d), $no)); }, $dirs)); | |
$dirs = array_filter($scan, "is_dir"); | |
$file = array_diff($scan, $dirs); | |
$scan = call_user_func_array("array_merge", array_map(function($d) use($no) { return array_map(function($e) use($d) { return "$d/$e"; }, array_diff(scandir($d), $no)); }, $dirs)); | |
$dirs = array_filter($scan, "is_dir"); | |
$file = array_merge($file, array_diff($scan, $dirs)); | |
$directory = getcwd(); | |
$filtimes = []; | |
array_walk($file, function ($d) { global $filtimes, $directory; $filtimes[$d] = filemtime($directory . DIRECTORY_SEPARATOR . $d); }); | |
usort($file, function ($a, $b) { global $filtimes; return $filtimes[$a] - $filtimes[$b]; }); | |
foreach ($file as $f) { | |
printf("<a href=\"%1\$s\">%1\$s</a><br />\n", htmlentities($f)); | |
} | |
?> | |
<br /> | |
<br /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment