summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.php269
1 files changed, 269 insertions, 0 deletions
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..b8a98fa
--- /dev/null
+++ b/index.php
@@ -0,0 +1,269 @@
+<?php
+$pass = 'REPLACE THIS WITH A SHA256 HASH';
+
+if ($_POST) {
+ if ((hash("sha256", $_POST['password']) == $pass)) {
+ if (isset($_POST['rememberme'])) {
+ /* Set cookie to last 1 year */
+ setcookie('password', hash("sha256", $_POST['password']), time()+60*60*24*365, '/', 'www.blaupload.co.uk');
+ } else {
+ /* Cookie expires when browser closes */
+ setcookie('password', hash("sha256", $_POST['password']), false, '/', 'www.blaupload.co.uk');
+ }
+ header('Location: http://www.blaupload.co.uk/');
+ } else {
+ header('Location: http://www.blaupload.co.uk/');
+ exit();
+ }
+} else {
+ if (!isset($_COOKIE["password"]) || (isset($_COOKIE["password"]) && $_COOKIE["password"] != $pass)) {
+?>
+<html>
+<head>
+<title>Irn-Bru</title>
+<script type="text/javascript">
+ function formfocus() {
+ document.getElementById('password').focus();
+ }
+ window.onload = formfocus;
+</script>
+</head>
+<body>
+
+<form name="form" method="post" action="./">
+ <p><input type="password" title="Enter your password" name="password" id="password">
+ <br><input type="checkbox" name="rememberme" value="rememberme">Remember me</p>
+ <p><input type="submit" name="Submit" value="Login"></p>
+</form>
+</body>
+</html>
+<?php
+ exit();
+ }
+}
+
+function size_readable($size, $max = null, $system = 'si', $retstring = '%01.2f %s') {
+ // Pick units
+ $systems['si']['prefix'] = array('B', 'K', 'MB', 'GB', 'TB', 'PB');
+ $systems['si']['size'] = 1000;
+ $systems['bi']['prefix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
+ $systems['bi']['size'] = 1024;
+ $sys = isset($systems[$system]) ? $systems[$system] : $systems['si'];
+
+ // Max unit to display
+ $depth = count($sys['prefix']) - 1;
+ if ($max && false !== $d = array_search($max, $sys['prefix'])) {
+ $depth = $d;
+ }
+
+ // Loop
+ $i = 0;
+ while ($size >= $sys['size'] && $i < $depth) {
+ $size /= $sys['size'];
+ $i++;
+ }
+
+ return sprintf($retstring, $size, $sys['prefix'][$i]);
+}
+?>
+
+<!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";
+$sizeurl = "?C=S;O=A";
+
+if (isset($_GET['C'])) {
+ $sort = preg_split("/;O=/", $_GET['C']);
+ if ($_GET['C'] == "N;O=A") {
+ $nameurl = "?C=N;O=D";
+ } else if ($_GET['C'] == "M;O=A") {
+ $modifiedurl = "?C=M;O=D";
+ } else if ($_GET['C'] == "S;O=A") {
+ $sizeurl = "?C=S;O=D";
+ }
+}
+
+if (isset($_GET['C'])) {
+ $sort = preg_split("/;O=/", $_GET['C']);
+ if ($_GET['C'] == "N;O=A") {
+ $nameurl = "?C=N;O=D";
+ } else if ($_GET['C'] == "M;O=A") {
+ $modifiedurl = "?C=M;O=D";
+ } else if ($_GET['C'] == "S;O=A") {
+ $sizeurl = "?C=S;O=D";
+ }
+}
+
+
+?>
+
+
+<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
+
+date_default_timezone_set("GB");
+#print_r(listdir_by_date("./"));
+
+$files_directory = "./";
+
+$new_array = array();
+$files = array();
+
+$fdirectory = opendir("$files_directory");
+while ($file = readdir($fdirectory)) {
+ if (($file == ".") || ($file == "..")) {
+ } else {
+ array_push($files, $file);
+ }
+}
+
+foreach ($files as $key=> $file) {
+ $c_date = filemtime("$files_directory/$file");
+ $new_array[$c_date] = $file;
+ $size_array[$c_date] = filesize("$files_directory/$file");
+}
+
+if (isset($sort)) {
+ if ($sort[0] == "M") {
+ if ($sort[1] == "A") {
+ ksort($new_array);
+ } else {
+ krsort($new_array);
+ }
+ }
+} else {
+ krsort($new_array);
+}
+
+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]) {
+ case "png":
+ case "jpg":
+ case "gif":
+ case "bmp":
+ case "jpeg":
+ case "svg":
+ $icon="image2";
+ break;
+ case "exe":
+ case "jar":
+ case "class":
+ case "apk":
+ $icon="binary";
+ break;
+ case "c":
+ case "cpp":
+ case "h":
+ $icon="c";
+ break;
+ case "doc":
+ case "docx":
+ case "dot":
+ case "dotx":
+ case "odt":
+ case "ott":
+ case "oth":
+ case "odm":
+ case "xls":
+ case "xlsx":
+ case "ppt":
+ case "pptx":
+ $icon="layout";
+ break;
+ case "avi":
+ case "mkv":
+ case "wmv":
+ case "ogv":
+ case "3gp":
+ case "divx":
+ case "mov":
+ $icon="movie";
+ break;
+ case "pdf":
+ $icon="pdf";
+ break;
+ case "ps":
+ $icon="ps";
+ break;
+ case "java":
+ case "php":
+ case "html":
+ case "htm":
+ case "xml":
+ case "cs":
+ case "sh":
+ case "bat":
+ case "js":
+ case "jsp":
+ case "py":
+ case "cgi":
+ case "pl":
+ $icon="script";
+ break;
+ case "wav":
+ $icon="sound1";
+ break;
+ case "mp3":
+ case "ogg":
+ case "wma":
+ case "aac":
+ $icon="sound2";
+ break;
+ case "tex":
+ $icon="tex";
+ case "txt":
+ case "rtf":
+ case "log":
+ $icon="text";
+ break;
+ case "zip":
+ case "rar":
+ case "gz":
+ case "bz2":
+ case "tar":
+ case "tgz":
+ case "7z":
+ case "iso":
+ $icon="compressed";
+ break;
+ 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";
+}
+
+clearstatcache();
+?>
+<hr></pre>
+
+<address>Apache Server at www.blaupload.co.uk Port 80</address>
+</body></html>