Multiple changes everywhere

This commit is contained in:
Pierre-Alain Bandinelli 2016-05-14 10:55:50 +02:00
parent 40af9e6304
commit 2f98035ac1
13 changed files with 86 additions and 56 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
includes/config.php includes/config.php
rain/cache/*.php
rain/template/footer.html
public/files

View File

@ -1,5 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015 nokonoko Copyright (c) 2015 nokonoko
Copyright (c) 2016 PA BANDINELLI, HéliApps SAS
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to the Software without restriction, including without limitation the rights to

View File

@ -1,14 +1,17 @@
<?php <?php
//Loading configuration file
require_once "includes/config.php";
//If the value d doesn't exist, redirect back to front page *1 //If the value d doesn't exist, redirect back to front page *1
if(isset($_GET['d'])) { if(isset($_GET['d'])) {
//Include the core file with the functions //Include the core file with the functions
include_once('includes/core.php'); include_once(CONFIG_ROOT_PATH.'includes/core.php');
switch ($_GET['d']) { switch ($_GET['d']) {
//Uploading with HTML response and errors //Uploading with HTML response and errors
case 'upload': case 'upload':
//If no file is being posted, show the error page and exit. //If no file is being posted, show the error page and exit.
if(empty($_FILES['file']['name'])){ if(empty($_FILES['file']['name'])){
include_once('error.php'); include_once(CONFIG_ROOT_PATH.'error.php');
exit(0); exit(0);
} }
//Set the name value to the original filename //Set the name value to the original filename
@ -47,7 +50,7 @@ if(isset($_GET['d'])) {
break; break;
default: default:
//If no correct valid argument for the api to perform on, tell them to enter a valid one //If no correct valid argument for the api to perform on, tell them to enter a valid one
exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload-tool'); exit('Please provide a valid argument. Example: curl -i -F name=test.jpg -F file=@localfile.jpg '.CONFIG_ROOT_URL.'/api.php?d=upload-tool');
break; break;
} }
}else{ }else{

View File

@ -13,6 +13,5 @@ $tpl->assign("title", $title);
$tpl->draw("header"); $tpl->draw("header");
$tpl->draw("error"); $tpl->draw("error");
$tpl->draw("footer"); $tpl->draw("footer");
?> ?>

View File

@ -0,0 +1,6 @@
<?php
#This is the configuration file for Uguu Temp File Sharing system
define('CONFIG_ROOT_URL', "http://path.to.uguu");
define('CONFIG_FILES_PATH', "/path/to/uguu/public/files/");
define('CONFIG_ROOT_PATH', "/path/to/uguu/");
define('CONFIG_RANDOM_LENGTH', "10");

View File

@ -1,24 +1,25 @@
<?php <?php
//Loading configuration file
require_once "config.php";
//Saving the file on the server
function save_file ($file, $name, $arg, $type){ function save_file ($file, $name, $arg, $type){
//Where to save
$path='/home/neku/www/files/';
$block = array('exe', 'scr', 'rar', 'zip', 'com', 'vbs', 'bat', 'cmd', 'html', 'htm', 'msi');
//Generate name depending on arg //Generate name depending on arg
switch($arg){ switch($arg){
case 'random': case 'random':
$ext = pathinfo($file.$name, PATHINFO_EXTENSION); $ext = pathinfo($file.$name, PATHINFO_EXTENSION);
$ext = strtolower($ext); $ext = strtolower($ext);
if(in_array($ext, $block)){ if(in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))){
if($type==='normal'){ if($type==='normal'){
include_once('error_meow.php'); include_once(CONFIG_ROOT_PATH.'error_meow.php');
exit(0); exit(0);
}else{ }else{
exit('File type not allowed.'); exit('File type not allowed.');
} }
} }
$file_name = gen_name('random', $ext); $file_name = gen_name('random', $ext);
while(file_exists($path.$file_name)){ while(file_exists(CONFIG_FILES_PATH.$file_name)){
$file_name = gen_name('random', $ext); $file_name = gen_name('random', $ext);
} }
break; break;
case 'custom_original': case 'custom_original':
@ -27,38 +28,40 @@ function save_file ($file, $name, $arg, $type){
$file_name = gen_name('custom_original', $name); $file_name = gen_name('custom_original', $name);
$ext = pathinfo($file_name, PATHINFO_EXTENSION); $ext = pathinfo($file_name, PATHINFO_EXTENSION);
$ext = strtolower($ext); $ext = strtolower($ext);
if(in_array($ext, $block)){ if(in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))){
if($type==='normal'){ if($type==='normal'){
include_once('error_meow.php'); include_once(CONFIG_ROOT_PATH.'error_meow.php');
exit(0); exit(0);
}else{ }else{
exit('File type not allowed.'); exit('File type not allowed.');
}
} }
} while(file_exists(CONFIG_FILES_PATH.$file_name)){
while(file_exists($path.$file_name)){
$file_name = gen_name('custom_original', $name); $file_name = gen_name('custom_original', $name);
} }
break; break;
} }
//Move the file to the above location with said filename //Move the file to the above location with said filename
move_uploaded_file($file,$path.$file_name); move_uploaded_file($file,CONFIG_FILES_PATH.$file_name);
//Check if html or plain text should be returned //Check if html or plain text should be returned
if($type==='tool'){ if($type==='tool'){
//Return url+filename to the user (plain text) //Return url+filename to the user (plain text)
echo 'http://a.uguu.se/'.urlencode($file_name); echo CONFIG_ROOT_URL.'/files/'.urlencode($file_name);
exit(0); exit(0);
}elseif($type==='normal'){ }elseif($type==='normal'){
//Return url+filename to the user (HTML) //Return url+filename to the user (HTML)
$n=urlencode($file_name); $n=urlencode($file_name);
include_once('/home/neku/www/page/public/upload-done.php'); include_once(CONFIG_ROOT_PATH.'upload-done.php');
exit(0); exit(0);
} }
} }
#Generate a random name for the uploaded file
function gen_name($arg, $in){ function gen_name($arg, $in){
$chars = 'abcdefghijklmnopqrstuvwxyz'; $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$name = ''; $name = '';
for ($i = 0; $i < 6; $i++) { for ($i = 0; $i < CONFIG_RANDOM_LENGTH; $i++) {
$name .= $chars[mt_rand(0, 25)]; $name .= $chars[mt_rand(0, 60)];
} }
switch($arg){ switch($arg){
case 'random': case 'random':

View File

@ -1,4 +1,7 @@
<?php <?php
//Loading configuration file
require_once "includes/config.php";
require_once "rain/rain.tpl.class.php"; require_once "rain/rain.tpl.class.php";
raintpl::configure( 'path_replace', false); raintpl::configure( 'path_replace', false);
@ -15,10 +18,11 @@ $tpl->assign("title", $title);
$tpl->draw("header"); $tpl->draw("header");
if(isset($_GET['info'])) { if(isset($_GET['info'])) {
$tpl->assign("url_filename", CONFIG_ROOT_URL);
$tpl->draw("info"); $tpl->draw("info");
} else { } else {
$tpl->draw("upload"); $tpl->draw("upload");
} }
$tpl->draw("footer"); $tpl->draw("footer");
?> ?>

View File

@ -2,19 +2,14 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col l6 s12"> <div class="col l6 s12">
<h5 class="white-text">Pomf</h5> <h5 class="white-text">Limitations</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> <p class="grey-text text-lighten-4">If you need to store files for a longer time, you can deploy your own version of Uguu, the sources are available on Github.</p>
</div> </div>
<div class="col l4 offset-l2 s12"> <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> </div>
</div> </div>
</footer> </footer>
</body> </body>
</html> </html>

View File

@ -0,0 +1,20 @@
<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

@ -4,8 +4,8 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Temp file hosting, Up to 150MB for 1 hour."> <meta name="description" content="Temp file hosting, up to 150MB.">
<title>Uguu.se &middot; {$title}</title> <title>Uguu &middot; {$title}</title>
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon">
<!-- materialize --> <!-- materialize -->
<link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/> <link type="text/css" rel="stylesheet" href="css/materialize.min.css" media="screen,projection"/>
@ -25,15 +25,13 @@
<div class="nav-wrapper blue-grey darken-1"> <div class="nav-wrapper blue-grey darken-1">
<div class="container"> <div class="container">
<div class="col s12"> <div class="col s12">
<a href="/" class="brand-logo">Uguu.se</a> <a href="/" class="brand-logo">Uguu</a>
<a href="#" data-activates="mobile-demo" class="button-collapse"><i class="mdi-navigation-menu"></i></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"> <ul class="right hide-on-med-and-down">
<li><a href="/?info">Info</a></li> <li><a href="/?info">Info</a></li>
<li><a href="https://github.com/nokonoko/uguu">Github</a></li>
</ul> </ul>
<ul class="side-nav" id="mobile-demo"> <ul class="side-nav" id="mobile-demo">
<li><a href="/?info">Info</a></li> <li><a href="/?info">Info</a></li>
<li><a href="https://github.com/nokonoko/uguu">Github</a></li>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -3,16 +3,14 @@
<div class="col s12"> <div class="col s12">
<div class="card-panel blue-grey darken-1"> <div class="card-panel blue-grey darken-1">
<div class="card-content white-text"> <div class="card-content white-text">
<span class="card-title">Info</span> <span class="card-title"><b>Info</b></span>
<p>Store any filetype with a size up to 150MB for up to 1 hour. <p>Store any filetype with a size up to 150MB for up to 1 hour.
Uguu cares about your privacy and stores NO logs. Uguu cares about your privacy and stores NO logs.
</p> </p>
<p> <p>
If you would like to upload using ShareX read <a style="color: #bbdefb" href="https://github.com/ShareX/ShareX/wiki/Custom-Uploader-examples#uguuse">this</a>.<br />
To upload using curl or make a tool you can post using:<br /> To upload using curl or make a tool you can post using:<br />
<code>curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload</code> (HTML Response)<br /> <code>curl -i -F name=test.jpg -F file=@localfile.jpg {$url_filename}/api.php?d=upload</code> (HTML Response)<br />
<code>curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload-tool</code> (Plain text Response)</p> <code>curl -i -F name=test.jpg -F file=@localfile.jpg {$url_filename}/api.php?d=upload-tool</code> (Plain text Response)</p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,8 +3,8 @@
<div class="col s12"> <div class="col s12">
<div class="card-panel blue-grey darken-1"> <div class="card-panel blue-grey darken-1">
<div class="card-content white-text"> <div class="card-content white-text">
<span class="card-title" style="color: #FF9999"><h3>File uploaded!</h3></span> <span class="card-title" style="color: #00FF99"><h3>File uploaded!</h3></span>
<p><a href="http://a.uguu.se/{$filename}">http://a.uguu.se/{$filename}</a></p> <p><a href="{$url_filename}">{$url_filename}</a></p>
<p>Your file will be available for download during 24 hours.</p> <p>Your file will be available for download during 24 hours.</p>
</div> </div>
</div> </div>

View File

@ -1,13 +1,13 @@
<?php <?php
require_once "/home/neku/www/page/public/rain/rain.tpl.class.php"; require_once "rain/rain.tpl.class.php";
raintpl::configure( 'path_replace', false); raintpl::configure( 'path_replace', false);
raintpl::configure( 'tpl_dir', '/home/neku/www/page/public/rain/template/'); raintpl::configure( 'tpl_dir', 'rain/template/');
raintpl::configure( 'cache_dir', '/home/neku/www/page/public/rain/cache/' ); raintpl::configure( 'cache_dir', 'rain/cache/' );
$tpl = new RainTPL; $tpl = new RainTPL;
$title = "Temp File Hosting"; $title = "Temp File Hosting";
$tpl->assign("title", $title); $tpl->assign("title", $title);
$tpl->draw("header"); $tpl->draw("header");
$tpl->assign("filename", $n); $tpl->assign("url_filename", CONFIG_ROOT_URL.'/files/'.$n);
$tpl->draw("upload-done"); $tpl->draw("upload-done");
$tpl->draw("footer"); $tpl->draw("footer");
?> ?>