annotate index.php @ 58:281a129299cf

Update js and use jquery
author nanaya <me@myconan.net>
date Tue, 04 Apr 2017 22:26:45 +0900
parents aa12b7cbe1e8
children 612d99622699
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
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
2
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
3 define('DL_VERSION', '2.2.3');
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
4 // Required for strftime(). Set to UTC because :internet:.
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
5 date_default_timezone_set('UTC');
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
6
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
7 // $uri: web-facing path
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
8 $uri = $_SERVER["REQUEST_URI"];
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
9 $query_string_start = strpos($uri, "?");
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
10 if ($query_string_start !== false) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
11 $uri = substr($uri, 0, $query_string_start);
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
12 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
13 $uri = urldecode($uri);
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
14
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
15 // $dir: filesystem path
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
16 if (isset($_SERVER["DL_DIR"])) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
17 $dir = $_SERVER["DL_DIR"];
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
18 } elseif (isset($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
19 $dir = $_SERVER["CONTEXT_DOCUMENT_ROOT"];
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
20 $dir .= substr($uri, strlen($_SERVER["CONTEXT_PREFIX"]));
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
21 } else {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
22 $dir = $_SERVER["DOCUMENT_ROOT"] . $uri;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
23 }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
24
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
25 if (realpath($dir) === false) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
26 header("HTTP/1.0 404 Not Found");
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
27 } elseif (substr($uri, -1) !== "/") {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
28 header("Location: " . $uri . "/");
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
29 }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
30
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
31 if (http_response_code() !== 200) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
32 exit;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
33 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
34
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
35 $dir_handle = opendir($dir);
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
36 $files = array();
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
37 $dirs = array();
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
38 while (($file = readdir($dir_handle)) !== false) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
39 if ($file === "." || $file === "..") {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
40 continue;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
41 } elseif (!(isset($_SERVER["DL_SHOWALL"]) && $_SERVER["DL_SHOWALL"] === "1") && substr($file, 0, 1) === ".") {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
42 continue;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
43 } elseif (is_dir($dir . $file)) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
44 $dirs[] = $file;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
45 } else {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
46 $files[] = $file;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
47 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
48 }
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
49 sort($files);
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
50 sort($dirs);
43
54c13838f8bb Add spacing to before/after hidden data part.
nanaya <me@myconan.net>
parents: 42
diff changeset
51
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
52 // BEGIN UTILITY
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
53 function h($string)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
54 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
55 return htmlspecialchars($string, ENT_QUOTES, "UTF-8");
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
56 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
57 function a($string)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
58 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
59 return preg_replace("#(%2F)+#", "/", rawurlencode($string));
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
60 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
61 function link_to($target, $title)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
62 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
63 return('<a href="' . a($target) . '">' . h($title) . "</a>");
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
64 }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
65
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
66 function human_size($size)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
67 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
68 $thousand_units = array("ko", "Mo", "Go", "To", "Po");
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
69
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
70 $return_format = "%d %s";
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
71
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
72 if ($size === 1) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
73 $return_unit = "octet";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
74 } elseif ($size < 1000) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
75 $return_unit = "octets";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
76 } else {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
77 $size /= 1000;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
78 for ($i = 0; $size >= 1000 && $i < count($thousand_units); $i++) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
79 $size /= 1000;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
80 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
81 $return_format = "%.2f %s";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
82 $return_unit = $thousand_units[$i];
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
83 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
84 return sprintf($return_format, $size, $return_unit);
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
85 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
86
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
87 function hidden_data($data = "", $is_dir = false)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
88 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
89 return "<i> " . ($is_dir === true ? 0 : 1) . " " . $data . " </i>";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
90 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
91 // END UTILITY
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
92
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
93 function tree_link($uri)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
94 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
95 $uri_array = explode("/", trim($uri, "/"));
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
96
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
97 $tree_path = "/";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
98 $tree_link = link_to($tree_path, "[root]");
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
99 $tree_link .= "/";
51
29543401ef18 Ignore nonexisting files.
nanaya <me@myconan.net>
parents: 50
diff changeset
100
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
101 foreach ($uri_array as $p) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
102 if ($p === "") {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
103 continue;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
104 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
105 $tree_path .= $p . "/";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
106 $tree_link .= link_to($tree_path, $p) . "/";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
107 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
108
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
109 return $tree_link;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
110 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
111
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
112 function up_link($uri)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
113 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
114 if ($uri !== "/") {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
115 return "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
116 }
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
117 }
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
118
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
119 function file_rows($dir, $files, $is_dir)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
120 {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
121 $file_suffix = "";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
122 if ($is_dir) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
123 $file_suffix = "/";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
124 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
125
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
126 $file_rows = "";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
127 foreach ($files as $file) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
128 $file_path = $dir."/".$file;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
129
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
130 if (!file_exists($file_path)) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
131 continue;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
132 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
133 $file_stat = stat($file_path);
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
134
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
135 $file_rows .=
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
136 "<tr>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
137 "<td>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
138 hidden_data("", $is_dir).
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
139 link_to($file.$file_suffix, $file.$file_suffix).
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
140 "</td>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
141 "<td>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
142 hidden_data($file_stat["size"], $is_dir).
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
143 ($is_dir ? "[dir]" : human_size($file_stat["size"])).
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
144 "</td>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
145 "<td>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
146 hidden_data("", $is_dir).$columns["date"].
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
147 h(strftime("%Y-%m-%d %H:%M %Z", $file_stat["mtime"])).
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
148 "</td>".
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
149 "</tr>";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
150 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
151 return $file_rows;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
152 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
153
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
154 header('Content-Type: text/html; charset=utf-8');
0
8cba59d07798 Initial import.
edogawaconan <me@myconan.net>
parents:
diff changeset
155 ?>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
156 <!doctype html>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
157 <head>
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
158 <meta charset="utf-8">
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
159 <title>Index of <?= h($uri); ?></title>
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
160 <meta name="viewport" content="width=device-width, initial-scale=1.0">
58
281a129299cf Update js and use jquery
nanaya <me@myconan.net>
parents: 57
diff changeset
161 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.css">
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
162
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
163 <style type="text/css">
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
164 .mfp-content figure { margin: 0; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
165 * { box-sizing: border-box; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
166 body {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
167 font-family: Segoe UI, sans-serif;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
168 font-size: 14px;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
169 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
170 h1 { margin: 5px; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
171 table {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
172 width: 100%;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
173 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
174 th:first-child, td:first-child {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
175 width: 100%;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
176 white-space: pre-wrap;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
177 word-wrap: break-word;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
178 word-break: break-all;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
179 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
180 tr {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
181 position: relative;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
182 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
183 th, td {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
184 white-space: nowrap;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
185 padding: 2px 5px;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
186 }
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
187
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
188 i {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
189 display: none;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
190 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
191
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
192 input {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
193 width: 100%;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
194 margin: 10px 0px;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
195 }
46
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
196
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
197 th span {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
198 display: block;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
199 text-decoration: underline;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
200 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
201 th span.desc::after {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
202 content: " ▼";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
203 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
204 th span.asc::after {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
205 content: " ▲";
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
206 }
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
207
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
208 @media (min-width: 768px) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
209 th {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
210 background: #ccc;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
211 cursor: pointer;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
212 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
213 tr:nth-child(even) { background: #eee; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
214 tr:hover { background: #ddd; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
215 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
216
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
217 @media (max-width: 767px) {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
218 table {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
219 border-spacing: 0 10px;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
220 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
221 th { display: none; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
222 tr {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
223 background: #eee;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
224 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
225 td {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
226 display: inline-block;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
227 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
228 td:first-child {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
229 background: #ddd;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
230 padding: 5px;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
231 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
232 table a {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
233 font-size: 18px;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
234 display: block;
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
235 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
236 input { font-size: 18px; }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
237 }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
238 </style>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
239 </head>
46
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
240 <body id="files">
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
241 <h1>Index of <?= tree_link($uri); ?></h1>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
242
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
243 <input placeholder="search (non-recursive)" class="search" />
46
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
244
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
245 <table>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
246 <thead>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
247 <tr>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
248 <th><span class="sort" data-sort="filename">File</span></th>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
249 <th><span class="sort" data-sort="size">Size</span></th>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
250 <th><span class="sort" data-sort="date">Date</span></th>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
251 </tr>
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
252 <?= up_link($uri); ?>
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
253 </thead>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
254 <tbody class="list">
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
255 <?= file_rows($dir, $dirs, true); ?>
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
256 <?= file_rows($dir, $files, false); ?>
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
257 </tbody>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
258 </table>
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
259
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
260 <footer>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
261 <hr>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
262 <em>
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
263 Running <a href="https://bitbucket.org/edogawaconan/dirlist-php">dirlist-php <?= DL_VERSION ?></a>.
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
264 Powered by PHP <?= phpversion(); ?>.
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
265 </em>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
266 </footer>
14
c2a468e9f3ac Add lightbox support \o/
edogawaconan <me@myconan.net>
parents: 11
diff changeset
267
58
281a129299cf Update js and use jquery
nanaya <me@myconan.net>
parents: 57
diff changeset
268 <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
281a129299cf Update js and use jquery
nanaya <me@myconan.net>
parents: 57
diff changeset
269 <script src="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>
281a129299cf Update js and use jquery
nanaya <me@myconan.net>
parents: 57
diff changeset
270 <script src="//cdnjs.cloudflare.com/ajax/libs/list.js/1.2.0/list.min.js"></script>
17
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
271
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
272 <script>
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
273 $("table td a").each(function() {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
274 if (!this.href.match(/\.(jpe?g|png|gif|webp)$/i)) return
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
275
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
276 this.className = "image"
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
277 this.setAttribute("title", this.innerHTML)
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
278 })
32
986aec12eb7f Use magnific popup instead of lightbox.
edogawaconan <me@myconan.net>
parents: 30
diff changeset
279
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
280 $("table > tbody").magnificPopup({
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
281 delegate: "a.image",
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
282 type: "image",
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
283 gallery: { enabled: true }
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
284 })
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
285
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
286 $("tbody td:nth-child(3n + 1)").addClass("filename")
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
287 $("tbody td:nth-child(3n + 2)").addClass("size")
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
288 $("tbody td:nth-child(3n + 3)").addClass("date")
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
289
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
290 new List("files", {
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
291 valueNames: ["filename", "size", "date"],
57
aa12b7cbe1e8 Use short echo syntax
nanaya <me@myconan.net>
parents: 56
diff changeset
292 page: <?= count($dirs) + count($files); ?>
56
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
293 })
d0b3c58c2781 Style cleanup
nanaya <me@myconan.net>
parents: 55
diff changeset
294 </script>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
295 </body>