diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9ecb1db --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +includes/config.php +rain/cache/*.php +rain/template/footer.html +public/files diff --git a/LICENSE b/LICENSE index e11fb0b..849e3e0 100644 --- 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/README.md b/README.md index 4cf8a3d..3326607 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,54 @@ # About -[Uguu.se](http://uguu.se) source code, stores files and deletes after X amount of time. +Temp file sharing application source code, stores files and deletes after X amount of time. Forked from Uguu.se available [here](https://github.com/nokonoko/uguu). -# Install -Tested with: -* Nginx+PHP5-FPM (PHP 5.4) on Debian 7 Wheezy +# Tested with: +* Nginx+PHP5-FPM (PHP 5.4) on Debian 7 Wheezy * Apache (PHP 5.4) on Ubuntu 14.04 LTS +* Apache (PHP 5.6) on Debian 8 Jessie * Nginx+PHP5-FPM (PHP 5.6) on Debian 8 Jessie -Modify -* Modify includes/core.php where to save files and other paths. -* Set correct paths in several other files. (Will add fix for this via config file instead). -* Change uguu.se to your own name in several files. -* Cron with check.sh: `crontab -e` -* After running `crontab -e`, add `0,15,30,45 * * * * bash /path/to/check.sh`, or read up on how cron works. -* Some extensions are blocked by default, this can be changed via includes/core.php's $block array. -* Everything else to your likings. +# Install: -Change php.ini and nginx.conf settings to allow bigger uploads. +* Deploy base code, for example with `git clone https://github.com/pierre-alain-b/Uguu.git` +* Modify includes/config.php (copy config.template.php as a starting point) to set up the main options for Uguu. +* Some file extensions are blocked by default, this can be changed via includes/config.php's CONFIG_BLOCKED_EXTENSIONS value. +* Copy `rain/template/footer.template.html` as `rain/template/footer.html` and personalize the footer as you wish +* Execute check.sh regularly with cron to delete old files: `crontab -e` and add `0,15,30,45 * * * * bash /path/to/check.sh` (or adapt if you know how cron works). +* Make the Uguu/public/files and Uguu/rain/cache directory modifiable by the web server user: +`chown -R www-data:www-data /path/to/Uguu/public/files` and `chown -R www-data:www-data /path/to/Uguu/rain/cache` +* Make sure the Uguu/public/files folder is not indexable, you may use a virtual host config similar to this one: -Make the uguu/ directory modifiable to the nginx user: -`setfacl -m u:www-data:rwx /path/to/uguu/directory/` +``` + + ServerName path.to.uguu -# Todo + DocumentRoot /var/www/Uguu/ + + AllowOverride All + Require all granted + -* Restructure files. -* Make global config file. -* Probably a lot of things but I'm a lazy fuck, come with suggestions. + Alias "/files" "/var/www/Uguu/public/files/" + + + SetHandler default-handler + + AllowOverride None + Options -Indexes + Require all granted + + +``` # Using the API * Leaving POST value 'name' empty will cause it to save using the original filename. * Leaving POST value 'randomname' empty will cause it to use original filename or custom name if 'name' is set to file.ext. - + * Putting anything into POST value 'randomname' will cause it to return a random filename + ext (xxxxxx.ext). * Putting a custom name into POST value 'name' will cause it to return a custom filename (yourpick.ext). - + E.g: - * curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload (HTML Response) - * curl -i -F name=test.jpg -F file=@localfile.jpg http://uguu.se/api.php?d=upload-tool (Plain text Response) - - -This will probably get changed later since it's messy and unpractical. - -# Contact - -[neku@pomf.se](mailto:neku@pomf.se) or [@Nekunekus](https://twitter.com/nekunekus). + * curl -i -F name=test.jpg -F file=@localfile.jpg http://path.to.uguu/api.php?d=upload (HTML Response) + * curl -i -F name=test.jpg -F file=@localfile.jpg http://path.to.uguu/api.php?d=upload-tool (Plain text Response) diff --git a/api.php b/api.php index eddad7d..a58709e 100644 --- a/api.php +++ b/api.php @@ -1,14 +1,17 @@ assign("title", $title); $tpl->draw("header"); $tpl->draw("error"); - $tpl->draw("footer"); -?> \ No newline at end of file +?> diff --git a/includes/check.sh b/includes/check.sh index 61e2aa1..9eb25f4 100644 --- a/includes/check.sh +++ b/includes/check.sh @@ -1,2 +1,2 @@ #! /bin/sh -find /home/neku/www/files/ -mmin +1440 -exec rm -f {} \; +find $(grep -oP '"CONFIG_FILES_PATH", "\K(.*)(?=")' config.php) -mtime +$(grep -oP '"CONFIG_MAX_RETENTION_TIME", "\K(.*)(?=")' config.php) -exec rm -f {} \; diff --git a/includes/config.template.php b/includes/config.template.php new file mode 100644 index 0000000..4178ee2 --- /dev/null +++ b/includes/config.template.php @@ -0,0 +1,9 @@ +assign("title", $title); $tpl->draw("header"); if(isset($_GET['info'])) { + $tpl->assign("url_filename", CONFIG_ROOT_URL); + $tpl->assign("retention_time", CONFIG_MAX_RETENTION_TEXT); $tpl->draw("info"); } else { $tpl->draw("upload"); } $tpl->draw("footer"); -?> \ No newline at end of file +?> diff --git a/public/files/.keep b/public/files/.keep new file mode 100644 index 0000000..e69de29 diff --git a/rain/cache/.keep b/rain/cache/.keep new file mode 100644 index 0000000..e69de29 diff --git a/rain/template/footer.html b/rain/template/footer.template.html similarity index 99% rename from rain/template/footer.html rename to rain/template/footer.template.html index d0244a7..04bafdb 100644 --- a/rain/template/footer.html +++ b/rain/template/footer.template.html @@ -17,4 +17,4 @@ - \ No newline at end of file + diff --git a/rain/template/header.html b/rain/template/header.html index 3661aa6..520790d 100644 --- a/rain/template/header.html +++ b/rain/template/header.html @@ -4,8 +4,8 @@ - - Uguu.se · {$title} + + Uguu · {$title} @@ -25,15 +25,13 @@