testing
nokonoko 2021-06-22 21:30:58 +02:00
parent e3b2d66ef3
commit 85d74c0d22
64 changed files with 2372 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ node_modules
build
package.json
package-lock.json
.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>

18
LICENSE Normal file
View File

@ -0,0 +1,18 @@
Copyright (c) 2020 Eric Johansson <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 in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

97
Makefile Normal file
View File

@ -0,0 +1,97 @@
MAKE="make"
INSTALL="install"
TAR="tar"
GREP="grep"
NODE="node"
NPM="npm"
DESTDIR="./dist"
PKG_VERSION := $( $(GREP) -Po '(?<="version": ")[^"]*' )
TMPDIR := $(shell mktemp -d)
# default modules
MODULES="php"
all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules
swig:
$(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html
$(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html
$(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > $(CURDIR)/build/tools.html
htmlmin:
$(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/index.html -o $(CURDIR)/build/index.html
$(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/faq.html -o $(CURDIR)/build/faq.html
$(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html
installdirs:
mkdir -p $(DESTDIR)/ $(DESTDIR)/img
ifneq (,$(findstring php,$(MODULES)))
mkdir -p $(DESTDIR)/classes $(DESTDIR)/includes
endif
ifneq (,$(findstring moe,$(MODULES)))
mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
endif
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 --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/.),)
cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
else
$(error The php submodule was not found)
endif
copy-moe:
ifneq ($(wildcard $(CURDIR)/moe/.),)
cp -rv $(CURDIR)/moe $(CURDIR)/build/
else
$(error The moe submodule was not found)
endif
install: installdirs
cp -rv $(CURDIR)/build/* $(DESTDIR)/
dist:
DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
export DESTDIR
install
$(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
rm -rf $(TMPDIR)
clean:
rm -rvf $(CURDIR)/node_modules
rm -rvf $(CURDIR)/build
uninstall:
rm -rvf $(DESTDIR)/
npm_dependencies:
$(NPM) install
builddirs:
mkdir -p $(CURDIR)/build $(CURDIR)/build/img
ifneq (,$(findstring php,$(MODULES)))
mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
endif
ifneq (,$(findstring moe,$(MODULES)))
mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
endif
submodules:
$(info The following modules will be enabled: $(MODULES))
ifneq (,$(findstring php,$(MODULES)))
$(MAKE) copy-php
endif
ifneq (,$(findstring moe,$(MODULES)))
$(MAKE) copy-moe
endif

162
README.md Normal file
View File

@ -0,0 +1,162 @@
# What is Uguu?
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 supported
- Upload API with multiple response choices
- JSON
- HTML
- Text
- CSV
- Supports [ShareX](https://getsharex.com/) and other screenshot tools
### Demo
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.
Node is used to compile Uguu.
## Install
**Detailed installation and configuration can be found at [Uguu Documentation](https://blog.yeet.nu/blog/uguu-docs).**
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
Hit me up at [@nekunekus](https://twitter.com/nekunekus) or email me at neku@pomf.se
## Credits
Uguu is based on [Pomf](http://github.com/pomf/pomf) which was written by Emma Lejack & Eric Johansson (nekunekus) and with help from the open source community.
## License
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

1
checkdb.sh Normal file
View File

@ -0,0 +1 @@
sqlite3 /path/to/db/uguu.sq3 "DELETE FROM files WHERE date <= strftime('%s', datetime('now', '-1 day'));"

2
checkfiles.sh Normal file
View File

@ -0,0 +1,2 @@
#! /bin/sh
find /path/to/files/ -mmin +1440 -exec rm -f {} \;

30
dist.json Normal file
View File

@ -0,0 +1,30 @@
{
"init": {
"allowErrors": false
},
"dest": "dist",
"pkgVersion": "<%= pkg.version %>",
"banners": [
"banners/malware_scans.swig",
"banners/donations.swig"
],
"src": [
"templates/index.swig",
"templates/faq.swig",
"templates/tools.swig"
],
"generateRobotstxt": false,
"generateSitemap": false,
"max_upload_size": 128,
"production": false,
"siteName": "SITENAME",
"siteUrl": "https://yoursite.com",
"abuseContact": "abuse@example.com",
"infoContact": "info@example.com",
"ServerCountryLocation": "Sweden",
"SiteMetaInfo": "SITENAME is a temporary file hosting service, upload files up to 128MiB for 24 hours.",
"ToolsDesc": "The following tools might need editing to work on this clone of Uguu, usually editing the URL works.",
"paypalUrl": "",
"bitcoinAddress": "",
"flattrUrl": ""
}

13
sqlite_schema.sql Normal file
View File

@ -0,0 +1,13 @@
PRAGMA synchronous = OFF;
PRAGMA journal_mode = MEMORY;
BEGIN TRANSACTION;
CREATE TABLE `files` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT
, `hash` char(40) default NULL
, `originalname` varchar(255) default NULL
, `filename` varchar(30) default NULL
, `size` integer default NULL
, `date` integer default NULL
, `ip` char(15) default NULL
);
END TRANSACTION;

397
static/css/uguu.css Normal file
View File

@ -0,0 +1,397 @@
/**
* Copyright (c) 2011, 2012, 2013 Twitter, Inc.
* Copyright (c) 2013, 2014 Peter Lejeck <peter.lejeck@gmail.com>
*
* 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 use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* USE BORDER BOX
*/
*,
*:before,
*:after {
box-sizing: border-box;
}
/**
* PAGE LAYOUT
*/
body {
background-attachment: fixed, fixed;
background-color: #F7F7F7;
background-image: url('grill.php'), url('img/bg.png');
background-position: 85% 100%, top left;
background-repeat: no-repeat, repeat;
color: #333;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
height: 100%;
line-height: 20px;
margin: 0;
padding-top: 20px;
padding-bottom: 40px;
}
.container {
margin: 0 auto;
max-width: 700px;
}
/**
* ELEMENTS
*/
/* paragraphs */
p {
margin: 0 0 10px;
}
/* images */
input[type=image], img {
vertical-align: middle;
}
/* links */
a {
color: #0078B4;
text-decoration: none;
transition: color 0.25s;
}
a:hover,
a:focus,
a:active {
color: #005580;
}
a:focus {
outline: thin dotted #333;
}
/**
* JUMBOTRON
*/
.jumbotron {
margin: 60px 0;
text-align: center;
transition: width 0.5s, height 0.5s, margin 0.5s, padding 0.5s;
}
.jumbotron h1 {
color: inherit;
font-family: inherit;
font-size: 72px;
font-weight: bold;
line-height: 1;
margin: 10px 0;
cursor: default;
text-rendering: optimizelegibility;
}
.jumbotron .lead {
font-size: 21px;
font-weight: 200;
line-height: 30px;
margin-bottom: 20px;
transition: font-size 0.5s;
}
.jumbotron .btn {
background: rgba(202, 230, 190, 0.75);
border: 1px solid #B7D1A0;
border-radius: 4px;
color: #468847;
cursor: pointer;
display: inline-block;
font-size: 24px;
padding: 28px 48px;
text-shadow: 0 1px rgba(255, 255, 255, 0.5);
transition: background-color 0.25s, width 0.5s, height 0.5s;
}
.jumbotron .btn:hover,
.jumbotron .btn:active,
.jumbotron .btn:focus,
.jumbotron .btn.drop {
background-color: rgb(188, 228, 170);
text-decoration: none;
}
/**
* BOXES
*/
.alert {
background-color: #FCF8E3;
border: 1px solid #FBEED5;
border-radius: 4px;
margin-bottom: 20px;
padding: 8px 14px;
text-shadow: 0px 1px rgba(255, 255, 255, 0.5);
transition: width 0.5s, margin 0.5s, padding 0.5s, background-color 0.5s;
}
.alert-error {
background-color: #F2DEDE;
border-color: #EED3D7;
color: #AA4342;
}
.alert-info {
background-color: #D9EDF7;
border-color: #BCE8F1;
color: #167196;
}
/**
* DONATION BUTTONS
*/
span.donate-btns {
display: block;
text-align: center;
margin: 11px 0 3px;
}
a.donate-btn {
height: 26px;
display: inline-block;
margin: 2px 5px;
background: hsl(0, 0%, 95%);
line-height: 16px;
padding: 3px 8px 3px 24px;
border-radius: 3px;
color: hsl(0, 0%, 25%);
border: 1px solid hsl(0, 0%, 85%);
transition: all .2s;
}
a.donate-btn:hover {
color: #000;
border: 1px solid hsl(0, 0%, 70%);
background-color: hsl(0, 0%, 80%);
}
.icon {
display: block;
height: 16px;
width: 16px;
float: left;
margin-left: -20px;
margin-top: 1px;
}
.icon-paypal {
background-image: url('img/paypal.png');
}
.icon-bitcoin {
background-image: url('img/bitcoin.png');
}
.icon-flattr {
background-image: url('img/flattr.png');
}
/**
* NAVIGATION LINKS
*/
nav > ul,
nav a {
color: #33799B;
list-style: none;
margin: 0;
padding: 0;
text-align: center;
}
nav > ul > li {
display: inline-block;
margin: 0;
padding: 0;
cursor: default;
}
nav > ul > li:after {
content: "|";
margin: 0 8px;
opacity: 0.3;
}
nav > ul > li:last-child:after {
content: "";
margin: 0;
}
/**
* UPLOAD FILE LIST
*/
#upload-filelist {
list-style-type: none;
margin: 20px 50px;
padding: 0;
text-align: left;
}
.error#upload-filelist {
color: #891A18;
}
button.upload-clipboard-btn {
height: 16px;
}
.error#upload-filelist .progress-percent {
color: #B94A48;
}
.error#upload-filelist .file-progress {
display: none;
}
#upload-filelist > li {
margin-top: 5px;
overflow: hidden;
}
#upload-filelist > li.total {
border-top: 1px solid rgba(0, 0, 0, 0.05);
font-weight: bold;
padding-top: 5px;
}
.file-name {
float: left;
overflow: hidden;
max-width: 70%;
text-overflow: ellipsis;
white-space: nowrap;
}
.file-progress,
.file-url {
display: inline-block;
float: right;
font-size: 0.9em;
margin-left: 8px;
vertical-align: middle;
}
.file-url a {
color: #5C5C5C;
}
.file-url a:hover {
color: #1C1C1C;
}
.progress-percent {
float: right;
}
progress[value] {
/* Reset the default appearance */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
}
progress[value]::-webkit-progress-bar {
background-color: #eee;
border-radius: 2px;
box-shadow: 0 2px 5px rgba(0,0,0,0.25) inset;
}
/* completed rows */
.completed .file-progress,
.completed .progress-percent {
display: none;
}
.completed .file-url {
display: block;
}
/**
* PROGRESS BARS
*/
.progress-outer {
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid white;
border-radius: 4px;
box-shadow: 0 0 0 1px black;
color: transparent;
display: inline-block;
font-size: 0;
float: right;
height: 8px;
margin: 6px 6px 0;
overflow: hidden;
vertical-align: middle;
width: 50px;
}
.progress-inner {
background-color: black;
height: 6px;
margin: 0;
width: 0;
}
/**
* MEDIA QUERIES
*/
@media only screen and (max-device-width: 320px), only screen and (max-width: 400px) {
body {
padding: 10px 0 0 0;
}
.jumbotron {
margin: 20px 0 30px;
}
.jumbotron .lead {
font-size: 18px;
}
.jumbotron .btn, .alert, #upload-filelist {
border-radius: 0;
border-width: 1px 0;
width: 100%;
margin-left: 0;
margin-right: 0;
padding-left: 20px;
padding-right: 20px;
}
#upload-filelist {
background-color: rgba(255, 255, 255, 0.75);
overflow: hidden;
}
#upload-filelist > li.file {
margin-top: 12px;
margin-bottom: 12px;
}
.file-progress {
width: 70%;
}
.file-name, .file-url {
width: 100%;
max-width: 100%;
}
.file-url a {
text-decoration: underline;
margin-left: 15px;
}
.file-url a:before {
content: "http://";
}
.alert {
font-size: 13px;
}
.alert-error {
background-color: rgba(248, 223, 223, 0.75);
}
nav {
background-color: rgba(255, 255, 255, 0.75);
border: #FFFFFF;
padding: 10px 0;
}
}
/*
* no js
*/
#upload-btn {
display: none;
}
.js #upload-input {
display: none;
}
.js input[type="submit"]{
display: none;
}
.js #upload-btn {
display: inline-block !important;
}

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

