Mercurial > dirlist-php
comparison index.php @ 52:f48a4fbb9cf9
Rewrite file rows generator.
author | nanaya <me@myconan.net> |
---|---|
date | Mon, 24 Aug 2015 21:34:58 +0900 |
parents | 29543401ef18 |
children | 8e6acb7d4e48 |
comparison
equal
deleted
inserted
replaced
51:29543401ef18 | 52:f48a4fbb9cf9 |
---|---|
88 return "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>"; | 88 return "<tr><td colspan=3>" . link_to(dirname($uri) . "/", "[up]") . "</td></tr>"; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 function file_rows($dir, $files, $is_dir) { | 92 function file_rows($dir, $files, $is_dir) { |
93 $file_suffix = ""; | |
94 if ($is_dir) { $file_suffix = "/"; } | |
95 | |
93 $file_rows = ""; | 96 $file_rows = ""; |
94 $file_suffix = ""; | |
95 $list_file_prefix = hidden_data("", $is_dir); | |
96 | |
97 if ($is_dir) { | |
98 $file_suffix = "/"; | |
99 } | |
100 | |
101 foreach($files as $file) { | 97 foreach($files as $file) { |
102 $file_path = $dir."/".$file; | 98 $file_path = $dir."/".$file; |
103 | 99 |
104 if (!file_exists($file_path)) { continue; } | 100 if (!file_exists($file_path)) { continue; } |
105 $file_stat = stat($file_path); | 101 $file_stat = stat($file_path); |
106 | 102 |
107 $file_rows .= "<tr>"; | 103 $file_rows .= |
108 $file_rows .= "<td>". $list_file_prefix . link_to($file . $file_suffix, $file . $file_suffix)."</td>"; | 104 "<tr>". |
109 | 105 "<td>". |
110 $file_rows .= "<td>"; | 106 hidden_data("", $is_dir). |
111 $file_rows .= hidden_data($file_stat["size"], $is_dir); | 107 link_to($file.$file_suffix, $file.$file_suffix). |
112 if ($is_dir) { $file_rows .= "[dir]"; } | 108 "</td>". |
113 else { $file_rows .= human_size($file_stat['size']); } | 109 "<td>". |
114 $file_rows .= "</td>"; | 110 hidden_data($file_stat["size"], $is_dir). |
115 | 111 ($is_dir ? "[dir]" : human_size($file_stat["size"])). |
116 $file_rows .= "<td>" . hidden_data("", $is_dir) . h(strftime("%Y-%m-%d %H:%M %Z", $file_stat['mtime'])) . "</td>"; | 112 "</td>". |
117 | 113 "<td>". |
118 $file_rows .= "</tr>"; | 114 hidden_data("", $is_dir).$columns["date"]. |
115 h(strftime("%Y-%m-%d %H:%M %Z", $file_stat["mtime"])). | |
116 "</td>". | |
117 "</tr>"; | |
119 } | 118 } |
120 return $file_rows; | 119 return $file_rows; |
121 } | 120 } |
122 ?> | 121 ?> |
123 <?php header('Content-Type: text/html; charset=utf-8'); ?> | 122 <?php header('Content-Type: text/html; charset=utf-8'); ?> |