]> jfr.im git - uguu.git/commitdiff
Multiple changes everywhere
authorPierre-Alain Bandinelli <redacted>
Sat, 14 May 2016 08:55:50 +0000 (10:55 +0200)
committerPierre-Alain Bandinelli <redacted>
Sat, 14 May 2016 08:55:50 +0000 (10:55 +0200)
13 files changed:
.gitignore
LICENSE
api.php
error.php
includes/config.template.php [new file with mode: 0644]
includes/core.php
index.php
rain/template/footer.html
rain/template/footer.template.html [new file with mode: 0644]
rain/template/header.html
rain/template/info.html
rain/template/upload-done.html
upload-done.php

index 355c251262fe64dddba5a61c5fa75e0a68c689d7..9ecb1db58a66fec032f7a587603accb3aab387f3 100644 (file)
@@ -1 +1,4 @@
 includes/config.php
+rain/cache/*.php
+rain/template/footer.html
+public/files
diff --git a/LICENSE b/LICENSE
index e11fb0bb435c085227baeb97e2a78296c3b09a54..849e3e0453b44fae8b8c907c24d924a67a32bda7 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,5 +1,6 @@
 The MIT License (MIT)
 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
 this software and associated documentation files (the "Software"), to deal in
 the Software without restriction, including without limitation the rights to
diff --git a/api.php b/api.php
index eddad7d0704d6b1140514af31b79034099876bb0..a58709ec2459095fd23e369ee3810dadf3eb9189 100644 (file)
--- a/api.php
+++ b/api.php
@@ -1,14 +1,17 @@
 <?php
+//Loading configuration file
+require_once "includes/config.php";
+
 //If the value d doesn't exist, redirect back to front page *1
 if(isset($_GET['d'])) {
     //Include the core file with the functions
-    include_once('includes/core.php');
+    include_once(CONFIG_ROOT_PATH.'includes/core.php');
     switch ($_GET['d']) {
        //Uploading with HTML response and errors
         case 'upload':
         //If no file is being posted, show the error page and exit.
         if(empty($_FILES['file']['name'])){
-               include_once('error.php');
+               include_once(CONFIG_ROOT_PATH.'error.php');
                exit(0);
         }
         //Set the name value to the original filename
@@ -47,7 +50,7 @@ if(isset($_GET['d'])) {
             break;
        default:
        //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;
     }
 }else{
index fd23956c7fd764206813dd40d4f796947e656af2..1c46c83eacd731708f957aa715671c60b931daff 100644 (file)
--- a/error.php
+++ b/error.php
@@ -13,6 +13,5 @@ $tpl->assign("title", $title);
 $tpl->draw("header");
 $tpl->draw("error");
 
-
 $tpl->draw("footer");
-?>
\ No newline at end of file
+?>
diff --git a/includes/config.template.php b/includes/config.template.php
new file mode 100644 (file)
index 0000000..5d47d2e
--- /dev/null
@@ -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");
index 3d74e8c8f15be4751b616c626b4466f7f0421e85..04303eb0bde537f5f0d1652c1bd06a4756a92b65 100644 (file)
@@ -1,24 +1,25 @@
 <?php
+//Loading configuration file
+require_once "config.php";
+
+//Saving the file on the server
 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
     switch($arg){
         case 'random':
             $ext = pathinfo($file.$name, PATHINFO_EXTENSION);
             $ext = strtolower($ext);
-            if(in_array($ext, $block)){
-                if($type==='normal'){
-                include_once('error_meow.php');
+            if(in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))){
+              if($type==='normal'){
+                include_once(CONFIG_ROOT_PATH.'error_meow.php');
                 exit(0);
-                }else{
-                    exit('File type not allowed.');
-                }
-                }
+              }else{
+                exit('File type not allowed.');
+              }
+            }
             $file_name = gen_name('random', $ext);
-            while(file_exists($path.$file_name)){
-                $file_name = gen_name('random', $ext);
+            while(file_exists(CONFIG_FILES_PATH.$file_name)){
+              $file_name = gen_name('random', $ext);
             }
             break;
         case 'custom_original':
@@ -27,38 +28,40 @@ function save_file ($file, $name, $arg, $type){
                 $file_name = gen_name('custom_original', $name);
                 $ext = pathinfo($file_name, PATHINFO_EXTENSION);
                 $ext = strtolower($ext);
-                if(in_array($ext, $block)){
-                if($type==='normal'){
-                include_once('error_meow.php');
-                exit(0);
-                }else{
-                    exit('File type not allowed.');
-                }
+                if(in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))){
+                 if($type==='normal'){
+                   include_once(CONFIG_ROOT_PATH.'error_meow.php');
+                   exit(0);
+                 }else{
+                   exit('File type not allowed.');
+                 }
                 }
-            while(file_exists($path.$file_name)){
+            while(file_exists(CONFIG_FILES_PATH.$file_name)){
                 $file_name = gen_name('custom_original', $name);
             }
             break;
     }
     //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
     if($type==='tool'){
     //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);
     }elseif($type==='normal'){
     //Return url+filename to the user (HTML)
     $n=urlencode($file_name);
-    include_once('/home/neku/www/page/public/upload-done.php');
+    include_once(CONFIG_ROOT_PATH.'upload-done.php');
     exit(0);
     }
 }
+
+#Generate a random name for the uploaded file
 function gen_name($arg, $in){
-    $chars = 'abcdefghijklmnopqrstuvwxyz';
+    $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
     $name = '';
-    for ($i = 0; $i < 6; $i++) {
-    $name .= $chars[mt_rand(0, 25)];
+    for ($i = 0; $i < CONFIG_RANDOM_LENGTH; $i++) {
+    $name .= $chars[mt_rand(0, 60)];
         }
     switch($arg){
         case 'random':
index 6f8552eda18534fbcdf72bda54f5798281e8fc4d..b7eeb7c66c32d2ad53ef0b01a23148568ff5e9fe 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,4 +1,7 @@
 <?php
+//Loading configuration file
+require_once "includes/config.php";
+
 require_once "rain/rain.tpl.class.php";
 
 raintpl::configure( 'path_replace', false);
@@ -15,10 +18,11 @@ $tpl->assign("title", $title);
 $tpl->draw("header");
 
 if(isset($_GET['info'])) {
+    $tpl->assign("url_filename", CONFIG_ROOT_URL);
     $tpl->draw("info");
 } else {
     $tpl->draw("upload");
 }
 
 $tpl->draw("footer");
-?>
\ No newline at end of file
+?>
index d0244a7ad01edca0445e2d1d54febf66d5a4c5be..99d4003104fcc15f7f826807c19c82da66c4f297 100644 (file)
@@ -2,19 +2,14 @@
         <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>
+                    <h5 class="white-text">Limitations</h5>
+                    <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 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
+</html>
diff --git a/rain/template/footer.template.html b/rain/template/footer.template.html
new file mode 100644 (file)
index 0000000..04bafdb
--- /dev/null
@@ -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>
index 3661aa6eb1aeb09ff364155e35dcf4103b41724e..520790d8b0bddafbd8d454bbc229b60fc097215c 100644 (file)
@@ -4,8 +4,8 @@
 <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; {$title}</title>
+    <meta name="description" content="Temp file hosting, up to 150MB.">
+    <title>Uguu &middot; {$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"/>
         <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="/" class="brand-logo">Uguu</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>
index ef956839cfb610aa586ceb6adcf133f9648c5bd1..6f1666e5ab651bd319da5e545608045d86528583 100644 (file)
@@ -3,16 +3,14 @@
         <div class="col s12">
             <div class="card-panel blue-grey darken-1">
                 <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.
                     Uguu cares about your privacy and stores NO logs.
                     </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 />
-                        <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 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</code> (HTML Response)<br />
+                        <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>
index c64aa352645f80b845c70cd74b87233f0701adde..ff4a8cd1a61c7cc245f10065584011b9c581f15e 100644 (file)
@@ -3,8 +3,8 @@
         <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>File uploaded!</h3></span>
-                        <p><a href="http://a.uguu.se/{$filename}">http://a.uguu.se/{$filename}</a></p>
+                    <span class="card-title" style="color: #00FF99"><h3>File uploaded!</h3></span>
+                        <p><a href="{$url_filename}">{$url_filename}</a></p>
                         <p>Your file will be available for download during 24 hours.</p>
                 </div>
             </div>
index f48802e1456425418c288a7577467d5fa9b01247..3447c62b5de4d055253da726eea172f04f7473cc 100644 (file)
@@ -1,13 +1,13 @@
 <?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( 'tpl_dir', '/home/neku/www/page/public/rain/template/');
-raintpl::configure( 'cache_dir', '/home/neku/www/page/public/rain/cache/' );
+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->assign("filename", $n);
+$tpl->assign("url_filename", CONFIG_ROOT_URL.'/files/'.$n);
 $tpl->draw("upload-done");
 $tpl->draw("footer");
 ?>