BIN
static/img/bg.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
static/img/bitcoin.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 945 B

BIN
static/img/donate.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
static/img/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
static/img/flattr.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

BIN
static/img/paypal.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

269
static/js/app.js Normal file
View File

@ -0,0 +1,269 @@
/**
* Copyright (c) 2016 Luminarys <postmaster@gensok.io>
*
* 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 use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
document.addEventListener('DOMContentLoaded', function() {
/**
* Sets up the elements inside file upload rows.
*
* @param {File} file
* @return {HTMLLIElement} row
*/
function addRow(file) {
var row = document.createElement('li');
var name = document.createElement('span');
name.textContent = file.name;
name.className = 'file-name';
var progressIndicator = document.createElement('span');
progressIndicator.className = 'progress-percent';
progressIndicator.textContent = '0%';
var progressBar = document.createElement('progress');
progressBar.className = 'file-progress';
progressBar.setAttribute('max', '100');
progressBar.setAttribute('value', '0');
row.appendChild(name);
row.appendChild(progressBar);
row.appendChild(progressIndicator);
document.getElementById('upload-filelist').appendChild(row);
return row;
}
/**
* Updates the page while the file is being uploaded.
*
* @param {ProgressEvent} evt
*/
function handleUploadProgress(evt) {
var xhr = evt.target;
var bar = xhr.bar;
var percentIndicator = xhr.percent;
/* If we have amounts of work done/left that we can calculate with
(which, unless we're uploading dynamically resizing data, is always), calculate the percentage. */
if (evt.lengthComputable) {
var progressPercent = Math.floor((evt.loaded / evt.total) * 100);
bar.setAttribute('value', progressPercent);
percentIndicator.textContent = progressPercent + '%';
}
}
/**
* Complete the uploading process by checking the response status and, if the
* upload was successful, writing the URL(s) and creating the copy element(s)
* for the files.
*
* @param {ProgressEvent} evt
*/
function handleUploadComplete(evt) {
var xhr = evt.target;
var bar = xhr.bar;
var row = xhr.row;
var percentIndicator = xhr.percent;
percentIndicator.style.visibility = 'hidden';
bar.style.visibility = 'hidden';
row.removeChild(bar);
row.removeChild(percentIndicator);
var respStatus = xhr.status;
var url = document.createElement('span');
url.className = 'file-url';
row.appendChild(url);
var link = document.createElement('a');
if (respStatus === 200) {
var response = JSON.parse(xhr.responseText);
if (response.success) {
link.textContent = response.files[0].url.replace(/.*?:\/\//g, '');
link.href = response.files[0].url;
url.appendChild(link);
var copy = document.createElement('button');
copy.className = 'upload-clipboard-btn';
var glyph = document.createElement('img');
glyph.src = 'img/glyphicons-512-copy.png';
copy.appendChild(glyph);
url.appendChild(copy);
copy.addEventListener("click", function(event) {
/* Why create an element? The text needs to be on screen to be
selected and thus copied. The only text we have on-screen is the link
without the http[s]:// part. So, this creates an element with the
full link for a moment and then deletes it.
See the "Complex Example: Copy to clipboard without displaying
input" section at: https://stackoverflow.com/a/30810322 */
var element = document.createElement('a');
element.textContent = response.files[0].url;
link.appendChild(element);
var range = document.createRange();
range.selectNode(element);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
document.execCommand("copy");
link.removeChild(element);
});
} else {
bar.innerHTML = 'Error: ' + response.description;
}
} else if (respStatus === 413) {
link.textContent = 'File too big!';
url.appendChild(link);
} else if (respStatus === 415) {
link.textContent = 'Filetype not allowed!';
url.appendChild(link);
} else {
link.textContent = 'Server error!';
url.appendChild(link);
}
}
/**
* Updates the page while the file is being uploaded.
*
* @param {File} file
* @param {HTMLLIElement} row
*/
function uploadFile(file, row) {
var bar = row.querySelector('.file-progress');
var percentIndicator = row.querySelector('.progress-percent');
var xhr = new XMLHttpRequest();
xhr.open('POST', 'upload.php');
xhr['row'] = row;
xhr['bar'] = bar;
xhr['percent'] = percentIndicator;
xhr.upload['bar'] = bar;
xhr.upload['percent'] = percentIndicator;
xhr.addEventListener('load', handleUploadComplete, false);
xhr.upload.onprogress = handleUploadProgress;
var form = new FormData();
form.append('files[]', file);
xhr.send(form);
}
/**
* Prevents the browser for allowing the normal actions associated with an event.
* This is used by event handlers to allow custom functionality without
* having to worry about the other consequences of that action.
*
* @param {Event} evt
*/
function stopDefaultEvent(evt) {
evt.stopPropagation();
evt.preventDefault();
}
/**
* Adds 1 to the state and changes the text.
*
* @param {Object} state
* @param {HTMLButtonElement} element
* @param {DragEvent} evt
*/
function handleDrag(state, element, evt) {
stopDefaultEvent(evt);
if (state.dragCount == 1) {
element.textContent = 'Drop it here~';
}
state.dragCount += 1;
}
/**
* Subtracts 1 from the state and changes the text back.
*
* @param {Object} state
* @param {HTMLButtonElement} element
* @param {DragEvent} evt
*/
function handleDragAway(state, element, evt) {
stopDefaultEvent(evt);
state.dragCount -= 1;
if (state.dragCount == 0) {
element.textContent = 'Select or drop file(s)';
}
}
/**
* Prepares files for uploading after being added via drag-drop.
*
* @param {Object} state
* @param {HTMLButtonElement} element
* @param {DragEvent} evt
*/
function handleDragDrop(state, element, evt) {
stopDefaultEvent(evt);
handleDragAway(state, element, evt);
var len = evt.dataTransfer.files.length;
for (var i = 0; i < len; i++) {
var file = evt.dataTransfer.files[i];
var row = addRow(file);
uploadFile(file, row);
}
}
/**
* Prepares the files to be uploaded when they're added to the <input> element.
*
* @param {InputEvent} evt
*/
function uploadFiles(evt) {
var len = evt.target.files.length;
// For each file, make a row, and upload the file.
for (var i = 0; i < len; i++) {
var file = evt.target.files[i];
var row = addRow(file);
uploadFile(file, row);
}
}
/**
* Opens up a "Select files.." dialog window to allow users to select files to upload.
*
* @param {HTMLInputElement} target
* @param {InputEvent} evt
*/
function selectFiles(target, evt) {
stopDefaultEvent(evt);
target.click();
}
/* 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. */
var state = { dragCount: 0 };
var uploadButton = document.getElementById('upload-btn');
window.addEventListener('dragenter', handleDrag.bind(this, state, uploadButton), false);
window.addEventListener('dragleave', handleDragAway.bind(this, state, uploadButton), false);
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));
uploadButton.addEventListener('drop', handleDragDrop.bind(this, state, uploadButton), false);
document.getElementById('upload-form').classList.add('js');
});

