annotate index.php @ 47:546c6b40d250

Changed enough stuff to bump minor version.
author nanaya <me@myconan.net>
date Sun, 24 May 2015 18:48:11 +0900
parents 113f9121d38b
children c388003e921a
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
47
546c6b40d250 Changed enough stuff to bump minor version.
nanaya <me@myconan.net>
parents: 46
diff changeset
2 define('DL_VERSION', '2.2.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"]; }
30
c482f0db5c28 Turns out "CONTEXT_DOCUMENT_ROOT" isn't enough.
edogawaconan <me@myconan.net>
parents: 28
diff changeset
16 elseif (isset($_SERVER["CONTEXT_DOCUMENT_ROOT"])) {
c482f0db5c28 Turns out "CONTEXT_DOCUMENT_ROOT" isn't enough.
edogawaconan <me@myconan.net>
parents: 28
diff changeset
17 $dir = $_SERVER["CONTEXT_DOCUMENT_ROOT"];
c482f0db5c28 Turns out "CONTEXT_DOCUMENT_ROOT" isn't enough.
edogawaconan <me@myconan.net>
parents: 28
diff changeset
18 $dir .= substr($uri, strlen($_SERVER["CONTEXT_PREFIX"]));
c482f0db5c28 Turns out "CONTEXT_DOCUMENT_ROOT" isn't enough.
edogawaconan <me@myconan.net>
parents: 28
diff changeset
19 }
26
eee7ca924a5e Make it work with apache (at least XAMPP).
edogawaconan <me@myconan.net>
parents: 25
diff changeset
20 else { $dir = $_SERVER["DOCUMENT_ROOT"] . $uri; }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
21
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
22 if (realpath($dir) === false) {
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
23 header("HTTP/1.0 404 Not Found");
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
24 } elseif (substr($uri, -1) !== "/") {
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
25 header("Location: " . $uri . "/");
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
26 }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
27
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
28 if (http_response_code() !== 200) { exit; }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
29
34
f761177dc1d4 Remove error suppression.
edogawaconan <me@myconan.net>
parents: 33
diff changeset
30 $dir_handle = opendir($dir);
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
31 $files = array();
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
32 $dirs = array();
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
33 while (($file = readdir($dir_handle)) !== false) {
28
ce92f4d41714 Add support for displaying hidden files.
edogawaconan <me@myconan.net>
parents: 27
diff changeset
34 if ($file === "." || $file === "..") { continue; }
ce92f4d41714 Add support for displaying hidden files.
edogawaconan <me@myconan.net>
parents: 27
diff changeset
35 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
36 elseif (is_dir($dir . $file)) { $dirs[] = $file; }
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
37 else { $files[] = $file; }
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
38 }
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
39 sort($files);
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
40 sort($dirs);
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
41
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
42 // BEGIN UTILITY
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
43 function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); }
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
44 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
45 function link_to($target, $title) { return('<a href="' . a($target) . '">' . h($title) . "</a>"); }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
46
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
47 function human_size($size) {
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
48 $thousand_units = array("ko", "Mo", "Go", "To", "Po");
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
49
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
50 $return_format = "%d %s";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
51
35
21132c7b6aaa Only 1 is singular.
edogawaconan <me@myconan.net>
parents: 34
diff changeset
52 if ($size === 1) {
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
53 $return_unit = "octet";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
54 } elseif ($size < 1000) {
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
55 $return_unit = "octets";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
56 } else {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
57 $size /= 1000;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
58 for ($i = 0; $size >= 1000 && $i < count($thousand_units); $i++) { $size /= 1000; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
59 $return_format = "%.2f %s";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
60 $return_unit = $thousand_units[$i];
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
61 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
62 return sprintf($return_format, $size, $return_unit);
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
63 }
43
54c13838f8bb Add spacing to before/after hidden data part.
nanaya <me@myconan.net>
parents: 42
diff changeset
64
45
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
65 function hidden_data($data = "", $is_dir = false) {
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
66 return "<i> " . ($is_dir === true ? 0 : 1) . " " . $data . " </i>";
43
54c13838f8bb Add spacing to before/after hidden data part.
nanaya <me@myconan.net>
parents: 42
diff changeset
67 }
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
68 // END UTILITY
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
69
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
70 function tree_link() {
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
71 global $uri;
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
72
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
73 $uri_array = explode("/", trim($uri, "/"));
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
74
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
75 $tree_path = "/";
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
76 $tree_link = link_to($tree_path, "[root]");
20
caf498a0c602 Hide [root] for aliased directory.
edogawaconan <me@myconan.net>
parents: 19
diff changeset
77 $tree_link .= "/";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
78
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
79 foreach ($uri_array as $p) {
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
80 if ($p === "") { continue; }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
81 $tree_path .= $p . "/";
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
82 $tree_link .= link_to($tree_path, $p) . "/";
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
83 }
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
84
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
85 return $tree_link;
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
86 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
87
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
88 function up_link() {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
89 if ($uri !== "/") {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
90 return "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>";
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
91 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
92 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
93
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
94 function file_rows($files, $is_dir) {
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
95 global $dir, $uri;
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
96
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
97 $file_rows = "";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
98 $file_suffix = "";
45
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
99 $list_file_prefix = hidden_data("", $is_dir);
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
100
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
101 if ($is_dir) {
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
102 $file_suffix = "/";
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
103 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
104
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
105 foreach($files as $file) {
36
9a2e0b2a2d1d Suppress stat() failure.
edogawaconan <me@myconan.net>
parents: 35
diff changeset
106 $file_stat = @stat($dir . "/". $file);
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
107
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
108 $file_rows .= "<tr>";
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
109 $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>";
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
110
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
111 $file_rows .= "<td>";
45
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
112 $file_rows .= hidden_data($file_stat["size"], $is_dir);
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
113 if ($is_dir) { $file_rows .= "[dir]"; }
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
114 else { $file_rows .= human_size($file_stat['size']); }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
115 $file_rows .= "</td>";
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
116
45
7de8f524d1e4 Always group by directory no matter what type of sorting.
nanaya <me@myconan.net>
parents: 44
diff changeset
117 $file_rows .= "<td>" . hidden_data("", $is_dir) . h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime'])) . "</td>";
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
118
2
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
119 $file_rows .= "</tr>";
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
120 }
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
121 return $file_rows;
9b5884ba214a Fix indentation.
edogawaconan <me@myconan.net>
parents: 0
diff changeset
122 }
0
8cba59d07798 Initial import.
edogawaconan <me@myconan.net>
parents:
diff changeset
123 ?>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
124 <?php header('Content-Type: text/html; charset=utf-8'); ?>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
125 <!doctype html>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
126 <head>
37
08c4e9388f54 Use new meta charset form.
edogawaconan <me@myconan.net>
parents: 36
diff changeset
127 <meta charset="utf-8">
23
949398173ecb Much simpler setup with $request_filename.
edogawaconan <me@myconan.net>
parents: 22
diff changeset
128 <title>Index of <?php echo h($uri); ?></title>
39
79d3478c33a3 Allow user zooming.
nanaya <me@myconan.net>
parents: 37
diff changeset
129 <meta name="viewport" content="width=device-width, initial-scale=1.0">
32
986aec12eb7f Use magnific popup instead of lightbox.
edogawaconan <me@myconan.net>
parents: 30
diff changeset
130 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/0.9.9/magnific-popup.css">
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
131 <style type="text/css">
32
986aec12eb7f Use magnific popup instead of lightbox.
edogawaconan <me@myconan.net>
parents: 30
diff changeset
132 .mfp-content figure { margin: 0; }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
133 * { box-sizing: border-box; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
134 body {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
135 font-family: Segoe UI, sans-serif;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
136 font-size: 14px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
137 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
138 h1 { margin: 5px; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
139 table {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
140 width: 100%;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
141 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
142 th:first-child, td:first-child {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
143 width: 100%;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
144 white-space: pre-wrap;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
145 word-wrap: break-word;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
146 word-break: break-all;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
147 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
148 tr {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
149 position: relative;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
150 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
151 th, td {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
152 white-space: nowrap;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
153 padding: 2px 5px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
154 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
155
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
156 i {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
157 display: none;
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
158 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
159
46
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
160 input {
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
161 width: 100%;
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
162 margin: 10px 0px;
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
163 }
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
164
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
165 th span {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
166 display: block;
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
167 text-decoration: underline;
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
168 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
169 th span.desc:after {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
170 content: " ▼";
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
171 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
172 th span.asc:after {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
173 content: " ▲";
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
174 }
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
175
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
176 @media (min-width: 768px) {
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
177 th {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
178 background: #ccc;
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
179 cursor: pointer;
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
180 }
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
181 tr:nth-child(even) { background: #eee; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
182 tr:hover { background: #ddd; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
183 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
184
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
185 @media (max-width: 767px) {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
186 table {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
187 border-spacing: 0 10px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
188 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
189 th { display: none; }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
190 tr {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
191 background: #eee;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
192 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
193 td {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
194 display: inline-block;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
195 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
196 td:first-child {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
197 background: #ddd;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
198 padding: 5px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
199 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
200 table a {
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
201 font-size: 18px;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
202 display: block;
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
203 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
204 }
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
205 </style>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
206 </head>
46
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
207 <body id="files">
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
208 <h1>Index of <?php echo tree_link(); ?></h1>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
209
46
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
210 <input placeholder="search (non-recursive)" class="search" />
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
211
113f9121d38b Allow searching \o/
nanaya <me@myconan.net>
parents: 45
diff changeset
212 <table>
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
213 <thead>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
214 <tr>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
215 <th><span class="sort" data-sort="filename">File</span></th>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
216 <th><span class="sort" data-sort="size">Size</span></th>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
217 <th><span class="sort" data-sort="date">Date</span></th>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
218 </tr>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
219 <?php echo up_link(); ?>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
220 </thead>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
221 <tbody class="list">
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
222 <?php echo file_rows($dirs, true); ?>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
223 <?php echo file_rows($files, false); ?>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
224 </tbody>
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
225 </table>
4
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
226
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
227 <footer>
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
228 <hr>
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
229 <em>
22
431682ff9169 Add version number.
edogawaconan <me@myconan.net>
parents: 21
diff changeset
230 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
231 Powered by PHP <?php echo phpversion(); ?>.
7812af1c23ae Actual refactor.
edogawaconan <me@myconan.net>
parents: 3
diff changeset
232 </em>
21
fb351f473fd5 Forgot to close footer.
edogawaconan <me@myconan.net>
parents: 20
diff changeset
233 </footer>
14
c2a468e9f3ac Add lightbox support \o/
edogawaconan <me@myconan.net>
parents: 11
diff changeset
234
32
986aec12eb7f Use magnific popup instead of lightbox.
edogawaconan <me@myconan.net>
parents: 30
diff changeset
235 <script src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.1.4/zepto.min.js"></script>
986aec12eb7f Use magnific popup instead of lightbox.
edogawaconan <me@myconan.net>
parents: 30
diff changeset
236 <script src="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/0.9.9/jquery.magnific-popup.min.js"></script>
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
237 <script src="//cdnjs.cloudflare.com/ajax/libs/list.js/1.1.1/list.min.js"></script>
17
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
238
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
239 <script>
41
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
240 $("table td a").each(function() {
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
241 if (!this.href.match(/\.(jpe?g|png|gif|webp)$/i)) return
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
242 this.className = "image"
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
243 this.setAttribute("title", this.innerHTML)
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
244 })
32
986aec12eb7f Use magnific popup instead of lightbox.
edogawaconan <me@myconan.net>
parents: 30
diff changeset
245
41
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
246 $("table > tbody").magnificPopup({
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
247 delegate: "a.image",
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
248 type: "image",
e122e4e55e75 No need to wait for document ready since it's already at the bottom of the page.
nanaya <me@myconan.net>
parents: 40
diff changeset
249 gallery: { enabled: true }
17
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
250 })
42
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
251
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
252 $("tbody td:nth-child(3n + 1)").addClass("filename")
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
253 $("tbody td:nth-child(3n + 2)").addClass("size")
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
254 $("tbody td:nth-child(3n + 3)").addClass("date")
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
255
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
256 ;(function() {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
257 var
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
258 options = {
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
259 valueNames: ["filename", "size", "date"],
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
260 page: <?php echo count($dirs) + count($files); ?>
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
261 },
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
262 list = new List("files", options)
ddb5458658d2 Sortable list \o/
nanaya <me@myconan.net>
parents: 41
diff changeset
263 })()
17
8b222e3ffe25 Set lightbox attributes through javascript instead of php.
edogawaconan <me@myconan.net>
parents: 16
diff changeset
264 </script>
3
9ea8be5b28d1 "refactor".
edogawaconan <me@myconan.net>
parents: 2
diff changeset
265 </body>