-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhttp-index-format_automator.php
53 lines (47 loc) · 1.73 KB
/
http-index-format_automator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/*
http-index-format Automator
@version 0.0.1
@license: GNU GPL, X11/MIT License
http://eligrey.com/about/license
@author: Elijah Grey, http://eligrey.com
Recomended use: Use in conjunction with mod_rewrite to make all directories automatically served as http-index-format.php?dir=DIRECTORY for Gecko browsers and default index view for normal browsers.
To have info in directories, place an index.info file in a directory to show comments in the generated application/http-index-format output
*/
header("Content-Type: application/http-index-format");
$dir = $_GET["dir"];
$dir = preg_replace("/\/{2,}/", "/", $dir) == "" ? "./" : $dir ;
echo "300: http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] . "\n";
if (is_dir($dir)) {
if($dh = opendir($dir)) {
if ( is_file($dir . "/index.info.php") ) {
echo "101: ";
include($dir . "/index.info.php");
echo "\n";
}
else if ( is_file($dir . "/index.info") ) {
$info = file($dir . "/index.info");
for($x = 0; $x <= count($info); $x++) {
if ($info[$x] != "") { echo "101: " . $info[$x]; }
}
echo "\n";
}
echo "200: Filename Content-Length File-type Last-Modified\n";
while ( ($file = readdir($dh)) !== false ) {
if ($file != "." && $file != ".." && $file != "index.info" && $file != "index.info.php" && $file != ".htaccess") {
if (is_link($dir."/".$file)) {
echo "201: ".'"'.$file.'"'." 0 SYMBOLIC-LINK \n";
}
elseif ( is_dir($dir."/".$file)) {
echo "201: ".'"'.$file.'"'." 0 DIRECTORY \n";
}
elseif ( is_file($dir."/".$file)) {
echo "201: ".'"'.$file.'" '.filesize($dir."/".$file)." FILE ".date("D,%20C%20j%20M%20Y%20G%3\AH%3\As", filemtime($dir."/".$file))."GMT\n";
}
}
}
}
}
echo "\n";
exit();
?>