3
static/php/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
node_modules
dist
dist.zip

0
static/php/.gitmodules vendored Normal file
View File

1
static/php/.mailmap Normal file
View File

@ -0,0 +1 @@
Eric Johansson <neku@pomf.se>

18
static/php/.travis.yml Normal file
View File

@ -0,0 +1,18 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.3'
- '7.4'
- hhvm
install:
- source ~/.nvm/nvm.sh
- nvm ls-remote
- nvm install stable
- nvm use stable
script:
- make

18
static/php/LICENSE Normal file
View File

@ -0,0 +1,18 @@
Copyright (c) 2020 Eric Johansson <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 in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,259 @@
<?php
/**
* The Response class is a do-it-all for getting responses out in different
* formats.
*
* @todo Create sub-classes to split and extend this god object.
*/
class Response
{
/**
* Indicates response type used for routing.
*
* Valid strings are 'csv', 'html', 'json' and 'text'.
*
* @var string Response type
*/
private $type;
/**
* Indicates requested response type.
*
* Valid strings are 'csv', 'html', 'json', 'gyazo' and 'text'.
*
* @param string|null $response_type Response type
*/
public function __construct($response_type = null)
{
switch ($response_type) {
case 'csv':
header('Content-Type: text/csv; charset=UTF-8');
$this->type = $response_type;
break;
case 'html':
header('Content-Type: text/html; charset=UTF-8');
$this->type = $response_type;
break;
case 'json':
header('Content-Type: application/json; charset=UTF-8');
$this->type = $response_type;
break;
case 'gyazo':
header('Content-Type: text/plain; charset=UTF-8');
$this->type = 'text';
break;
case 'text':
header('Content-Type: text/plain; charset=UTF-8');
$this->type = $response_type;
break;
default:
header('Content-Type: application/json; charset=UTF-8');
$this->type = 'json';
$this->error(400, 'Invalid response type. Valid options are: csv, html, json, text.');
break;
}
}
/**
* Routes error messages depending on response type.
*
* @param int $code HTTP status code number
* @param int $desc descriptive error message
*
* @return void
*/
public function error($code, $desc)
{
$response = null;
switch ($this->type) {
case 'csv':
$response = $this->csvError($desc);
break;
case 'html':
$response = $this->htmlError($code, $desc);
break;
case 'json':
$response = $this->jsonError($code, $desc);
break;
case 'text':
$response = $this->textError($code, $desc);
break;
}
//http_response_code(500); // "500 Internal Server Error"
echo $response;
}
/**
* Routes success messages depending on response type.
*
* @param mixed[] $files
*
* @return void
*/
public function send($files)
{
$response = null;
switch ($this->type) {
case 'csv':
$response = $this->csvSuccess($files);
break;
case 'html':
$response = $this->htmlSuccess($files);
break;
case 'json':
$response = $this->jsonSuccess($files);
break;
case 'text':
$response = $this->textSuccess($files);
break;
}
http_response_code(200); // "200 OK". Success.
echo $response;
}
/**
* Indicates with CSV body the request was invalid.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param int $description descriptive error message
*
* @return string error message in CSV format
*/
private static function csvError($description)
{
return '"error"'."\r\n"."\"$description\""."\r\n";
}
/**
* Indicates with CSV body the request was successful.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param mixed[] $files
*
* @return string success message in CSV format
*/
private static function csvSuccess($files)
{
$result = '"name","url","hash","size"'."\r\n";
foreach ($files as $file) {
$result .= '"'.$file['name'].'"'.','.
'"'.$file['url'].'"'.','.
'"'.$file['hash'].'"'.','.
'"'.$file['size'].'"'."\r\n";
}
return $result;
}
/**
* Indicates with HTML body the request was invalid.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param int $code HTTP status code number
* @param int $description descriptive error message
*
* @return string error message in HTML format
*/
private static function htmlError($code, $description)
{
return '<p>ERROR: ('.$code.') '.$description.'</p>';
}
/**
* Indicates with HTML body the request was successful.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param mixed[] $files
*
* @return string success message in HTML format
*/
private static function htmlSuccess($files)
{
$result = '';
foreach ($files as $file) {
$result .= '<a href="'.$file['url'].'">'.$file['url'].'</a><br>';
}
return $result;
}
/**
* Indicates with JSON body the request was invalid.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param int $code HTTP status code number
* @param int $description descriptive error message
*
* @return string error message in pretty-printed JSON format
*/
private static function jsonError($code, $description)
{
return json_encode([
'success' => false,
'errorcode' => $code,
'description' => $description,
], JSON_PRETTY_PRINT);
}
/**
* Indicates with JSON body the request was successful.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param mixed[] $files
*
* @return string success message in pretty-printed JSON format
*/
private static function jsonSuccess($files)
{
return json_encode([
'success' => true,
'files' => $files,
], JSON_PRETTY_PRINT);
}
/**
* Indicates with plain text body the request was invalid.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param int $code HTTP status code number
* @param int $description descriptive error message
*
* @return string error message in plain text format
*/
private static function textError($code, $description)
{
return 'ERROR: ('.$code.') '.$description;
}
/**
* Indicates with plain text body the request was successful.
*
* @deprecated 2.1.0 Will be renamed to camelCase format.
*
* @param mixed[] $files
*
* @return string success message in plain text format
*/
private static function textSuccess($files)
{
$result = '';
foreach ($files as $file) {
$result .= $file['url']."\n";
}
return $result;
}
}

