Mercurial > dirlist-php
comparison index.php @ 14:c2a468e9f3ac
Add lightbox support \o/
author | edogawaconan <me@myconan.net> |
---|---|
date | Wed, 22 Oct 2014 01:12:55 +0900 |
parents | 9abfd376740d |
children | 3dbddf76760a |
comparison
equal
deleted
inserted
replaced
13:b6b65a5b9c1a | 14:c2a468e9f3ac |
---|---|
40 sort($dirs); | 40 sort($dirs); |
41 | 41 |
42 // BEGIN UTILITY | 42 // BEGIN UTILITY |
43 function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); } | 43 function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); } |
44 function a($string) { return preg_replace("#(%2F)+#", "/", rawurlencode($string)); } | 44 function a($string) { return preg_replace("#(%2F)+#", "/", rawurlencode($string)); } |
45 function link_to($target, $title) { return('<a href="' . a($target) . '">' . h($title) . "</a>"); } | 45 function link_to($target, $title) { |
46 $lightbox = ""; | |
47 if (substr($target, -1) !== "/" && preg_match("/(jpe?g|gif|png|webp)$/i", pathinfo($target, PATHINFO_EXTENSION)) === 1) { | |
48 $lightbox = ' data-lightbox="aa" '; | |
49 } | |
50 | |
51 return('<a href="' . a($target) . '"' . $lightbox . ">" . h($title) . "</a>"); | |
52 } | |
46 | 53 |
47 function human_size($size) { | 54 function human_size($size) { |
48 $thousand_units = array("ko", "Mo", "Go", "To", "Po"); | 55 $thousand_units = array("ko", "Mo", "Go", "To", "Po"); |
49 | 56 |
50 $return_format = "%d %s"; | 57 $return_format = "%d %s"; |
117 <!doctype html> | 124 <!doctype html> |
118 <head> | 125 <head> |
119 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> | 126 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> |
120 <title>Index of <?php echo h($prefix . $path); ?></title> | 127 <title>Index of <?php echo h($prefix . $path); ?></title> |
121 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> | 128 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> |
129 <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/css/lightbox.css"> | |
122 <style type="text/css"> | 130 <style type="text/css"> |
123 * { box-sizing: border-box; } | 131 * { box-sizing: border-box; } |
124 body { | 132 body { |
125 font-family: Segoe UI, sans-serif; | 133 font-family: Segoe UI, sans-serif; |
126 font-size: 14px; | 134 font-size: 14px; |
190 <hr> | 198 <hr> |
191 <em> | 199 <em> |
192 Running <a href="https://bitbucket.org/edogawaconan/dirlist-php">dirlist-php</a>. | 200 Running <a href="https://bitbucket.org/edogawaconan/dirlist-php">dirlist-php</a>. |
193 Powered by PHP <?php echo phpversion(); ?>. | 201 Powered by PHP <?php echo phpversion(); ?>. |
194 </em> | 202 </em> |
203 | |
204 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> | |
205 <script src="//cdnjs.cloudflare.com/ajax/libs/lightbox2/2.7.1/js/lightbox.min.js"></script> | |
195 </body> | 206 </body> |