]> jfr.im git - uguu.git/commitdiff
Adding error page
authorJames Dillon <redacted>
Mon, 5 Oct 2015 17:18:37 +0000 (18:18 +0100)
committerJames Dillon <redacted>
Mon, 5 Oct 2015 17:18:37 +0000 (18:18 +0100)
If a user tries to upload without a file selected, the user is
redirected to an error page instead of "You fucked up".

api.php
error.php [new file with mode: 0644]
rain/cache/error.e1ac13855adfa478d8926be2da304459.rtpl.php [new file with mode: 0644]
rain/cache/footer.e1ac13855adfa478d8926be2da304459.rtpl.php [new file with mode: 0644]
rain/cache/header.e1ac13855adfa478d8926be2da304459.rtpl.php [new file with mode: 0644]
rain/cache/upload.e1ac13855adfa478d8926be2da304459.rtpl.php [new file with mode: 0644]
rain/template/error.html [new file with mode: 0644]

diff --git a/api.php b/api.php
index ad5fc5de00def7c5dbe38332cade6a29315a0462..89151bad6a5c406354c059705c1b282768592919 100644 (file)
--- a/api.php
+++ b/api.php
@@ -5,9 +5,11 @@ if(isset($_GET['d'])) {
     include_once('includes/core.php');
     switch ($_GET['d']) {
         case 'upload':
-        //If no file is being posted, exit
+        //If no file is being posted, show the error page and exit.
         if(empty($_FILES['file']['name'])){
-        exit('You fucked up, nothing to do.');}
+               include('error.php');
+               exit(0);
+        }
         //Set the name value to the original filename
        $name = $_FILES['file']['name'];
        $arg = 'custom_original';
diff --git a/error.php b/error.php
new file mode 100644 (file)
index 0000000..fd23956
--- /dev/null
+++ b/error.php
@@ -0,0 +1,18 @@
+<?php
+require_once "rain/rain.tpl.class.php";
+
+raintpl::configure( 'path_replace', false);
+raintpl::configure( 'tpl_dir', 'rain/template/');
+raintpl::configure( 'cache_dir', 'rain/cache/' );
+
+$tpl = new RainTPL;
+
+$title = "Temp File Hosting";
+
+$tpl->assign("title", $title);
+$tpl->draw("header");
+$tpl->draw("error");
+
+
+$tpl->draw("footer");
+?>
\ No newline at end of file
diff --git a/rain/cache/error.e1ac13855adfa478d8926be2da304459.rtpl.php b/rain/cache/error.e1ac13855adfa478d8926be2da304459.rtpl.php
new file mode 100644 (file)
index 0000000..c7beb37
--- /dev/null
@@ -0,0 +1,12 @@
+<?php if(!class_exists('raintpl')){exit;}?><div class="container">
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel blue-grey darken-1">
+                <div class="card-content white-text">
+                    <span class="card-title" style="color: #FF9999"><h3>Error!</h3></span>
+                    <p>Ooops! It seems something has went wrong! Make sure you've selected a file for upload :^)</p>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
\ No newline at end of file
diff --git a/rain/cache/footer.e1ac13855adfa478d8926be2da304459.rtpl.php b/rain/cache/footer.e1ac13855adfa478d8926be2da304459.rtpl.php
new file mode 100644 (file)
index 0000000..8fbe7ec
--- /dev/null
@@ -0,0 +1,20 @@
+<?php if(!class_exists('raintpl')){exit;}?>    <footer class="page-footer blue-grey darken-1" style="position: absolute; bottom: 0; width: 100%">
+        <div class="container">
+            <div class="row">
+                <div class="col l6 s12">
+                    <h5 class="white-text">Pomf</h5>
+                    <p class="grey-text text-lighten-4">If you need to store files for a longer time, please use <a style="color: #bbdefb" href="http://pomf.se">Pomf.se</a> or wait until Uguu offers longer time.</p>
+                </div>
+                <div class="col l4 offset-l2 s12">
+                    <h5 class="white-text">Contact</h5>
+                    <ul>
+                        <li><a class="grey-text text-lighten-3" href="https://twitter.com/nekunekus">@nekunekus</a></li>
+                        <li><a class="grey-text text-lighten-3" href="mailto:neku@pomf.se">neku@pomf.se</a></li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </footer>
+</body>
+
+</html>
\ No newline at end of file
diff --git a/rain/cache/header.e1ac13855adfa478d8926be2da304459.rtpl.php b/rain/cache/header.e1ac13855adfa478d8926be2da304459.rtpl.php
new file mode 100644 (file)
index 0000000..6b22197
--- /dev/null
@@ -0,0 +1,41 @@
+<?php if(!class_exists('raintpl')){exit;}?><!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <meta name="description" content="Temp file hosting, Up to 150MB for 1 hour.">
+    <title>Uguu.se &middot; <?php echo $title;?></title>
+    <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
+    <!-- materialize -->
+    <link type="text/css" rel="stylesheet" href="css/materialize.min.css"  media="screen,projection"/>
+    <link type="text/css" rel="stylesheet" href="css/ie.css"  media="screen,projection"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
+    <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
+    <script type="text/javascript" src="js/materialize.min.js"></script>
+    <script>
+        $( document ).ready(function(){
+            $(".button-collapse").sideNav();
+        })
+    </script>
+</head>
+
+<body>
+    <nav>
+        <div class="nav-wrapper blue-grey darken-1">
+            <div class="container">
+                <div class="col s12">
+                    <a href="/" class="brand-logo">Uguu.se</a>
+                    <a href="#" data-activates="mobile-demo" class="button-collapse"><i class="mdi-navigation-menu"></i></a>
+                    <ul class="right hide-on-med-and-down">
+                        <li><a href="/?info">Info</a></li>
+                        <li><a href="https://github.com/nokonoko/uguu">Github</a></li>
+                    </ul>
+                    <ul class="side-nav" id="mobile-demo">
+                        <li><a href="/?info">Info</a></li>
+                        <li><a href="https://github.com/nokonoko/uguu">Github</a></li>
+                    </ul>
+                </div>
+            </div>
+        </div>
+    </nav>
diff --git a/rain/cache/upload.e1ac13855adfa478d8926be2da304459.rtpl.php b/rain/cache/upload.e1ac13855adfa478d8926be2da304459.rtpl.php
new file mode 100644 (file)
index 0000000..a9ed4d2
--- /dev/null
@@ -0,0 +1,29 @@
+<?php if(!class_exists('raintpl')){exit;}?><div class="container">
+    <form class="col s12" action="api.php?d=upload" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="MAX_FILE_SIZE" value="150000000" />
+            <div class="file-field input-field">
+                <input class="file-path validate" type="text" readonly="readonly"/>
+                    <div class="btn ie-btn-fix">
+                        <span>File</span>
+                        <input id="file" type="file" name="file" />
+                    </div>
+                </div>
+
+                <p>
+                    <input type="checkbox" id="randomname" name="randomname" />
+                    <label for="randomname">Generate random filename</label>
+                </p>
+
+                <div class="row">
+                    <div class="input-field col s12">
+                        <input id="customname" type="text" name="name">
+                        <label for="customname">Custom filename, e.g cat.flac (optional)</label>
+                    </div>
+                </div>
+
+                <button class="btn waves-effect waves-light" type="submit">Upload
+                    <i class="mdi-content-send right"></i>
+                </button>
+            </div>
+    </form>
+</div>
diff --git a/rain/template/error.html b/rain/template/error.html
new file mode 100644 (file)
index 0000000..4593592
--- /dev/null
@@ -0,0 +1,12 @@
+<div class="container">
+    <div class="row">
+        <div class="col s12">
+            <div class="card-panel blue-grey darken-1">
+                <div class="card-content white-text">
+                    <span class="card-title" style="color: #FF9999"><h3>Error!</h3></span>
+                    <p>Ooops! It seems something has went wrong! Make sure you've selected a file for upload :^)</p>
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
\ No newline at end of file