View File

@ -0,0 +1,63 @@
<?php
/**
* Returns a human readable error description for file upload errors.
*
* @author Dan Brown <danbrown@php.net>
* @author Michiel Thalen
* @copyright Copyright © 1997 - 2016 by the PHP Documentation Group
* @license
* UploadException is licensed under a Creative Commons Attribution 3.0 License
* or later.
*
* Based on a work at
* https://secure.php.net/manual/en/features.file-upload.errors.php#89374.
*
* You should have received a copy of the Creative Commons Attribution 3.0
* License with this program. If not, see
* <https://creativecommons.org/licenses/by/3.0/>.
*/
class UploadException extends Exception
{
public function __construct($code)
{
$message = $this->codeToMessage($code);
parent::__construct($message, 500);
}
private function codeToMessage($code)
{
switch ($code) {
case UPLOAD_ERR_INI_SIZE:
$message = 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
break;
case UPLOAD_ERR_FORM_SIZE:
$message = 'The uploaded file exceeds the MAX_FILE_SIZE directive that was '.
'specified in the HTML form';
break;
case UPLOAD_ERR_PARTIAL:
$message = 'The uploaded file was only partially uploaded';
break;
case UPLOAD_ERR_NO_FILE:
$message = 'No file was uploaded';
break;
case UPLOAD_ERR_NO_TMP_DIR:
$message = 'Missing a temporary folder';
break;
case UPLOAD_ERR_CANT_WRITE:
$message = 'Failed to write file to disk';
break;
case UPLOAD_ERR_EXTENSION:
$message = 'File upload stopped by extension';
break;
default:
$message = 'Unknown upload error';
break;
}
return $message;
}
}

