Compare commits

..

14 Commits

Author SHA1 Message Date
nokonoko 5d44b61c16 things 2021-06-23 14:31:48 +02:00
nokonoko 85d74c0d22 reload 2021-06-22 21:30:58 +02:00
nokonoko e3b2d66ef3 clean slate 2021-06-22 18:18:18 +02:00
nokonoko 8ea87bf207 Merge branch 'testing' of https://github.com/nokonoko/Uguu into testing 2021-06-22 18:15:45 +02:00
nokonoko cf1d2267e3 a 2021-06-22 18:15:36 +02:00
Eric Johansson (neku) 7002081c5c
Update X.Y.conf 2021-06-22 15:45:49 +02:00
nokonoko 8c2ebd4b8e Update dist.json 2021-06-22 15:25:47 +02:00
nokonoko 8a32b18eae Update .gitignore 2021-06-22 15:21:54 +02:00
nokonoko c685ab1fc3 Update .gitignore 2021-06-22 15:18:42 +02:00
nokonoko 30bd416912 revert 2021-06-22 14:29:33 +02:00
nokonoko 48233fb137 saner code 2021-06-22 13:25:57 +02:00
nokonoko 74d3554fa6 slim down 2021-06-22 12:55:44 +02:00
nokonoko 1d15881dee anti-dupe option 2021-06-22 11:39:26 +02:00
nokonoko b873b00865 start of admin panel 2021-06-21 23:44:27 +02:00
47 changed files with 659 additions and 233 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

7
.gitignore vendored
View File

@ -1,2 +1,7 @@
DS_Store
dist
node_modules
build
package.json
package-lock.json
.DS_Store
**/.DS_Store

319
COPYING.CC-BY-3.0 Normal file
View File

