From 7b6ceda54dd6f6b49d439447f925474b01fbd6a3 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Wed, 23 Jul 2014 16:15:16 +0100 Subject: Separate presentation from list generation and add options for HTML or JSON output --- index.php | 86 +++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 32 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index b8a98fa..7b6a1a9 100644 --- a/index.php +++ b/index.php @@ -67,18 +67,6 @@ function size_readable($size, $max = null, $system = 'si', $retstring = '%01.2f } ?> - - - -Index of / - - - -
- -
- - -
Icon  Name                    Last modified      Size
23) { - $preview = substr($value, 0, 20) . "..>"; - } else { - $preview = $value; - } - $spaces = ""; - for ($i = 0; $i < (24 - strlen($preview)); $i++) { - $spaces = $spaces . " "; - } - -$fileparts = explode('.', strtolower($value)); -$icon = "unknown"; -switch ($fileparts[count($fileparts)-1]) { + $fileparts = explode('.', strtolower($value)); + $icon = "unknown"; + + switch ($fileparts[count($fileparts)-1]) { case "png": case "jpg": case "gif": @@ -256,14 +235,57 @@ switch ($fileparts[count($fileparts)-1]) { default: $icon="unknown"; break; -} + } - echo '[IMG] ' . $preview . '' . $spaces . $key_convert . ' ' . size_readable($size_array[$key], null, "bi") . ' ' . "\n"; + $listing[$listsize]['filename'] = $value; + $listing[$listsize]['type'] = $icon; + $listing[$listsize]['modified'] = $key; + $listing[$listsize]['size'] = $size_array[$key]; + + + $listsize++; } clearstatcache(); + +if (!isset($_GET['format']) || $_GET['format'] == "html") { +?> + + + +Index of / + + + +
+ +
+ +
Icon  Name                    Last modified      Size
+
23) { + $preview = substr($listing[$i]['filename'], 0, 20) . "..>"; + } else { + $preview = $listing[$i]['filename']; + } + + $spaces = ""; + + for ($j = 0; $j < (24 - strlen($preview)); $j++) { + $spaces = $spaces . " "; + } + + echo '[IMG] ' . $preview . '' . $spaces . date("d-M-Y H:i", $listing[$i]['modified']) . ' ' . size_readable($listing[$i]['size'], null, "bi") . ' ' . "\n"; +} ?>
Apache Server at www.blaupload.co.uk Port 80
+ -- cgit v1.2.3