View File

@ -0,0 +1,32 @@
<?php
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;
}
}

24
static/php/grill.php Normal file
View File

@ -0,0 +1,24 @@
<?php
// Array of image paths, feel free to add/remove to/from this list
$images = array(
'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"
if (headers_sent() === false) {
header('Location: '.$images[array_rand($images)], true, 303);
}

View File

@ -0,0 +1,6 @@
<?php
require_once 'settings.inc.php';
/* NOTE: we don't have to unref the PDO because we're not long-running */
$db = new PDO(UGUU_DB_CONN, UGUU_DB_USER, UGUU_DB_PASS);

View File

@ -0,0 +1,106 @@
<?php
/**
* User configurable settings for Uguu.
*/
/*
* PDO connection socket
*
* Database connection to use for communication. Currently, MySQL is the only
* DSN prefix supported.
*
* @see http://php.net/manual/en/ref.pdo-mysql.connection.php PHP manual for
* PDO_MYSQL DSN.
* @param string UGUU_DB_CONN DSN:host|unix_socket=hostname|path;dbname=database
*/
define('UGUU_DB_CONN', 'sqlite:/path/to/db/uguu.sq3');
/*
* PDO database login credentials
*/
/* @param string UGUU_DB_NAME Database username */
define('UGUU_DB_USER', 'NULL');
/* @param string UGUU_DB_PASS Database password */
define('UGUU_DB_PASS', 'NULL');
/** Log IP of uploads */
define('LOG_IP', 'false');
/** Dont upload a file already in the DB */
define('ANTI_DUPE', 'false');
/*
* File system location where to store uploaded files
*
* @param string Path to directory with trailing delimiter
*/
define('UGUU_FILES_ROOT', '/path/to/file/');
/*
* Maximum number of iterations while generating a new filename
*
* Uguu uses an algorithm to generate random filenames. Sometimes a file may
* exist under a randomly generated filename, so we count tries and keep trying.
* If this value is exceeded, we give up trying to generate a new filename.
*
* @param int UGUU_FILES_RETRIES Number of attempts to retry
*/
define('UGUU_FILES_RETRIES', 15);
/*
* The length of generated filename (without file extension)
*
* @param int UGUU_FILES_LENGTH Number of random alphabetical ASCII characters
* to use
*/
define('UGUU_FILES_LENGTH', 8);
/*
* URI to prepend to links for uploaded files
*
* @param string UGUU_URL URI with trailing delimiter
*/
define('UGUU_URL', 'https://url.to.subdomain.where.files.will.be.served.com/');
/*
* URI for filename generation
*
* @param string characters to be used in generateName()
*/
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']));
/**
* Filter mode: whitelist (true) or blacklist (false).
*
* @param bool $FILTER_MODE mime type filter mode
*/
$FILTER_MODE = false;
/**
* Double dot file extensions.
*
* Uguu keeps the last file extension for the uploaded file. In other words, an
* uploaded file with `.tar.gz` extension will be given a random filename which
* ends in `.gz` unless configured here to ignore discards for `.tar.gz`.
*
* @param string[] $doubledots Array of double dot file extensions strings
* without the first prefixing dot
*/
$doubledots = array_map('strrev', [
'tar.gz',
'tar.bz',
'tar.bz2',
'tar.xz',
'user.js',
]);

237
static/php/upload.php Normal file
View File

@ -0,0 +1,237 @@
<?php
/**
* Handles POST uploads, generates filenames, moves files around and commits
* uploaded metadata to database.
*/
require_once 'classes/Response.class.php';
require_once 'classes/UploadException.class.php';
require_once 'classes/UploadedFile.class.php';
require_once 'includes/database.inc.php';
/**
* Generates a random name for the file, retrying until we get an unused one.
*
* @param UploadedFile $file
*
* @return string
*/
function generateName($file)
{
global $db;
global $doubledots;
// We start at N retries, and --N until we give up
$tries = UGUU_FILES_RETRIES;
$length = UGUU_FILES_LENGTH;
//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) {
if (stripos($revname, $ddot) === 0) {
$ext = strrev($ddot);
}
}
do {
// Iterate until we reach the maximum number of retries
if ($tries-- === 0) {
http_response_code(500);
throw new Exception(
'Gave up trying to find an unused name',
500
); // HTTP status code "500 Internal Server Error"
}
$chars = ID_CHARSET;
$name = '';
for ($i = 0; $i < $length; ++$i) {
$name .= $chars[mt_rand(0, strlen($chars))];
}
// Add the extension to the file name
if (isset($ext) && $ext !== '') {
$name .= '.'.$ext;
}
//Check if MIME is blacklisted
if (in_array($type_mime, unserialize(CONFIG_BLOCKED_MIME))) {
http_response_code(415);
throw new UploadException(UPLOAD_ERR_EXTENSION);
exit(0);
}
//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
$q = $db->prepare('SELECT COUNT(filename) FROM files WHERE filename = (:name)');
$q->bindValue(':name', $name, PDO::PARAM_STR);
$q->execute();
$result = $q->fetchColumn();
// If it does, generate a new name
} while ($result > 0);
return $name;
}
/**
* Handles the uploading and db entry for a file.
*
* @param UploadedFile $file
*
* @return array
*/
function uploadFile($file)
{
global $db;
global $FILTER_MODE;
global $FILTER_MIME;
// Handle file errors
if ($file->error) {
throw new UploadException($file->error);
}
//fixes a bug
$lol = $file->getSha1();
// 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 == '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);
$q->execute();
$result = $q->fetch();
if ($result['count'] > 0) {
return [
'hash' => $file->getSha1(),
'name' => $file->name,
'url' => UGUU_URL.rawurlencode($result['filename']),
'size' => $file->size,
];
}
}
// Get IP
$ip = $_SERVER['REMOTE_ADDR'];
// Generate a name for the file
$newname = generateName($file);
// Store the file's full file path in memory
$uploadFile = UGUU_FILES_ROOT.$newname;
// Attempt to move it to the static directory
if (!move_uploaded_file($file->tempfile, $uploadFile)) {
http_response_code(500);
throw new Exception(
'Failed to move file to destination',
500
); // HTTP status code "500 Internal Server Error"
}
// Need to change permissions for the new file to make it world readable
if (!chmod($uploadFile, 0644)) {
http_response_code(500);
throw new Exception(
'Failed to change file permissions',
500
); // HTTP status code "500 Internal Server Error"
}
// 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->bindValue(':hash', $file->getSha1(), PDO::PARAM_STR);
$q->bindValue(':orig', strip_tags($file->name), PDO::PARAM_STR);
$q->bindValue(':name', $newname, PDO::PARAM_STR);
$q->bindValue(':size', $file->size, PDO::PARAM_INT);
$q->bindValue(':date', time(), PDO::PARAM_STR);
$q->bindValue(':ip', $ip, PDO::PARAM_STR);
$q->execute();
return [
'hash' => $file->getSha1(),
'name' => $file->name,
'url' => UGUU_URL.rawurlencode($newname),
'size' => $file->size,
];
}
/**
* Reorder files array by file.
*
* @return array
*/
function diverseArray($files)
{
$result = [];
foreach ($files as $key1 => $value1) {
foreach ($value1 as $key2 => $value2) {
$result[$key2][$key1] = $value2;
}
}
return $result;
}
/**
* Reorganize the $_FILES array into something saner.
*
* @return array
*/
function refiles($files)
{
$result = [];
$files = diverseArray($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'];
$result[] = $f;
}
return $result;
}
$type = isset($_GET['output']) ? $_GET['output'] : 'json';
$response = new Response($type);
if (isset($_FILES['files'])) {
$uploads = refiles($_FILES['files']);
try {
foreach ($uploads as $upload) {
$res[] = uploadFile($upload);
}
$response->send($res);
} catch (Exception $e) {
$response->error($e->getCode(), $e->getMessage());
}
} else {
$response->error(400, 'No input file(s)');
}

