Adding error page

If a user tries to upload without a file selected, the user is
redirected to an error page instead of "You fucked up".
This commit is contained in:
James Dillon 2015-10-05 18:18:37 +01:00
parent da36710e1c
commit 0591f08bbf
7 changed files with 136 additions and 2 deletions

View File

@ -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';

18
error.php Normal file
View File

@ -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");
?>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

12
rain/template/error.html Normal file
View File

@ -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>