]> git.mxchange.org Git - simple-upload.git/commitdiff
Added optional modification date display
authors-ko <aleks@s-ko.net>
Thu, 25 Sep 2014 21:55:30 +0000 (22:55 +0100)
committers-ko <aleks@s-ko.net>
Thu, 25 Sep 2014 21:55:30 +0000 (22:55 +0100)
index.php

index 2952e39b0c1744f729e853b3b9b5f6f5c43a5101..ff1aa24e349023a991e6f42efb9b27661d3e9529 100644 (file)
--- a/index.php
+++ b/index.php
                listfiles_size => true,
 
 
+               // Display file dates
+               listfiles_date => true,
+
+
                // Randomize file names (number of 'false')
                random_name_len => 10,
 
@@ -76,7 +80,7 @@
                echo '</pre>';
        }
 
-       function FormatSize ($bytes, $precision = 2) {
+       function FormatSize ($bytes) {
                $units = array('B', 'KB', 'MB', 'GB', 'TB');
 
                $bytes = max($bytes, 0);
@@ -85,7 +89,7 @@
 
                $bytes /= pow(1024, $pow);
 
-               return round($bytes, $precision) . ' ' . $units[$pow];
+               return ceil($bytes) . ' ' . $units[$pow];
        }
 
 
                                        $dh = opendir($settings['uploaddir']);
                                        while (false !== ($filename = readdir($dh)))
                                                if (!in_array($filename, array('.', '..', $data['scriptname']))) {
-                                                       $size = '';
+                                                       $file_info = array();
+
+                                                       if ($settings['listfiles_size'])
+                                                               $file_info[] = FormatSize(filesize($filename));
 
                                                        if ($settings['listfiles_size'])
-                                                               $size = '(' . FormatSize(filesize($filename)) . ')';
+                                                               $file_info[] = date ('F d Y H:i:s.', filemtime($filename));
+
+                                                       $file_info = implode(',', $file_info);
+
+                                                       if (strlen($file_info) > 0)
+                                                               $file_info = '(' . $file_info . ')';
 
-                                                       echo "<li><a href=\"$filename\">$filename $size</a></li>";
+                                                       echo "<li><a href=\"$filename\">$filename $file_info</a></li>";
                                                }
                                ?>
                        </ul>