3
templates/banners.swig Normal file
View File

@ -0,0 +1,3 @@
{% for banner in banners %}
{% include banner %}
{% endfor %}

View File

@ -0,0 +1,23 @@
<p class="alert alert-info">
<strong>{{siteName}} is free to use, but our hosting costs are far from it</strong> &mdash; donations are what keep {{siteName}} alive, free, and fast.</strong>
<span class="donate-btns">
{% if paypalUrl != '' %}
<a class="donate-btn donate-paypal" href="{{paypalUrl}}" target="_BLANK">
<span class="icon icon-paypal"></span>
PayPal
</a>
{% endif %}
{% if bitcoinAddress != '' %}
<a class="donate-btn donate-bitcoin" href="bitcoin:{{bitcoinAddress}}?label={{siteName}}&amp;message=Hosting%20Costs" target="_BLANK">
<span class="icon icon-bitcoin"></span>
Bitcoin
</a>
{% endif %}
{% if flattrUrl != '' %}
<a class="donate-btn donate-flattr" href="{{flattrUrl}}" target="_BLANK">
<span class="icon icon-flattr"></span>
Flattr
</a>
{% endif %}
</span>
</p>

View File

@ -0,0 +1,3 @@
<p class="alert alert-error">
<strong>Malware is not allowed</strong> &mdash; files identified as malware will be removed without further notice.
</p>

