annotate index.php @ 28:ce92f4d41714

Add support for displaying hidden files.
author edogawaconan <me@myconan.net>
date Thu, 30 Oct 2014 12:14:32 +0900
parents aa3f0003fb41
children c482f0db5c28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8cba59d07798 Initial import.
edogawaconan <me@myconan.net>
parents:
diff changeset
1 <?php
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
2 define('DL_VERSION', '2.0.0');
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
3 // Required for strftime(). Set to UTC because :internet:.
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
4 date_default_timezone_set('UTC');
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
5
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
6 // $uri: web-facing path
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
7 $uri = $_SERVER["REQUEST_URI"];
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
8 $query_string_start = strpos($uri, "?");
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
9 if ($query_string_start !== false) {
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
10 $uri = substr($uri, 0, $query_string_start);
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
11 }
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
12 $uri = urldecode($uri);
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
13
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
14 // $dir: filesystem path
26
eee7ca924a5e Make it work with apache (at least XAMPP).
edogawaconan <me@myconan.net>
parents: 25
diff changeset
15 if (isset($_SERVER["DL_DIR"])) { $dir = $_SERVER["DL_DIR"]; }
eee7ca924a5e Make it work with apache (at least XAMPP).
edogawaconan <me@myconan.net>
parents: 25
diff changeset
16 elseif (isset($_SERVER["CONTEXT_DOCUMENT_ROOT"])) { $dir = $_SERVER["CONTEXT_DOCUMENT_ROOT"]; }
eee7ca924a5e Make it work with apache (at least XAMPP).
edogawaconan <me@myconan.net>
parents: 25
diff changeset
17 else { $dir = $_SERVER["DOCUMENT_ROOT"] . $uri; }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
18
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
19 if (realpath($dir) === false) {
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
20 header("HTTP/1.0 404 Not Found");
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
21 } elseif (substr($uri, -1) !== "/") {
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
22 header("Location: " . $uri . "/");
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
23 }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
24
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
25 if (http_response_code() !== 200) { exit; }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
26
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
27 $dir_handle = @opendir($dir);
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
28 $files = array();
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
29 $dirs = array();
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
30 while (($file = readdir($dir_handle)) !== false) {
28
ce92f4d41714 Add support for displaying hidden files.
edogawaconan <me@myconan.net>
parents: 27
diff changeset
31 if ($file === "." || $file === "..") { continue; }
ce92f4d41714 Add support for displaying hidden files.
edogawaconan <me@myconan.net>
parents: 27
diff changeset
32 elseif (!(isset($_SERVER["DL_SHOWALL"]) && $_SERVER["DL_SHOWALL"] === "1") && substr($file, 0, 1) === ".") { continue; }
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
33 elseif (is_dir($dir . $file)) { $dirs[] = $file; }
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
34 else { $files[] = $file; }
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
35 }
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
36 sort($files);
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
37 sort($dirs);
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
38
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
39 // BEGIN UTILITY
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
40 function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); }
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
41 function a($string) { return preg_replace("#(%2F)+#", "/", rawurlencode($string)); }
17
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
42 function link_to($target, $title) { return('<a href="' . a($target) . '">' . h($title) . "</a>"); }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
43
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
44 function human_size($size) {
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
45 $thousand_units = array("ko", "Mo", "Go", "To", "Po");
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
46
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
47 $return_format = "%d %s";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
48
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
49 if ($size <= 1) {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
50 $return_unit = "octet";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
51 } elseif ($size < 1000) {
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
52 $return_unit = "octets";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
53 } else {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
54 $size /= 1000;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
55 for ($i = 0; $size >= 1000 && $i < count($thousand_units); $i++) { $size /= 1000; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
56 $return_format = "%.2f %s";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
57 $return_unit = $thousand_units[$i];
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
58 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
59 return sprintf($return_format, $size, $return_unit);
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
60 }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
61 // END UTILITY
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
62
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
63 function tree_link() {
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
64 global $uri;
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
65
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
66 $uri_array = explode("/", trim($uri, "/"));
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
67
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
68 $tree_path = "/";
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
69 $tree_link = link_to($tree_path, "[root]");
20
caf498a0c602 Hide [root] for aliased directory.
edogawaconan <me@myconan.net>
parents: 19
diff changeset
70 $tree_link .= "/";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
71
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
72 foreach ($uri_array as $p) {
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
73 if ($p === "") { continue; }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
74 $tree_path .= $p . "/";
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
75 $tree_link .= link_to($tree_path, $p) . "/";
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
76 }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
77
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
78 return $tree_link;
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
79 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
80
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
81 function file_rows($files, $is_dir) {
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
82 global $dir, $uri;
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
83
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
84 $file_rows = "";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
85 $file_suffix = "";
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
86
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
87 if ($is_dir) {
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
88 $file_suffix = "/";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
89
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
90 if ($uri !== "/") {
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
91 $file_rows .= "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>";
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
92 }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
93 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
94
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
95 foreach($files as $file) {
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
96 $file_stat = stat($dir . "/". $file);
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
97
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
98 $file_rows .= "<tr>";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
99 $file_rows .= "<td>".link_to($file . $file_suffix, $file . $file_suffix)."</td>";
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
100
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
101 $file_rows .= "<td>";
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
102 if ($is_dir) { $file_rows .= "[dir]"; }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
103 else { $file_rows .= human_size($file_stat['size']); }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
104 $file_rows .= "</td>";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
105
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
106 $file_rows .= "<td>".h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime']))."</td>";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
107
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
108 $file_rows .= "</tr>";
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
109 }
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
110 return $file_rows;
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
111 }
0
8cba59d07798 Initial import.
edogawaconan <me@myconan.net>
parents:
diff changeset
112 ?>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
113 <?php header('Content-Type: text/html; charset=utf-8'); ?>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
114 <!doctype html>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
115 <head>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
116 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
117 <title>Index of <?php echo h($uri); ?></title>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
118 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
14
c2a468e9f3ac Add lightbox support \o/
edogawaconan <me@myconan.net>
parents: 11
diff changeset
119 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/css/lightbox.css">
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
120 <style type="text/css">
16
3c0b3a38a7fc Stupid lightbox2 can't copy image url directly ._.
edogawaconan <me@myconan.net>
parents: 15
diff changeset
121 .lb-data a { color: #ccc; }
18
9a4ac2d53a36 Set lightbox position to fixed.
edogawaconan <me@myconan.net>
parents: 17
diff changeset
122 .lightbox {
9a4ac2d53a36 Set lightbox position to fixed.
edogawaconan <me@myconan.net>
parents: 17
diff changeset
123 position: fixed;
9a4ac2d53a36 Set lightbox position to fixed.
edogawaconan <me@myconan.net>
parents: 17
diff changeset
124 top: 50px !important;
9a4ac2d53a36 Set lightbox position to fixed.
edogawaconan <me@myconan.net>
parents: 17
diff changeset
125 }
16
3c0b3a38a7fc Stupid lightbox2 can't copy image url directly ._.
edogawaconan <me@myconan.net>
parents: 15
diff changeset
126 </style>
3c0b3a38a7fc Stupid lightbox2 can't copy image url directly ._.
edogawaconan <me@myconan.net>
parents: 15
diff changeset
127 <style type="text/css">
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
128 * { box-sizing: border-box; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
129 body {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
130 font-family: Segoe UI, sans-serif;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
131 font-size: 14px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
132 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
133 h1 { margin: 5px; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
134 table {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
135 width: 100%;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
136 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
137 th:first-child, td:first-child {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
138 width: 100%;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
139 white-space: pre-wrap;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
140 word-wrap: break-word;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
141 word-break: break-all;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
142 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
143 tr {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
144 position: relative;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
145 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
146 th, td {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
147 white-space: nowrap;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
148 padding: 2px 5px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
149 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
150
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
151 @media (min-width: 768px) {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
152 th { background: #ccc; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
153 tr:nth-child(even) { background: #eee; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
154 tr:hover { background: #ddd; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
155 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
156
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
157 @media (max-width: 767px) {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
158 table {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
159 border-spacing: 0 10px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
160 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
161 th { display: none; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
162 tr {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
163 background: #eee;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
164 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
165 td {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
166 display: inline-block;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
167 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
168 td:first-child {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
169 background: #ddd;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
170 padding: 5px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
171 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
172 table a {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
173 font-size: 18px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
174 display: block;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
175 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
176 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
177 </style>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
178 </head>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
179 <body>
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
180 <h1>Index of <?php echo tree_link(); ?></h1>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
181
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
182 <table>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
183 <thead><tr>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
184 <th>File</th>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
185 <th>Size</th>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
186 <th>Date</th>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
187 </tr></thead>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
188 <tbody>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
189 <?php echo file_rows($dirs, true); ?>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
190 <?php echo file_rows($files, false); ?>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
191 </tbody>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
192 </table>
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
193
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
194 <footer>
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
195 <hr>
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
196 <em>
22
431682ff9169 Add version number.
edogawaconan <me@myconan.net>
parents: 21
diff changeset
197 Running <a href="https://bitbucket.org/edogawaconan/dirlist-php">dirlist-php <?php echo DL_VERSION ?></a>.
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
198 Powered by PHP <?php echo phpversion(); ?>.
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
199 </em>
21
fb351f473fd5 Forgot to close footer.
edogawaconan <me@myconan.net>
parents: 20
diff changeset
200 </footer>
14
c2a468e9f3ac Add lightbox support \o/
edogawaconan <me@myconan.net>
parents: 11
diff changeset
201
c2a468e9f3ac Add lightbox support \o/
edogawaconan <me@myconan.net>
parents: 11
diff changeset
202 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
17
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
203
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
204 <script>
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
205 $("table > tbody > tr > td > a").each(function() {
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
206 if (!this.href.match(/\.(jpe?g|png|gif|webp)$/i)) return
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
207 var title = this.outerHTML
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
208 this.setAttribute("data-title", title)
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
209 this.setAttribute("data-lightbox", "aa")
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
210 })
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
211 </script>
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
212
14
c2a468e9f3ac Add lightbox support \o/
edogawaconan <me@myconan.net>
parents: 11
diff changeset
213 <script src="//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/js/lightbox.min.js"></script>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
214 </body>