@ -0,0 +1,319 @@
Creative Commons Legal Code
Attribution 3.0 Unported
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
DAMAGES RESULTING FROM ITS USE.
License
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
CONDITIONS.
1. Definitions
a. "Adaptation" means a work based upon the Work, or upon the Work and
other pre-existing works, such as a translation, adaptation,
derivative work, arrangement of music or other alterations of a
literary or artistic work, or phonogram or performance and includes
cinematographic adaptations or any other form in which the Work may be
recast, transformed, or adapted including in any form recognizably
derived from the original, except that a work that constitutes a
Collection will not be considered an Adaptation for the purpose of
this License. For the avoidance of doubt, where the Work is a musical
work, performance or phonogram, the synchronization of the Work in
timed-relation with a moving image ("synching") will be considered an
Adaptation for the purpose of this License.
b. "Collection" means a collection of literary or artistic works, such as
encyclopedias and anthologies, or performances, phonograms or
broadcasts, or other works or subject matter other than works listed
in Section 1(f) below, which, by reason of the selection and
arrangement of their contents, constitute intellectual creations, in
which the Work is included in its entirety in unmodified form along
with one or more other contributions, each constituting separate and
independent works in themselves, which together are assembled into a
collective whole. A work that constitutes a Collection will not be
considered an Adaptation (as defined above) for the purposes of this
License.
c. "Distribute" means to make available to the public the original and
copies of the Work or Adaptation, as appropriate, through sale or
other transfer of ownership.
d. "Licensor" means the individual, individuals, entity or entities that
offer(s) the Work under the terms of this License.
e. "Original Author" means, in the case of a literary or artistic work,
the individual, individuals, entity or entities who created the Work
or if no individual or entity can be identified, the publisher; and in
addition (i) in the case of a performance the actors, singers,
musicians, dancers, and other persons who act, sing, deliver, declaim,
play in, interpret or otherwise perform literary or artistic works or
expressions of folklore; (ii) in the case of a phonogram the producer
being the person or legal entity who first fixes the sounds of a
performance or other sounds; and, (iii) in the case of broadcasts, the
organization that transmits the broadcast.
f. "Work" means the literary and/or artistic work offered under the terms
of this License including without limitation any production in the
literary, scientific and artistic domain, whatever may be the mode or
form of its expression including digital form, such as a book,
pamphlet and other writing; a lecture, address, sermon or other work
of the same nature; a dramatic or dramatico-musical work; a
choreographic work or entertainment in dumb show; a musical
composition with or without words; a cinematographic work to which are
assimilated works expressed by a process analogous to cinematography;
a work of drawing, painting, architecture, sculpture, engraving or
lithography; a photographic work to which are assimilated works
expressed by a process analogous to photography; a work of applied
art; an illustration, map, plan, sketch or three-dimensional work
relative to geography, topography, architecture or science; a
performance; a broadcast; a phonogram; a compilation of data to the
extent it is protected as a copyrightable work; or a work performed by
a variety or circus performer to the extent it is not otherwise
considered a literary or artistic work.
g. "You" means an individual or entity exercising rights under this
License who has not previously violated the terms of this License with
respect to the Work, or who has received express permission from the
Licensor to exercise rights under this License despite a previous
violation.
h. "Publicly Perform" means to perform public recitations of the Work and
to communicate to the public those public recitations, by any means or
process, including by wire or wireless means or public digital
performances; to make available to the public Works in such a way that
members of the public may access these Works from a place and at a
place individually chosen by them; to perform the Work to the public
by any means or process and the communication to the public of the
performances of the Work, including by public digital performance; to
broadcast and rebroadcast the Work by any means including signs,
sounds or images.
i. "Reproduce" means to make copies of the Work by any means including
without limitation by sound or visual recordings and the right of
fixation and reproducing fixations of the Work, including storage of a
protected performance or phonogram in digital form or other electronic
medium.
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
limit, or restrict any uses free from copyright or rights arising from
limitations or exceptions that are provided for in connection with the
copyright protection under copyright law or other applicable laws.
3. License Grant. Subject to the terms and conditions of this License,
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
perpetual (for the duration of the applicable copyright) license to
exercise the rights in the Work as stated below:
a. to Reproduce the Work, to incorporate the Work into one or more
Collections, and to Reproduce the Work as incorporated in the
Collections;
b. to create and Reproduce Adaptations provided that any such Adaptation,
including any translation in any medium, takes reasonable steps to
clearly label, demarcate or otherwise identify that changes were made
to the original Work. For example, a translation could be marked "The
original work was translated from English to Spanish," or a
modification could indicate "The original work has been modified.";
c. to Distribute and Publicly Perform the Work including as incorporated
in Collections; and,
d. to Distribute and Publicly Perform Adaptations.
e. For the avoidance of doubt:
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme cannot be waived, the Licensor
reserves the exclusive right to collect such royalties for any
exercise by You of the rights granted under this License;
ii. Waivable Compulsory License Schemes. In those jurisdictions in
which the right to collect royalties through any statutory or
compulsory licensing scheme can be waived, the Licensor waives the
exclusive right to collect such royalties for any exercise by You
of the rights granted under this License; and,
iii. Voluntary License Schemes. The Licensor waives the right to
collect royalties, whether individually or, in the event that the
Licensor is a member of a collecting society that administers
voluntary licensing schemes, via that society, from any exercise
by You of the rights granted under this License.
The above rights may be exercised in all media and formats whether now
known or hereafter devised. The above rights include the right to make
such modifications as are technically necessary to exercise the rights in
other media and formats. Subject to Section 8(f), all rights not expressly
granted by Licensor are hereby reserved.
4. Restrictions. The license granted in Section 3 above is expressly made
subject to and limited by the following restrictions:
a. You may Distribute or Publicly Perform the Work only under the terms
of this License. You must include a copy of, or the Uniform Resource
Identifier (URI) for, this License with every copy of the Work You
Distribute or Publicly Perform. You may not offer or impose any terms
on the Work that restrict the terms of this License or the ability of
the recipient of the Work to exercise the rights granted to that
recipient under the terms of the License. You may not sublicense the
Work. You must keep intact all notices that refer to this License and
to the disclaimer of warranties with every copy of the Work You
Distribute or Publicly Perform. When You Distribute or Publicly
Perform the Work, You may not impose any effective technological
measures on the Work that restrict the ability of a recipient of the
Work from You to exercise the rights granted to that recipient under
the terms of the License. This Section 4(a) applies to the Work as
incorporated in a Collection, but this does not require the Collection
apart from the Work itself to be made subject to the terms of this
License. If You create a Collection, upon notice from any Licensor You
must, to the extent practicable, remove from the Collection any credit
as required by Section 4(b), as requested. If You create an
Adaptation, upon notice from any Licensor You must, to the extent
practicable, remove from the Adaptation any credit as required by
Section 4(b), as requested.
b. If You Distribute, or Publicly Perform the Work or any Adaptations or
Collections, You must, unless a request has been made pursuant to
Section 4(a), keep intact all copyright notices for the Work and
provide, reasonable to the medium or means You are utilizing: (i) the
name of the Original Author (or pseudonym, if applicable) if supplied,
and/or if the Original Author and/or Licensor designate another party
or parties (e.g., a sponsor institute, publishing entity, journal) for
attribution ("Attribution Parties") in Licensor's copyright notice,
terms of service or by other reasonable means, the name of such party
or parties; (ii) the title of the Work if supplied; (iii) to the
extent reasonably practicable, the URI, if any, that Licensor
specifies to be associated with the Work, unless such URI does not
refer to the copyright notice or licensing information for the Work;
and (iv) , consistent with Section 3(b), in the case of an Adaptation,
a credit identifying the use of the Work in the Adaptation (e.g.,
"French translation of the Work by Original Author," or "Screenplay
based on original Work by Original Author"). The credit required by
this Section 4 (b) may be implemented in any reasonable manner;
provided, however, that in the case of a Adaptation or Collection, at
a minimum such credit will appear, if a credit for all contributing
authors of the Adaptation or Collection appears, then as part of these
credits and in a manner at least as prominent as the credits for the
other contributing authors. For the avoidance of doubt, You may only
use the credit required by this Section for the purpose of attribution
in the manner set out above and, by exercising Your rights under this
License, You may not implicitly or explicitly assert or imply any
connection with, sponsorship or endorsement by the Original Author,
Licensor and/or Attribution Parties, as appropriate, of You or Your
use of the Work, without the separate, express prior written
permission of the Original Author, Licensor and/or Attribution
Parties.
c. Except as otherwise agreed in writing by the Licensor or as may be
otherwise permitted by applicable law, if You Reproduce, Distribute or
Publicly Perform the Work either by itself or as part of any
Adaptations or Collections, You must not distort, mutilate, modify or
take other derogatory action in relation to the Work which would be
prejudicial to the Original Author's honor or reputation. Licensor
agrees that in those jurisdictions (e.g. Japan), in which any exercise
of the right granted in Section 3(b) of this License (the right to
make Adaptations) would be deemed to be a distortion, mutilation,
modification or other derogatory action prejudicial to the Original
Author's honor and reputation, the Licensor will waive or not assert,
as appropriate, this Section, to the fullest extent permitted by the
applicable national law, to enable You to reasonably exercise Your
right under Section 3(b) of this License (right to make Adaptations)
but not otherwise.
5. Representations, Warranties and Disclaimer
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
7. Termination
a. This License and the rights granted hereunder will terminate
automatically upon any breach by You of the terms of this License.
Individuals or entities who have received Adaptations or Collections
from You under this License, however, will not have their licenses
terminated provided such individuals or entities remain in full
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
survive any termination of this License.
b. Subject to the above terms and conditions, the license granted here is
perpetual (for the duration of the applicable copyright in the Work).
Notwithstanding the above, Licensor reserves the right to release the
Work under different license terms or to stop distributing the Work at
any time; provided, however that any such election will not serve to
withdraw this License (or any other license that has been, or is
required to be, granted under the terms of this License), and this
License will continue in full force and effect unless terminated as
stated above.
8. Miscellaneous
a. Each time You Distribute or Publicly Perform the Work or a Collection,
the Licensor offers to the recipient a license to the Work on the same
terms and conditions as the license granted to You under this License.
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
offers to the recipient a license to the original Work on the same
terms and conditions as the license granted to You under this License.
c. If any provision of this License is invalid or unenforceable under
applicable law, it shall not affect the validity or enforceability of
the remainder of the terms of this License, and without further action
by the parties to this agreement, such provision shall be reformed to
the minimum extent necessary to make such provision valid and
enforceable.
d. No term or provision of this License shall be deemed waived and no
breach consented to unless such waiver or consent shall be in writing
and signed by the party to be charged with such waiver or consent.
e. This License constitutes the entire agreement between the parties with
respect to the Work licensed here. There are no understandings,
agreements or representations with respect to the Work not specified
here. Licensor shall not be bound by any additional provisions that
may appear in any communication from You. This License may not be
modified without the mutual written agreement of the Licensor and You.
f. The rights granted under, and the subject matter referenced, in this
License were drafted utilizing the terminology of the Berne Convention
for the Protection of Literary and Artistic Works (as amended on
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
and the Universal Copyright Convention (as revised on July 24, 1971).
These rights and subject matter take effect in the relevant
jurisdiction in which the License terms are sought to be enforced
according to the corresponding provisions of the implementation of
those treaty provisions in the applicable national law. If the
standard suite of rights granted under applicable copyright law
includes additional rights not granted under this License, such
additional rights are deemed to be included in the License; this
License is not intended to restrict the license of any rights under
applicable law.
Creative Commons Notice
Creative Commons is not a party to this License, and makes no warranty
whatsoever in connection with the Work. Creative Commons will not be
liable to You or any party on any legal theory for any damages
whatsoever, including without limitation any general, special,
incidental or consequential damages arising in connection to this
license. Notwithstanding the foregoing two (2) sentences, if Creative
Commons has expressly identified itself as the Licensor hereunder, it
shall have all rights and obligations of Licensor.
Except for the limited purpose of indicating to the public that the
Work is licensed under the CCPL, Creative Commons does not authorize
the use by either party of the trademark "Creative Commons" or any
related trademark or logo of Creative Commons without the prior
written consent of Creative Commons. Any permitted use will be in
compliance with Creative Commons' then-current trademark usage
guidelines, as may be published on its website or otherwise made
available upon request from time to time. For the avoidance of doubt,
this trademark restriction does not form part of this License.
Creative Commons may be contacted at https://creativecommons.org/.<Paste>

View File

@ -32,16 +32,17 @@ ifneq (,$(findstring moe,$(MODULES)))
endif
min-css:
$(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
$(NODE) $(CURDIR)/node_modules/.bin/cleancss --skip-rebase --O1 specialComments:0 $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
min-js:
echo "// @source https://github.com/nokonoko/uguu/tree/master/static/js" > $(CURDIR)/build/uguu.min.js
echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/uguu.min.js
$(NODE) $(CURDIR)/node_modules/.bin/uglifyjs ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
$(NODE) $(CURDIR)/node_modules/.bin/uglifyjs --screw-ie8 ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
echo "// @license-end" >> $(CURDIR)/build/uguu.min.js
copy-img:
cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/
cp -v $(CURDIR)/static/img/favicon.ico $(CURDIR)/build/favicon.ico
copy-php:
ifneq ($(wildcard $(CURDIR)/static/php/.),)

138
README.md
View File

@ -1,19 +1,12 @@
# Uguu
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=nokonoko_Uguu&metric=alert_status)](https://sonarcloud.io/dashboard?id=nokonoko_Uguu)
[![MIT
licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nokonoko/uguu/master/LICENSE)
[![Documentation Status](https://docs.uguu.se/img/flat.svg)](https://docs.uguu.se)
# What is Uguu?
Uguu is a simple lightweight temporary file hosting and sharing platform, but can also be used as a permanent file host.
Uguu is a simple lightweight file uploading and sharing platform, with the option for files to expire.
## Features
- One click uploading, no registration required
- A minimal, modern web interface
- Drag & Drop & Paste supported
- Drag & drop supported
- Upload API with multiple response choices
- JSON
- HTML
@ -23,20 +16,132 @@ Uguu is a simple lightweight temporary file hosting and sharing platform, but ca
### Demo
See the real world site at [uguu.se](https://uguu.se).
See the real world example at [uguu.se](https://uguu.se).
## Requirements
Original development environment is Nginx + PHP5.3 + SQLite, but is confirmed to
work with Apache 2.4 and newer PHP versions like PHP7.3 and PHP8.0
work with Apache 2.4 and newer PHP versions like PHP7.3.
Node is used to compile Uguu.
## Installation
## Install
Installation and configuration can be found at [Uguu Documentation](https://docs.uguu.se).
**Detailed installation and configuration can be found at [Uguu Documentation](https://blog.yeet.nu/blog/uguu-docs).**
If you need a admin panel check out [Moe Panel](https://github.com/pomf/MoePanel).
If you don't need a detailed one just follow the instructions below.
### Compiling
First you must get a copy of the uguu code. To do so, clone this git repo.
```bash
git clone https://github.com/nokonoko/uguu
```
**Run the following commands to do so, please configure `dist.json` before you compile.**
```bash
cd uguu/
make
make install
```
OR
```bash
make install DESTDIR=/desired/path/for/site
```
After this, the uguu site is now compressed and set up inside `dist/`, or, if specified, `DESTDIR`.
## Configuring
Front-end related settings, such as the name of the site, and maximum allowable
file size, are found in `dist.json`. Changes made here will
only take effect after rebuilding the site pages. This may be done by running
`make` from the root of the site directory.
**Back-end related settings, such as database configuration, and path for uploaded files, are found in `includes/settings.inc.php`. Changes made here take effect immediately. Change the following settings:**
```php
define('UGUU_DB_CONN', 'sqlite:/path/to/db/uguu.sq3');
define('UGUU_FILES_ROOT', '/path/to/file/');
define('UGUU_URL', 'https://subdomainforyourfiles.your.site');
```
**If you intend to allow uploading files larger than 2 MB, you may also need to
increase POST size limits in `php.ini` and webserver configuration. For PHP,
modify `upload_max_filesize` and `post_max_size` values. The configuration
option for nginx webserver is `client_max_body_size`.**
**Edit checkdb.sh and checkfiles.sh to the proper paths:**
```bash
sqlite3 /path/to/db/uguu.sq3 "DELETE FROM files WHERE date <= strftime('%s', datetime('now', '-1 day'));"
```
```bash
find /path/to/files/ -mmin +1440 -exec rm -f {} \;
```
**Then add them to your crontab:**
```bash
0,30 * * * * bash /path/to/checkfiles.sh
0,30 * * * * bash /path/to/checkdb.sh
```
These scripts check if DB entries and files are older then 24 hours and if they are deletes them.
## MIME/EXT Blocking
**Blocking certain filetypes from being uploaded can be changed by editing the following settings in `includes/settings.inc.php`:**
```php
define('CONFIG_BLOCKED_EXTENSIONS', serialize(['exe', 'scr', 'com', 'vbs', 'bat', 'cmd', 'htm', 'html', 'jar', 'msi', 'apk', 'phtml', 'svg']));
define('CONFIG_BLOCKED_MIME', serialize(['application/msword', 'text/html', 'application/x-dosexec', 'application/java', 'application/java-archive', 'application/x-executable', 'application/x-mach-binary', 'image/svg+xml']));
```
By default the most common malicious filetypes are blocked.
## IP logging
This is turned off by default, but you can enable it by changing:
```php
define('LOG_IP', 'false');
```
## Anti dupe
This is turned off by default, if a user uploads a file already uploaded the link to the already existing file will be returned instead.
```php
define('ANTI_DUPE', 'false');
```
## Using SQLite as DB engine
We need to create the SQLite database before it may be used by uguu.
Fortunately, this is incredibly simple.
First create a directory for the database, e.g. `mkdir /var/db/uguu`.
Then, create a new SQLite database from the schema, e.g. `sqlite3 /var/db/uguu/uguu.sq3 -init /home/uguu/sqlite_schema.sql`.
Then, finally, ensure the permissions are correct, e.g.
```bash
chown www-data:www-data /var/db/uguu
chmod 0750 /var/db/uguu
chmod 0640 /var/db/uguu/uguu.sq3
```
Finally, edit `includes/settings.inc.php` to indicate this is the database engine you would like to use. Make the changes outlined below
```php
define('UGUU_DB_CONN', '[stuff]'); ---> define('UGUU_DB_CONN', 'sqlite:/var/db/uguu/uguu.sq3');
define('UGUU_DB_USER', '[stuff]'); ---> define('UGUU_DB_USER', null);
define('UGUU_DB_PASS', '[stuff]'); ---> define('UGUU_DB_PASS', null);
```
*NOTE: The directory where the SQLite database is stored, must be writable by the web server user*
## API
To upload using curl or make a tool you can post using:
```
curl -i -F files[]=@yourfile.jpeg https://uguu.se/upload.php (JSON Response)
```
```
curl -i -F files[]=@yourfile.jpeg https://uguu.se/upload.php?output=text (Text Response)
```
```
curl -i -F files[]=@yourfile.jpeg https://uguu.se/upload.php?output=csv (CSV Response)
```
```
curl -i -F files[]=@yourfile.jpeg https://uguu.se/upload.php?output=html (HTML Response)
```
## Getting help
@ -50,3 +155,8 @@ Uguu is based on [Pomf](http://github.com/pomf/pomf) which was written by Emma L
Uguu is free software, and is released under the terms of the Expat license. See
`LICENSE`.
## To do in release v1.1.0
* Mod feature and interface
* Blacklist DB (already exists on Uguu.se, but not in this code)
* Code cleanup

View File

@ -3,7 +3,7 @@
"allowErrors": false
},
"dest": "dist",
"pkgVersion": "1.3.0",
"pkgVersion": "<%= pkg.version %>",
"banners": [
"banners/malware_scans.swig",
"banners/donations.swig"
@ -18,7 +18,7 @@
"max_upload_size": 128,
"production": false,
"siteName": "SITENAME",
"siteUrl": "https://yoursite.com",
"siteUrl": "http://localhost",
"abuseContact": "abuse@example.com",
"infoContact": "info@example.com",
"ServerCountryLocation": "Sweden",
@ -27,4 +27,4 @@
"paypalUrl": "",
"bitcoinAddress": "",
"flattrUrl": ""
}
}

View File

@ -1,26 +0,0 @@
CREATE TABLE `files` (
`id` int(20) unsigned NOT NULL auto_increment,
`hash` char(40) DEFAULT NULL,
`originalname` varchar(255) default NULL,
`filename` varchar(30) default NULL,
`size` int(15) DEFAULT NULL,
`date` int(15) DEFAULT NULL,
`ip` char(15) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `accounts` (
`id` int(20) unsigned NOT NULL auto_increment,
`email` varchar(255) default NULL,
`pass` varchar(255) default NULL,
`level` int(15) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE `blacklist` (
`id` int(20) unsigned NOT NULL auto_increment,
`hash` char(40) DEFAULT NULL,
`originalname` varchar(255) default NULL,
`time` int(15) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@ -1,28 +0,0 @@
{
"name": "uguu",
"version": "1.3.0",
"description": "Kawaii file host",
"homepage": "https://uguu.se/",
"repository": {
"type": "git",
"url": "https://github.com/nokonoko/pomf"
},
"author": "Eric Johansson <neku@pomf.se>",
"contributors": [
"Pomf Community <github.com/pomf/pomf>",
"Uguu Community <github.com/nokonoko/uguu>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/nokonoko/uguu/issues"
},
"devDependencies": {
"clean-css": "^5.1.2",
"clean-css-cli": "^5.3.0",
"uglify-js": "^3.13.9",
"swig": "^1.4.2"
},
"dependencies": {
"htmlmin": "0.0.6"
}
}

View File

@ -10,16 +10,4 @@ CREATE TABLE `files` (
, `date` integer default NULL
, `ip` char(15) default NULL
);
CREATE TABLE `accounts` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `email` varchar(255) default NULL
, `pass` varchar(255) default NULL
, `level` integer default NULL
);
CREATE TABLE `blacklist` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `hash` char(40) default NULL
, `originalname` varchar(255) default NULL
, `time` integer default NULL
);
END TRANSACTION;

View File

@ -35,11 +35,11 @@
*/
body {
background-attachment: fixed, fixed;
background-color: #1b1b1b;
background-color: #F7F7F7;
background-image: url('grill.php'), url('img/bg.png');
background-position: 85% 100%, top left;
background-repeat: no-repeat, repeat;
color: #f7f7f7;
color: #333;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
height: 100%;
@ -232,7 +232,7 @@ nav > ul > li:last-child:after {
color: #891A18;
}
button.upload-clipboard-btn {
height: 32px;
height: 16px;
}
.error#upload-filelist .progress-percent {
color: #B94A48;

BIN
static/img/10.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
static/img/11.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
static/img/12.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
static/img/13.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
static/img/14.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
static/img/15.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
static/img/16.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

BIN
static/img/17.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/img/18.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
static/img/19.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
static/img/2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

BIN
static/img/20.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
static/img/3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
static/img/4.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
static/img/5.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
static/img/6.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
static/img/7.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
static/img/8.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
static/img/9.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 801 B

BIN
static/img/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -1,7 +1,5 @@
/**
* Copyright (c) 2016 Luminarys <postmaster@gensok.io>
*
* Copyright (c) 2021 Eric Johansson (Nekunekus) <neku@pomf.se>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -22,7 +20,7 @@
* SOFTWARE.
*/
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function() {
/**
* Sets up the elements inside file upload rows.
*
@ -253,17 +251,6 @@
target.click();
}
/* Handles the pasting function */
window.addEventListener("paste", e =>{
var len = e.clipboardData.files.length;
for (var i = 0; i < len; i++) {
var file = e.clipboardData.files[i];
var row = addRow(file);
uploadFile(file, row);
}
});
/* Set-up the event handlers for the <button>, <input> and the window itself
and also set the "js" class on selector "#upload-form", presumably to
allow custom styles for clients running javascript. */
@ -274,7 +261,6 @@
window.addEventListener('drop', handleDragAway.bind(this, state, uploadButton), false);
window.addEventListener('dragover', stopDefaultEvent, false);
var uploadInput = document.getElementById('upload-input');
uploadInput.addEventListener('change', uploadFiles);
uploadButton.addEventListener('click', selectFiles.bind(this, uploadInput));

View File

@ -4,29 +4,27 @@ class UploadedFile
{
/* Public attributes */
public $name;
public $mime;
public $size;
public $tempfile;
public $error;
/**
* SHA-1 checksum
*
* @var string 40 digit hexadecimal hash (160 bits)
*/
private $sha1;
/**
* Generates the SHA-1 or returns the cached SHA-1 hash for the file.
*
* @return string|false $sha1
*/
public function getSha1()
{
if (!$this->sha1) {
$this->sha1 = sha1_file($this->tempfile);
}
return $this->sha1;
}
private $mime;
public function getMime()
{
if (!$this->mime) {
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$this->mime = finfo_file($finfo, $this->tempfile);
finfo_close($finfo);
}
return $this->mime;
}
}

View File

@ -2,8 +2,20 @@
// Array of image paths, feel free to add/remove to/from this list
$images = array(
'img/1.png',
'img/2.png',
'img/3.png',
'img/4.png',
'img/5.png',
'img/6.png',
'img/7.png',
'img/8.png',
'img/9.png',
'img/10.png',
'img/11.png',
'img/12.png',
'img/13.png',
'img/14.png',
'img/15.png',
);
// Redirect to a random image from the above array using status code "303 See Other"

View File

@ -25,21 +25,11 @@ define('UGUU_DB_USER', 'NULL');
/* @param string UGUU_DB_PASS Database password */
define('UGUU_DB_PASS', 'NULL');
/**
* @param boolean Log IP of uploads
*/
define('LOG_IP', false);
/** Log IP of uploads */
define('LOG_IP', 'false');
/**
* @param boolean anti-dupe
*/
define('ANTI_DUPE', false);
/**
* @param boolean blacklist DB
* ONLY ENABLE THIS IS YOU ARE USING THE LATEST DB SCHEMA!
*/
define('BLACKLIST_DB', false);
/** Dont upload a file already in the DB */
define('ANTI_DUPE', 'false');
/*
* File system location where to store uploaded files
@ -83,16 +73,20 @@ define('ID_CHARSET', 'abcdefghijklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ');
/*
* Filtered mime types
* @param string[] $FILTER_MIME allowed/blocked mime types
*/
//$FILTER_MIME = array("application/octet-stream", "application/msword", "text/html", "application/x-dosexec", "application/zip", "application/java", "application/java-archive", "application/pdf", "application/x-executable");
//$FILTER_EXT = array("exe", "scr", "com", "vbs", "bat", "cmd", "htm", "html", "zip", "jar", "msi", "apk", "pdf");
define('CONFIG_BLOCKED_EXTENSIONS', serialize(['exe', 'scr', 'com', 'vbs', 'bat', 'cmd', 'htm', 'html', 'jar', 'msi', 'apk', 'phtml', 'svg']));
define('CONFIG_BLOCKED_MIME', serialize(['application/msword', 'text/html', 'application/x-dosexec', 'application/java', 'application/java-archive', 'application/x-executable', 'application/x-mach-binary', 'image/svg+xml']));
/**
* Whitelist or blacklist mode
* @param boolean blacklist (false) | whitelist (true)
* Filter mode: whitelist (true) or blacklist (false).
*
* @param bool $FILTER_MODE mime type filter mode
*/
define('CONFIG_FILTER_MODE', false);
$FILTER_MODE = false;
/**
* Double dot file extensions.
*

View File

@ -27,11 +27,6 @@ function generateName($file)
//Get EXT
$ext = pathinfo($file->name, PATHINFO_EXTENSION);
//Get MIME
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$type_mime = finfo_file($finfo, $file->tempfile);
finfo_close($finfo);
// Check if extension is a double-dot extension and, if true, override $ext
$revname = strrev($file->name);
foreach ($doubledots as $ddot) {
@ -61,66 +56,17 @@ function generateName($file)
$name .= '.'.$ext;
}
// Check if the file is blacklisted
if(BLACKLIST_DB){
$q = $db->prepare('SELECT hash, COUNT(*) AS count FROM blacklist WHERE hash = (:hash)');
$q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR);
$q->execute();
$result = $q->fetch();
if ($result['count'] > 0) {
http_response_code(415);
throw new Exception(
'File blacklisted!',
415
);
exit(0);
}
//Check if MIME is blacklisted
if (in_array($file->getMime(), unserialize(CONFIG_BLOCKED_MIME))) {
http_response_code(415);
throw new UploadException(UPLOAD_ERR_EXTENSION);
exit(0);
}
// Check if file is whitelisted or blacklisted
switch (CONFIG_FILTER_MODE) {
case false:
//check if MIME is blacklisted
if (in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) {
http_response_code(415);
throw new Exception(
'File type not allowed!',
415
);
exit(0);
}
//Check if EXT is blacklisted
if (in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) {
http_response_code(415);
throw new Exception(
'File type not allowed!',
415
);
exit(0);
}
break;
case true:
//Check if MIME is whitelisted
if (!in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) {
http_response_code(415);
throw new Exception(
'File type not allowed!',
415
);
exit(0);
}
//Check if EXT is whitelisted
if (!in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) {
http_response_code(415);
throw new Exception(
'File type not allowed!',
415
);
exit(0);
}
break;
//Check if EXT is blacklisted
if (in_array($ext, unserialize(CONFIG_BLOCKED_EXTENSIONS))) {
http_response_code(415);
throw new UploadException(UPLOAD_ERR_EXTENSION);
exit(0);
}
// Check if a file with the same name does already exist in the database
@ -144,6 +90,8 @@ function generateName($file)
function uploadFile($file)
{
global $db;
global $FILTER_MODE;
global $FILTER_MIME;
// Handle file errors
if ($file->error) {
@ -156,7 +104,7 @@ function uploadFile($file)
// Check if a file with the same hash and size (a file which is the same)
// does already exist in the database; if it does, return the proper link
// and data. PHP deletes the temporary file just uploaded automatically.
if(ANTI_DUPE){
if(ANTI_DUPE == 'true'){
$q = $db->prepare('SELECT filename, COUNT(*) AS count FROM files WHERE hash = (:hash) AND size = (:size)');
$q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR);
$q->bindValue(':size', $file->size, PDO::PARAM_INT);
@ -172,6 +120,9 @@ function uploadFile($file)
}
}
// Get IP
$ip = $_SERVER['REMOTE_ADDR'];
// Generate a name for the file
$newname = generateName($file);
@ -196,15 +147,15 @@ function uploadFile($file)
); // HTTP status code "500 Internal Server Error"
}
// Log IP
if(LOG_IP){
$ip = $_SERVER['REMOTE_ADDR'];
} else {
$ip = null;
}
// Add it to the database
if(LOG_IP == 'true'){
$q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)');
} else {
$ip = '0';
$q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)');
}
// Common parameters binding
$q = $db->prepare('INSERT INTO files (hash, originalname, filename, size, date, ip) VALUES (:hash, :orig, :name, :size, :date, :ip)');
$q->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR);
$q->bindValue(':orig', strip_tags($file->name), PDO::PARAM_STR);
$q->bindValue(':name', $newname, PDO::PARAM_STR);
@ -252,7 +203,6 @@ function refiles($files)
foreach ($files as $file) {
$f = new UploadedFile();
$f->name = $file['name'];
$f->mime = $file['type'];
$f->size = $file['size'];
$f->tempfile = $file['tmp_name'];
$f->error = $file['error'];

View File

@ -1,8 +1,8 @@
{% extends "layout_index.swig" %}
{% extends "layout.swig" %}
{% block body %}
<div class="jumbotron">
<h1>{{siteName}}!</h1>
<h1>{{siteName}}~</h1>
<p class="lead">Max upload size is {{max_upload_size}}&nbsp;MiB & files expire after 24H, read the <a href="faq.html"><abbr title="Frequently asked questions">FAQ</abbr></a></p>
{% include "upload_form.swig" %}
</div>

View File

@ -5,9 +5,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Uguu {{pkgVersion}}">
<meta name="Description" content="{{SiteMetaInfo}}">
<title>{{siteName}} &middot; {% block title %}Temporary File Hosting{% endblock %}</title>
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
<title>{{siteName}} &middot; {% block title %}Kawaii Temporary File Hosting{% endblock %}</title>
<link rel="icon" href="favicon.ico">
<link rel="stylesheet" href="uguu.min.css">
<script src="uguu.min.js"></script>
</head>
<body>
<div class="container">

View File

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="Uguu {{pkgVersion}}">
<meta name="Description" content="{{SiteMetaInfo}}">
<title>{{siteName}} &middot; {% block title %}Temporary File Hosting{% endblock %}</title>
<link rel="icon" type="image/png" sizes="32x32" href="/img/favicon-32x32.png">
<link rel="stylesheet" href="uguu.min.css">
<script src="uguu.min.js"></script>
</head>
<body>
<div class="container">
{% block body %}What the fuck are you doing here, <span lang="jp">baka</span>?{% endblock %}
</div>
</body>
</html>

View File

@ -2,6 +2,6 @@
<ul>
<li><a href="/">{{siteName}}</a></li>
<li><a href="tools.html">Tools</a></li>
<li><a href="https://git.soper.xyz/Soper/sugoi">Git</a></li>
<li><a href="https://github.com/nokonoko/uguu">GitHub</a></li>
</ul>
</nav>

View File

@ -0,0 +1,5 @@
server {
listen 80;
server_name A.Y www.A.Y;
return 301 https://A.Y$request_uri;
}

View File

@ -0,0 +1,13 @@
server{
listen 443 ssl http2;
server_name A.Y www.A.Y;
ssl on;
ssl_certificate /etc/letsencrypt/live/A.Y/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/A.Y/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
root /var/www/uguu/files/;
autoindex off;
access_log off;
index index.html;
}

View File

@ -0,0 +1,5 @@
server {
listen 80;
server_name X.Y www.X.Y;
return 301 https://X.Y$request_uri;
}

View File

@ -0,0 +1,39 @@
server{
listen 443 ssl http2;
server_name www.X.Y X.Y;
ssl on;
ssl_certificate /etc/letsencrypt/live/X.Y/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/X.Y/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_ecdh_curve secp384r1;
ssl_buffer_size 2k;
ssl_session_tickets off;
root /var/www/uguu/dist/;
autoindex off;
access_log off;
index index.html index.php;
etag on;
location ~* \.(?:css|js|jpg|jpeg|gif|png|ico|xml|eot|woff|woff2|ttf|svg|otf)$ {
add_header Cache-Control "public";
expires 30d;
}
gzip on;
gzip_min_length 1000;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/css text/js text/javascript application/javascript application/x-javascript;
location ~* \.php$ {
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

View File

@ -0,0 +1,72 @@
user www-data;
worker_processes auto;
worker_rlimit_nofile 40000;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 4096;
multi_accept on;
use epoll;
}
http {
ssl_session_cache shared:SSL:5m;
ssl_session_timeout 12h;
ssl_session_tickets off;
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 10;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 128m;
##
# Mime Settings
##
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
#access_log /var/log/nginx/access.log;
#error_log /var/log/nginx/error.log;
error_log off;
access_log off;
##
# Gzip Settings
##
#gzip off;
#gzip_vary on;
#gzip_proxied any;
#gzip_comp_level 6;
#gzip_buffers 16 8k;
#gzip_http_version 1.1;
#gzip_types application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon text/css text/javascript text/xml;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}

View File

@ -1,5 +1,5 @@
<form id="upload-form" enctype="multipart/form-data" method="post" action="upload.php?output=html">
<button id="upload-btn" class="btn" type="button">Drop or paste file(s)</button>
<button id="upload-btn" class="btn" type="button">Select or drop file(s)</button>
<input type="file" id="upload-input" name="files[]" multiple data-max-size="{{max_upload_size}}MiB">
<input type="submit" value="Submit">
</form>