27
templates/faq.swig Normal file
View File

@ -0,0 +1,27 @@
{% extends "layout.swig" %}
{% block title %}FAQ{% endblock %}
{% block body %}
<article>
<div class="jumbotron">
<h1><abbr title="Frequently asked questions">FAQ</abbr></h1>
</div>
<div class="alert alert-info">
<h2>What is {{siteName}}?</h2>
<p><span role="definition"><dfn>{{siteName}}</dfn> is a simple to use free file hosting service.</span> It lets you share your photos, documents, music, videos and more with others online for 24 hours.</p>
<h2>What files are allowed?</h2>
<p>{{siteName}} welcomes uploading all files, as long as the file is legal in {{ServerCountryLocation}} and you have the legal right to publish the file on our service.</p>
<p>As an exception to this policy to prevent abuse, we do not allow malware on our service. Any malware that could be used to infect other computers may be removed from our service at our discretion.</p>
<h2>Can you remove my copyrighted file?</h2>
<p>Please submit your copyright takedown notice to <a href="mailto:{{abuseContact}}">{{abuseContact}}</a>. We will handle your notice within 24 hours and disable access to the infringing file after receiving a notice compliant with the Copyright Act 1968.</p>
<h2>Can you remove files that are defaming me or otherwise infringing my non-copyright rights?</h2>
<p>{{siteName}} respects takedowns for other files when accompanied with a certified {{ServerCountryLocation}} court order. If you are unable to obtain the order, a preliminary injuction or court order is typically also sufficient. Please forward the notice to <a href="mailto:{{abuseContact}}">{{abuseContact}}</a>.</p>
<h2>Can you remove illegal files?</h2>
<p>Please contact the appropriate law enforcement agency if you notice illegal files hosted on {{siteName}}. We have not been trained or qualified to investigate and fight crimes and enforce the law, so it's not appropriate to send accusations of illegal activity to us. <strong>You must contact the appropriate law enforcement office.</strong> They may then contact us if appropriate.</p>
<p>If you are an {{ServerCountryLocation}}law enforcement official and you need our assistance, please contact <a href="mailto:{{abuseContact}}">{{abuseContact}}</a>. If you are a law enforcement official from another country, we may voluntarily cooperate if the crime you are investigating would also be illegal in {{ServerCountryLocation}}.</p>
<h2>I have a question...</h2>
<p>Send us an email at <a href="mailto:{{infoContact}}">{{infoContact}}</a> and let's talk!</p>
</div>
</article>
{% include "nav.swig" %}
{% endblock %}

