summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php86
1 files changed, 54 insertions, 32 deletions
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
}
?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<title>Index of /</title>
-</head>
-<body>
-
-<form action="upload_file.php" method="post"
-enctype="multipart/form-data">
-<input type="file" name="file" id="file"> <input type="submit" name="submit" value="Submit">
-</form>
-
<?php
$nameurl = "?C=N;O=A";
$modifiedurl = "?C=M;O=A";
@@ -106,12 +94,11 @@ if (isset($_GET['C'])) {
}
}
-
+$listing = array();
+$listing[0] = array();
?>
-
-<pre><img src="/icons/blank.gif" alt="Icon "> <a href="<?php echo $nameurl; ?>">Name</a> <a href="<?php echo $modifiedurl; ?>">Last modified</a> <a href="<?php echo $sizeurl; ?>">Size</a><hr><?php
-
+<?php
date_default_timezone_set("GB");
#print_r(listdir_by_date("./"));
@@ -146,24 +133,16 @@ if (isset($sort)) {
krsort($new_array);
}
+$listsize = 0;
+
while ($this_array = each($new_array)){
$value = $this_array['value'];
$key = $this_array['key'];
- $key_convert = date("d-M-Y H:i", $key);
- if (strlen($value) > 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 src="/icons/'.$icon.'.gif" alt="[IMG]"> <a href="' . $value . '">' . $preview . '</a>' . $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") {
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<title>Index of /</title>
+</head>
+<body>
+
+<form action="upload_file.php" method="post"
+enctype="multipart/form-data">
+<input type="file" name="file" id="file"> <input type="submit" name="submit" value="Submit">
+</form>
+
+<pre><img src="/icons/blank.gif" alt="Icon "> <a href="<?php echo $nameurl; ?>">Name</a> <a href="<?php echo $modifiedurl; ?>">Last modified</a> <a href="<?php echo $sizeurl; ?>">Size</a>
+<hr><?php
+for ($i = 0; $i < count($listing); $i++) {
+ if (strlen($listing[$i]['filename']) > 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 src="/icons/' . $listing[$i]['type'] . '.gif" alt="[IMG]"> <a href="' . $listing[$i]['filename'] . '">' . $preview . '</a>' . $spaces . date("d-M-Y H:i", $listing[$i]['modified']) . ' ' . size_readable($listing[$i]['size'], null, "bi") . ' ' . "\n";
+}
?>
<hr></pre>
<address>Apache Server at www.blaupload.co.uk Port 80</address>
</body></html>
+<?php
+} else if ($_GET['format'] == "json") {
+ echo json_encode($listing);
+}
+?>