11
templates/index.swig Normal file
View File

@ -0,0 +1,11 @@
{% extends "layout.swig" %}
{% block body %}
<div class="jumbotron">
<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>
{% include "banners.swig" %}
{% include "nav.swig" %}
{% endblock %}

18
templates/layout.swig Normal file
View File

@ -0,0 +1,18 @@
<!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 %}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">
{% block body %}What the fuck are you doing here, <span lang="jp">baka</span>?{% endblock %}
</div>
</body>
</html>

7
templates/nav.swig Normal file
View File

@ -0,0 +1,7 @@
<nav>
<ul>
<li><a href="/">{{siteName}}</a></li>
<li><a href="tools.html">Tools</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/*;
}

64
templates/tools.swig Normal file
View File

@ -0,0 +1,64 @@
{% extends "layout.swig" %}
{% block title %}Tools{% endblock %}
{% block body %}
<div class="jumbotron"><h1>Uguu Tools</h1></div>
<div class="alert alert-info">
<section>
<h3>
To upload using curl or make a tool you can post using:
<br/>
curl -i -F files[]=@yourfile.jpeg {{siteUrl}}/upload.php (JSON Response)
</h3>
<p>{{ToolsDesc}}</p>
<section>
<h2>ShareX</h2>
<dl>
<dt>Download</dt>
<dd><a href="https://getsharex.com">https://getsharex.com</a></dd>
<dt>Source</dt>
<dd><a href="https://github.com/ShareX/ShareX">https://github.com/ShareX/ShareX</a></dd>
</dl>
</section>
<h2>uguuecho</h2>
<dl>
<dt>Download</dt>
<dd><a href="https://git.teknik.io/nekunekus/uguucho">https://git.teknik.io/nekunekus/uguucho</a></dd>
</dl>
</section>
<h2>pomfload</h2>
<dl>
<dt>Download</dt>
<dd><a href="https://github.com/ewhal/pomfload">https://github.com/ewhal/pomfload</a></dd>
</dl>
</section>
<section>
<h2>Pomfshare</h2>
<dl>
<dt>Download</dt>
<dd><a
href="https://github.com/Nyubis/Pomfshare">https://github.com/Nyubis/Pomfshare</a></dd>
</dl>
</section>
<section>
<h2>Pomf Rehost</h2>
<dl>
<dt>Download</dt>
<dd>
<a href="https://git.fuwafuwa.moe/lesderid/pomf-rehost">
https://git.fuwafuwa.moe/lesderid/pomf-rehost
</a>
</dd>
</dl>
</div>
</section>
{% include "nav.swig" %}
{% endblock %}

View File

@ -0,0 +1,6 @@
<form id="upload-form" enctype="multipart/form-data" method="post" action="upload.php?output=html">
<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>
<ul id="upload-filelist"></ul>