mirror of
https://github.com/nokonoko/Uguu.git
synced 2024-01-06 13:35:15 +00:00
v1.8.0
This commit is contained in:
parent
cec9e06e62
commit
f0210517c5
14
Makefile
Normal file → Executable file
14
Makefile
Normal file → Executable file
@ -23,18 +23,18 @@ CONTAINER_NAME = "$(CONTAINER_NAME)"
|
||||
pageList = $(shell $(CURDIR)/$(NODEJQ) -r ".pages[]" $(CURDIR)/$(CONF))
|
||||
noExt = $(shell echo $(i) | cut -d '.' -f1)
|
||||
|
||||
all: builddirs npm_dependencies ejs "node_modules/minify/bin/minify.js"-all copy-img copy-php
|
||||
all: builddirs npm_dependencies ejs minify copy-img copy-php
|
||||
|
||||
ejs:
|
||||
$(foreach i,$(pageList), \
|
||||
"node_modules/ejs/bin/cli.js" -f $(CURDIR)/$(CONF) $(CURDIR)/src/templates/$(i) -o $(CURDIR)/build/html/unmin/$(noExt).html;)
|
||||
|
||||
"node_modules/minify/bin/minify.js"-all:
|
||||
"node_modules/minify/bin/minify.js" $(CURDIR)/src/static/js/uguu.js > $(CURDIR)/build/js/uguu.min.js
|
||||
"node_modules/minify/bin/minify.js" $(CURDIR)/src/static/css/uguu.css > $(CURDIR)/build/css/uguu.min.css
|
||||
"node_modules/minify/bin/minify.js" $(CURDIR)/build/html/unmin/faq.html > $(CURDIR)/build/html/min/faq.html
|
||||
"node_modules/minify/bin/minify.js" $(CURDIR)/build/html/unmin/tools.html > $(CURDIR)/build/html/min/tools.html
|
||||
"node_modules/minify/bin/minify.js" $(CURDIR)/build/html/unmin/index.html > $(CURDIR)/build/html/min/index.html
|
||||
minify:
|
||||
node-minify --compressor uglify-es --input $(CURDIR)/src/static/js/uguu.js --output $(CURDIR)/build/js/uguu.min.js
|
||||
node-minify --compressor cssnano --input $(CURDIR)/src/static/css/uguu.css --output $(CURDIR)/build/css/uguu.min.css
|
||||
node-minify --compressor html-minifier --input $(CURDIR)/build/html/unmin/faq.html --output $(CURDIR)/build/html/min/faq.html
|
||||
node-minify --compressor html-minifier --input $(CURDIR)/build/html/unmin/api.html --output $(CURDIR)/build/html/min/api.html
|
||||
node-minify --compressor html-minifier --input $(CURDIR)/build/html/unmin/index.html --output $(CURDIR)/build/html/min/index.html
|
||||
|
||||
installdirs:
|
||||
mkdir -p $(DESTDIR)/ $(DESTDIR)/img
|
||||
|
4
README.md
Normal file → Executable file
4
README.md
Normal file → Executable file
@ -29,9 +29,9 @@ See the real world site at [uguu.se](https://uguu.se). (down right now)
|
||||
|
||||
## Requirements
|
||||
|
||||
Tested and working with Nginx + PHP-8.1 + SQLite/MySQL/PostgreSQL + NodeJS 18 or higher.
|
||||
Tested and working with Nginx + PHP-8.1 + SQLite/MySQL/PostgreSQL + Node.js 18 or higher.
|
||||
|
||||
Node is used to compile Uguu, after that it runs on PHP.
|
||||
Node.js is used to compile Uguu, after that it runs on PHP.
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -1,96 +0,0 @@
|
||||
FROM --platform=linux/amd64 debian:bullseye-slim
|
||||
|
||||
# Install needed software
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 curl cron socat
|
||||
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
|
||||
RUN curl -fsSL https://packages.sury.org/php/apt.gpg| gpg --dearmor -o /etc/apt/trusted.gpg.d/sury-keyring.gpg
|
||||
RUN apt-get update
|
||||
RUN apt-get upgrade -y
|
||||
RUN curl -o nodejssetup.sh https://deb.nodesource.com/setup_19.x
|
||||
RUN chmod a+x nodejssetup.sh
|
||||
RUN ./nodejssetup.sh
|
||||
RUN apt-get install -y nodejs gcc g++ make
|
||||
RUN apt-get install -y build-essential nginx-full php8.1-fpm php8.1 sqlite3 php8.1-sqlite3 \
|
||||
php8.1-curl php8.1-cli php8.1-lz4 php8.1-pgsql \
|
||||
php8.1-mcrypt php8.1-mysql php8.1-xdebug php8.1-zip \
|
||||
php8.1-common php8.1-readline php8.1-bcmath php8.1-common php8.1-xml
|
||||
|
||||
# Set ENV values for configuration
|
||||
ARG DOMAIN
|
||||
ENV DOMAIN=$DOMAIN
|
||||
|
||||
ARG FILE_DOMAIN
|
||||
ENV FILE_DOMAIN=$FILE_DOMAIN
|
||||
|
||||
ARG CONTACT_EMAIL
|
||||
ENV CONTACT_EMAIL=$CONTACT_EMAIL
|
||||
|
||||
ARG MAX_SIZE
|
||||
ENV MAX_SIZE=$MAX_SIZE
|
||||
|
||||
ARG EXPIRE_TIME
|
||||
ENV EXPIRE_TIME=$EXPIRE_TIME
|
||||
|
||||
# Set default workdir
|
||||
WORKDIR /var/www/
|
||||
|
||||
COPY docker/docker-entrypoint.sh .
|
||||
|
||||
# Decompress into Docker
|
||||
COPY docker/uguuForDocker.tar.gz /var/www/
|
||||
RUN mkdir /var/www/uguu
|
||||
RUN tar -xvf uguuForDocker.tar.gz -C uguu
|
||||
|
||||
# Create the needed directories
|
||||
RUN mkdir /var/www/files && \
|
||||
mkdir /var/www/db
|
||||
|
||||
# Create the Sqlite DB
|
||||
RUN sqlite3 /var/www/db/uguu.sq3 -init /var/www/uguu/src/static/dbSchemas/sqlite_schema.sql "" && \
|
||||
chown -R www-data:www-data /var/www && \
|
||||
chmod -R 775 /var/www/
|
||||
|
||||
# Add scripts to cron
|
||||
RUN echo "0,30 * * * * bash /var/www/uguu/src/static/scripts/checkfiles.sh" >> /var/spool/cron/crontabs/www-data && \
|
||||
echo "0,30 * * * * bash /var/www/uguu/src/static/scripts/checkdb.sh" >> /var/spool/cron/crontabs/www-data
|
||||
|
||||
# Fix script paths
|
||||
RUN chmod a+x /var/www/uguu/src/static/scripts/checkdb.sh && \
|
||||
chmod a+x /var/www/uguu/src/static/scripts/checkfiles.sh && \
|
||||
sed -i 's#/path/to/files/#/var/www/uguu/files/#g' /var/www/uguu/src/static/scripts/checkfiles.sh && \
|
||||
sed -i 's#/path/to/db/uguu.sq3#/var/www/db/uguu.sq3#g' /var/www/uguu/src/static/scripts/checkdb.sh
|
||||
|
||||
# Copy Nginx Server conf
|
||||
COPY docker/nginx/uguu.conf /etc/nginx/sites-enabled/uguu.conf
|
||||
COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
|
||||
# Modify expire time
|
||||
RUN sed -i "s#XXX#${EXPIRE_TIME}#g" /var/www/uguu/src/static/scripts/checkfiles.sh
|
||||
RUN sed -i "s#XXX#${EXPIRE_TIME}#g" /var/www/uguu/src/static/scripts/checkdb.sh
|
||||
|
||||
# Modify nginx values
|
||||
RUN sed -i "s#XMAINDOMAINX#${DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf
|
||||
RUN sed -i "s#XFILESDOMAINX#${FILE_DOMAIN}#g" /etc/nginx/sites-enabled/uguu.conf
|
||||
RUN sed -i "s#client_max_body_size 128M#client_max_body_size ${MAX_SIZE}M#g" /etc/nginx/nginx.conf
|
||||
|
||||
# Modify php-fpm values
|
||||
RUN sed -i "s#post_max_size = 8M#post_max_size = ${MAX_SIZE}M#g" /etc/php/8.1/fpm/php.ini
|
||||
RUN sed -i "s#upload_max_filesize = 2M#upload_max_filesize = ${MAX_SIZE}M#g" /etc/php/8.1/fpm/php.ini
|
||||
|
||||
# Copy Uguu config
|
||||
COPY src/config.json /var/www/uguu/config.json
|
||||
|
||||
# Expose port 80 from the container
|
||||
EXPOSE 80
|
||||
|
||||
# Expose port 443 from the container
|
||||
EXPOSE 443
|
||||
|
||||
# Install acme.sh
|
||||
RUN curl -o acmeinstall.sh https://get.acme.sh
|
||||
RUN chmod a+x acmeinstall.sh
|
||||
RUN ./acmeinstall.sh
|
||||
|
||||
# Load entrypoint
|
||||
ENTRYPOINT [ "bash", "/var/www/docker-entrypoint.sh" ]
|
@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
cd /var/www/uguu || exit
|
||||
npm install
|
||||
make
|
||||
make install
|
||||
service nginx stop
|
||||
rm /etc/nginx/sites-enabled/default
|
||||
/root/.acme.sh/acme.sh --set-default-ca --server letsencrypt
|
||||
/root/.acme.sh/acme.sh --issue --standalone -d "$DOMAIN" -d "$FILE_DOMAIN"
|
||||
service nginx start
|
||||
service php8.1-fpm start
|
||||
tail -f /dev/null
|
@ -1,62 +0,0 @@
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 4096;
|
||||
multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
types_hash_max_size 2048;
|
||||
client_max_body_size 128M;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log off;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name XMAINDOMAINX;
|
||||
|
||||
ssl on;
|
||||
ssl_certificate /root/.acme.sh/XMAINDOMAINX_ecc/fullchain.cer;
|
||||
ssl_certificate_key /root/.acme.sh/XMAINDOMAINX_ecc/XMAINDOMAINX.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
|
||||
ssl_ecdh_curve secp384r1;
|
||||
|
||||
root /var/www/uguu/dist/public/;
|
||||
autoindex off;
|
||||
access_log off;
|
||||
index index.html;
|
||||
|
||||
location ~* \.(css|js|jpg|jpeg|gif|png|ico|xml|eot|woff|woff2|ttf|svg|otf|x-icon|avif|webp|apng)$ {
|
||||
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/php8.1-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;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name XFILESDOMAINX;
|
||||
|
||||
ssl on;
|
||||
ssl_certificate /root/.acme.sh/XMAINDOMAINX_ecc/fullchain.cer;
|
||||
ssl_certificate_key /root/.acme.sh/XMAINDOMAINX_ecc/XMAINDOMAINX.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
|
||||
ssl_ecdh_curve secp384r1;
|
||||
|
||||
root /var/www/files/;
|
||||
autoindex off;
|
||||
access_log off;
|
||||
index index.html;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name XMAINDOMAINX;
|
||||
return 301 https://XMAINDOMAINX$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name XFILESDOMAINX;
|
||||
return 301 https://XFILESDOMAINX$request_uri;
|
||||
}
|
1946
docker/php/php.ini
1946
docker/php/php.ini
File diff suppressed because it is too large
Load Diff
@ -1,455 +0,0 @@
|
||||
; Start a new pool named 'www'.
|
||||
; the variable $pool can be used in any directive and will be replaced by the
|
||||
; pool name ('www' here)
|
||||
[www]
|
||||
|
||||
; Per pool prefix
|
||||
; It only applies on the following directives:
|
||||
; - 'access.log'
|
||||
; - 'slowlog'
|
||||
; - 'listen' (unixsocket)
|
||||
; - 'chroot'
|
||||
; - 'chdir'
|
||||
; - 'php_values'
|
||||
; - 'php_admin_values'
|
||||
; When not set, the global prefix (or /usr) applies instead.
|
||||
; Note: This directive can also be relative to the global prefix.
|
||||
; Default Value: none
|
||||
;prefix = /path/to/pools/$pool
|
||||
|
||||
; Unix user/group of processes
|
||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||
; will be used.
|
||||
user = nobody
|
||||
group = nobody
|
||||
|
||||
; The address on which to accept FastCGI requests.
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Note: This value is mandatory.
|
||||
listen = /var/run/php/php8.0-fpm.sock
|
||||
|
||||
; Set listen(2) backlog.
|
||||
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
|
||||
;listen.backlog = 511
|
||||
|
||||
; Set permissions for unix socket, if one is used. In Linux, read/write
|
||||
; permissions must be set in order to allow connections from a web server. Many
|
||||
; BSD-derived systems allow connections regardless of permissions. The owner
|
||||
; and group can be specified either by name or by their numeric IDs.
|
||||
; Default Values: user and group are set as the running user
|
||||
; mode is set to 0660
|
||||
;listen.owner = nobody
|
||||
;listen.group = nobody
|
||||
;listen.mode = 0660
|
||||
; When POSIX Access Control Lists are supported you can set them using
|
||||
; these options, value is a comma separated list of user/group names.
|
||||
; When set, listen.owner and listen.group are ignored
|
||||
;listen.acl_users =
|
||||
;listen.acl_groups =
|
||||
|
||||
; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
|
||||
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
|
||||
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
|
||||
; must be separated by a comma. If this value is left blank, connections will be
|
||||
; accepted from any ip address.
|
||||
; Default Value: any
|
||||
;listen.allowed_clients = 127.0.0.1
|
||||
|
||||
; Specify the nice(2) priority to apply to the pool processes (only if set)
|
||||
; The value can vary from -19 (highest priority) to 20 (lower priority)
|
||||
; Note: - It will only work if the FPM master process is launched as root
|
||||
; - The pool processes will inherit the master process priority
|
||||
; unless it specified otherwise
|
||||
; Default Value: no set
|
||||
; process.priority = -19
|
||||
|
||||
; Set the process dumpable flag (PR_SET_DUMPABLE prctl) even if the process user
|
||||
; or group is different than the master process user. It allows to create process
|
||||
; core dump and ptrace the process for the pool user.
|
||||
; Default Value: no
|
||||
; process.dumpable = yes
|
||||
|
||||
; Choose how the process manager will control the number of child processes.
|
||||
; Possible Values:
|
||||
; static - a fixed number (pm.max_children) of child processes;
|
||||
; dynamic - the number of child processes are set dynamically based on the
|
||||
; following directives. With this process management, there will be
|
||||
; always at least 1 children.
|
||||
; pm.max_children - the maximum number of children that can
|
||||
; be alive at the same time.
|
||||
; pm.start_servers - the number of children created on startup.
|
||||
; pm.min_spare_servers - the minimum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is less than this
|
||||
; number then some children will be created.
|
||||
; pm.max_spare_servers - the maximum number of children in 'idle'
|
||||
; state (waiting to process). If the number
|
||||
; of 'idle' processes is greater than this
|
||||
; number then some children will be killed.
|
||||
; ondemand - no children are created at startup. Children will be forked when
|
||||
; new requests will connect. The following parameter are used:
|
||||
; pm.max_children - the maximum number of children that
|
||||
; can be alive at the same time.
|
||||
; pm.process_idle_timeout - The number of seconds after which
|
||||
; an idle process will be killed.
|
||||
; Note: This value is mandatory.
|
||||
pm = dynamic
|
||||
|
||||
; The number of child processes to be created when pm is set to 'static' and the
|
||||
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
|
||||
; This value sets the limit on the number of simultaneous requests that will be
|
||||
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
|
||||
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
|
||||
; CGI. The below defaults are based on a server without much resources. Don't
|
||||
; forget to tweak pm.* to fit your needs.
|
||||
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
|
||||
; Note: This value is mandatory.
|
||||
pm.max_children = 5
|
||||
|
||||
; The number of child processes created on startup.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Default Value: (min_spare_servers + max_spare_servers) / 2
|
||||
pm.start_servers = 2
|
||||
|
||||
; The desired minimum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.min_spare_servers = 1
|
||||
|
||||
; The desired maximum number of idle server processes.
|
||||
; Note: Used only when pm is set to 'dynamic'
|
||||
; Note: Mandatory when pm is set to 'dynamic'
|
||||
pm.max_spare_servers = 3
|
||||
|
||||
; The number of seconds after which an idle process will be killed.
|
||||
; Note: Used only when pm is set to 'ondemand'
|
||||
; Default Value: 10s
|
||||
;pm.process_idle_timeout = 10s;
|
||||
|
||||
; The number of requests each child process should execute before respawning.
|
||||
; This can be useful to work around memory leaks in 3rd party libraries. For
|
||||
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
|
||||
; Default Value: 0
|
||||
;pm.max_requests = 500
|
||||
|
||||
; The URI to view the FPM status page. If this value is not set, no URI will be
|
||||
; recognized as a status page. It shows the following information:
|
||||
; pool - the name of the pool;
|
||||
; process manager - static, dynamic or ondemand;
|
||||
; start time - the date and time FPM has started;
|
||||
; start since - number of seconds since FPM has started;
|
||||
; accepted conn - the number of request accepted by the pool;
|
||||
; listen queue - the number of request in the queue of pending
|
||||
; connections (see backlog in listen(2));
|
||||
; max listen queue - the maximum number of requests in the queue
|
||||
; of pending connections since FPM has started;
|
||||
; listen queue len - the size of the socket queue of pending connections;
|
||||
; idle processes - the number of idle processes;
|
||||
; active processes - the number of active processes;
|
||||
; total processes - the number of idle + active processes;
|
||||
; max active processes - the maximum number of active processes since FPM
|
||||
; has started;
|
||||
; max children reached - number of times, the process limit has been reached,
|
||||
; when pm tries to start more children (works only for
|
||||
; pm 'dynamic' and 'ondemand');
|
||||
; Value are updated in real time.
|
||||
; Example output:
|
||||
; pool: www
|
||||
; process manager: static
|
||||
; start time: 01/Jul/2011:17:53:49 +0200
|
||||
; start since: 62636
|
||||
; accepted conn: 190460
|
||||
; listen queue: 0
|
||||
; max listen queue: 1
|
||||
; listen queue len: 42
|
||||
; idle processes: 4
|
||||
; active processes: 11
|
||||
; total processes: 15
|
||||
; max active processes: 12
|
||||
; max children reached: 0
|
||||
;
|
||||
; By default the status page output is formatted as text/plain. Passing either
|
||||
; 'html', 'xml' or 'json' in the query string will return the corresponding
|
||||
; output syntax. Example:
|
||||
; http://www.foo.bar/status
|
||||
; http://www.foo.bar/status?json
|
||||
; http://www.foo.bar/status?html
|
||||
; http://www.foo.bar/status?xml
|
||||
;
|
||||
; By default the status page only outputs short status. Passing 'full' in the
|
||||
; query string will also return status for each pool process.
|
||||
; Example:
|
||||
; http://www.foo.bar/status?full
|
||||
; http://www.foo.bar/status?json&full
|
||||
; http://www.foo.bar/status?html&full
|
||||
; http://www.foo.bar/status?xml&full
|
||||
; The Full status returns for each process:
|
||||
; pid - the PID of the process;
|
||||
; state - the state of the process (Idle, Running, ...);
|
||||
; start time - the date and time the process has started;
|
||||
; start since - the number of seconds since the process has started;
|
||||
; requests - the number of requests the process has served;
|
||||
; request duration - the duration in µs of the requests;
|
||||
; request method - the request method (GET, POST, ...);
|
||||
; request URI - the request URI with the query string;
|
||||
; content length - the content length of the request (only with POST);
|
||||
; user - the user (PHP_AUTH_USER) (or '-' if not set);
|
||||
; script - the main script called (or '-' if not set);
|
||||
; last request cpu - the %cpu the last request consumed
|
||||
; it's always 0 if the process is not in Idle state
|
||||
; because CPU calculation is done when the request
|
||||
; processing has terminated;
|
||||
; last request memory - the max amount of memory the last request consumed
|
||||
; it's always 0 if the process is not in Idle state
|
||||
; because memory calculation is done when the request
|
||||
; processing has terminated;
|
||||
; If the process is in Idle state, then informations are related to the
|
||||
; last request the process has served. Otherwise informations are related to
|
||||
; the current request being served.
|
||||
; Example output:
|
||||
; ************************
|
||||
; pid: 31330
|
||||
; state: Running
|
||||
; start time: 01/Jul/2011:17:53:49 +0200
|
||||
; start since: 63087
|
||||
; requests: 12808
|
||||
; request duration: 1250261
|
||||
; request method: GET
|
||||
; request URI: /test_mem.php?N=10000
|
||||
; content length: 0
|
||||
; user: -
|
||||
; script: /home/fat/web/docs/php/test_mem.php
|
||||
; last request cpu: 0.00
|
||||
; last request memory: 0
|
||||
;
|
||||
; Note: There is a real-time FPM status monitoring sample web page available
|
||||
; It's available in: /usr/share/php8/fpm/status.html
|
||||
;
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;pm.status_path = /status
|
||||
|
||||
; The address on which to accept FastCGI status request. This creates a new
|
||||
; invisible pool that can handle requests independently. This is useful
|
||||
; if the main pool is busy with long running requests because it is still possible
|
||||
; to get the status before finishing the long running requests.
|
||||
;
|
||||
; Valid syntaxes are:
|
||||
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
|
||||
; a specific port;
|
||||
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
|
||||
; a specific port;
|
||||
; 'port' - to listen on a TCP socket to all addresses
|
||||
; (IPv6 and IPv4-mapped) on a specific port;
|
||||
; '/path/to/unix/socket' - to listen on a unix socket.
|
||||
; Default Value: value of the listen option
|
||||
;pm.status_listen = 127.0.0.1:9001
|
||||
|
||||
; The ping URI to call the monitoring page of FPM. If this value is not set, no
|
||||
; URI will be recognized as a ping page. This could be used to test from outside
|
||||
; that FPM is alive and responding, or to
|
||||
; - create a graph of FPM availability (rrd or such);
|
||||
; - remove a server from a group if it is not responding (load balancing);
|
||||
; - trigger alerts for the operating team (24/7).
|
||||
; Note: The value must start with a leading slash (/). The value can be
|
||||
; anything, but it may not be a good idea to use the .php extension or it
|
||||
; may conflict with a real PHP file.
|
||||
; Default Value: not set
|
||||
;ping.path = /ping
|
||||
|
||||
; This directive may be used to customize the response of a ping request. The
|
||||
; response is formatted as text/plain with a 200 response code.
|
||||
; Default Value: pong
|
||||
;ping.response = pong
|
||||
|
||||
; The access log file
|
||||
; Default: not set
|
||||
;access.log = log/php8/$pool.access.log
|
||||
|
||||
; The access log format.
|
||||
; The following syntax is allowed
|
||||
; %%: the '%' character
|
||||
; %C: %CPU used by the request
|
||||
; it can accept the following format:
|
||||
; - %{user}C for user CPU only
|
||||
; - %{system}C for system CPU only
|
||||
; - %{total}C for user + system CPU (default)
|
||||
; %d: time taken to serve the request
|
||||
; it can accept the following format:
|
||||
; - %{seconds}d (default)
|
||||
; - %{milliseconds}d
|
||||
; - %{mili}d
|
||||
; - %{microseconds}d
|
||||
; - %{micro}d
|
||||
; %e: an environment variable (same as $_ENV or $_SERVER)
|
||||
; it must be associated with embraces to specify the name of the env
|
||||
; variable. Some examples:
|
||||
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
|
||||
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
|
||||
; %f: script filename
|
||||
; %l: content-length of the request (for POST request only)
|
||||
; %m: request method
|
||||
; %M: peak of memory allocated by PHP
|
||||
; it can accept the following format:
|
||||
; - %{bytes}M (default)
|
||||
; - %{kilobytes}M
|
||||
; - %{kilo}M
|
||||
; - %{megabytes}M
|
||||
; - %{mega}M
|
||||
; %n: pool name
|
||||
; %o: output header
|
||||
; it must be associated with embraces to specify the name of the header:
|
||||
; - %{Content-Type}o
|
||||
; - %{X-Powered-By}o
|
||||
; - %{Transfert-Encoding}o
|
||||
; - ....
|
||||
; %p: PID of the child that serviced the request
|
||||
; %P: PID of the parent of the child that serviced the request
|
||||
; %q: the query string
|
||||
; %Q: the '?' character if query string exists
|
||||
; %r: the request URI (without the query string, see %q and %Q)
|
||||
; %R: remote IP address
|
||||
; %s: status (response code)
|
||||
; %t: server time the request was received
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %T: time the log has been written (the request has finished)
|
||||
; it can accept a strftime(3) format:
|
||||
; %d/%b/%Y:%H:%M:%S %z (default)
|
||||
; The strftime(3) format must be encapsuled in a %{<strftime_format>}t tag
|
||||
; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
|
||||
; %u: remote user
|
||||
;
|
||||
; Default: "%R - %u %t \"%m %r\" %s"
|
||||
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
|
||||
|
||||
; The log file for slow requests
|
||||
; Default Value: not set
|
||||
; Note: slowlog is mandatory if request_slowlog_timeout is set
|
||||
;slowlog = log/php8/$pool.slow.log
|
||||
|
||||
; The timeout for serving a single request after which a PHP backtrace will be
|
||||
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
;request_slowlog_timeout = 0
|
||||
|
||||
; Depth of slow log stack trace.
|
||||
; Default Value: 20
|
||||
;request_slowlog_trace_depth = 20
|
||||
|
||||
; The timeout for serving a single request after which the worker process will
|
||||
; be killed. This option should be used when the 'max_execution_time' ini option
|
||||
; does not stop script execution for some reason. A value of '0' means 'off'.
|
||||
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
|
||||
; Default Value: 0
|
||||
;request_terminate_timeout = 0
|
||||
|
||||
; The timeout set by 'request_terminate_timeout' ini option is not engaged after
|
||||
; application calls 'fastcgi_finish_request' or when application has finished and
|
||||
; shutdown functions are being called (registered via register_shutdown_function).
|
||||
; This option will enable timeout limit to be applied unconditionally
|
||||
; even in such cases.
|
||||
; Default Value: no
|
||||
;request_terminate_timeout_track_finished = no
|
||||
|
||||
; Set open file descriptor rlimit.
|
||||
; Default Value: system defined value
|
||||
;rlimit_files = 1024
|
||||
|
||||
; Set max core size rlimit.
|
||||
; Possible Values: 'unlimited' or an integer greater or equal to 0
|
||||
; Default Value: system defined value
|
||||
;rlimit_core = 0
|
||||
|
||||
; Chroot to this directory at the start. This value must be defined as an
|
||||
; absolute path. When this value is not set, chroot is not used.
|
||||
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
|
||||
; of its subdirectories. If the pool prefix is not set, the global prefix
|
||||
; will be used instead.
|
||||
; Note: chrooting is a great security feature and should be used whenever
|
||||
; possible. However, all PHP paths will be relative to the chroot
|
||||
; (error_log, sessions.save_path, ...).
|
||||
; Default Value: not set
|
||||
;chroot =
|
||||
|
||||
; Chdir to this directory at the start.
|
||||
; Note: relative path can be used.
|
||||
; Default Value: current directory or / when chroot
|
||||
;chdir = /var/www
|
||||
|
||||
; Redirect worker stdout and stderr into main error log. If not set, stdout and
|
||||
; stderr will be redirected to /dev/null according to FastCGI specs.
|
||||
; Note: on highloaded environment, this can cause some delay in the page
|
||||
; process time (several ms).
|
||||
; Default Value: no
|
||||
;catch_workers_output = yes
|
||||
|
||||
; Decorate worker output with prefix and suffix containing information about
|
||||
; the child that writes to the log and if stdout or stderr is used as well as
|
||||
; log level and time. This options is used only if catch_workers_output is yes.
|
||||
; Settings to "no" will output data as written to the stdout or stderr.
|
||||
; Default value: yes
|
||||
;decorate_workers_output = no
|
||||
|
||||
; Clear environment in FPM workers
|
||||
; Prevents arbitrary environment variables from reaching FPM worker processes
|
||||
; by clearing the environment in workers before env vars specified in this
|
||||
; pool configuration are added.
|
||||
; Setting to "no" will make all environment variables available to PHP code
|
||||
; via getenv(), $_ENV and $_SERVER.
|
||||
; Default Value: yes
|
||||
;clear_env = no
|
||||
|
||||
; Limits the extensions of the main script FPM will allow to parse. This can
|
||||
; prevent configuration mistakes on the web server side. You should only limit
|
||||
; FPM to .php extensions to prevent malicious users to use other extensions to
|
||||
; execute php code.
|
||||
; Note: set an empty value to allow all extensions.
|
||||
; Default Value: .php
|
||||
;security.limit_extensions = .php .php3 .php4 .php5 .php7
|
||||
|
||||
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
|
||||
; the current environment.
|
||||
; Default Value: clean env
|
||||
;env[HOSTNAME] = $HOSTNAME
|
||||
;env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
;env[TMP] = /tmp
|
||||
;env[TMPDIR] = /tmp
|
||||
;env[TEMP] = /tmp
|
||||
|
||||
; Additional php.ini defines, specific to this pool of workers. These settings
|
||||
; overwrite the values previously defined in the php.ini. The directives are the
|
||||
; same as the PHP SAPI:
|
||||
; php_value/php_flag - you can set classic ini defines which can
|
||||
; be overwritten from PHP call 'ini_set'.
|
||||
; php_admin_value/php_admin_flag - these directives won't be overwritten by
|
||||
; PHP call 'ini_set'
|
||||
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
|
||||
|
||||
; Defining 'extension' will load the corresponding shared extension from
|
||||
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
|
||||
; overwrite previously defined php.ini values, but will append the new value
|
||||
; instead.
|
||||
|
||||
; Note: path INI options can be relative and will be expanded with the prefix
|
||||
; (pool, global or /usr)
|
||||
|
||||
; Default Value: nothing is defined by default except the values in php.ini and
|
||||
; specified at startup with the -d argument
|
||||
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
|
||||
;php_flag[display_errors] = off
|
||||
;php_admin_value[error_log] = /var/log/php8/$pool.error.log
|
||||
;php_admin_flag[log_errors] = on
|
||||
;php_admin_value[memory_limit] = 32M
|
12
package.json
Normal file → Executable file
12
package.json
Normal file → Executable file
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "uguu",
|
||||
"version": "1.7.6",
|
||||
"version": "1.8.0",
|
||||
"description": "Uguu is a simple lightweight temporary file host with support for drop, paste, click and API uploading.",
|
||||
"homepage": "https://uguu.se",
|
||||
"repository": {
|
||||
@ -17,10 +17,14 @@
|
||||
"url": "https://github.com/nokonoko/uguu/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"minify": "^10.3.0",
|
||||
"ejs": "^3.1.9",
|
||||
"node-jq": "^4.0.1",
|
||||
"imagemin-cli": "^7.0.0",
|
||||
"imagemin-pngquant": "^9.0.2"
|
||||
"imagemin-pngquant": "^9.0.2",
|
||||
"@node-minify/core": "^8.0.6",
|
||||
"@node-minify/cli": "^8.0.6",
|
||||
"@node-minify/uglify-es": "^8.0.6",
|
||||
"@node-minify/cssnano": "^8.0.6",
|
||||
"@node-minify/html-minifier": "^8.0.6",
|
||||
"node-jq": "^4.0.1"
|
||||
}
|
||||
}
|
||||
|
0
src/Classes/Connector.php
Normal file → Executable file
0
src/Classes/Connector.php
Normal file → Executable file
0
src/Classes/CuteGrills.php
Normal file → Executable file
0
src/Classes/CuteGrills.php
Normal file → Executable file
1
src/Classes/Database.php
Normal file → Executable file
1
src/Classes/Database.php
Normal file → Executable file
@ -172,4 +172,5 @@
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
0
src/Classes/GrillLoader.php
Normal file → Executable file
0
src/Classes/GrillLoader.php
Normal file → Executable file
0
src/Classes/Response.php
Normal file → Executable file
0
src/Classes/Response.php
Normal file → Executable file
0
src/Classes/Upload.php
Normal file → Executable file
0
src/Classes/Upload.php
Normal file → Executable file
87
src/Classes/expireChecker.php
Executable file
87
src/Classes/expireChecker.php
Executable file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Pomf\Uguu\Classes;
|
||||
use PDO;
|
||||
class expireChecker
|
||||
{
|
||||
public PDO $DB;
|
||||
public string $dbType;
|
||||
public array $CONFIG;
|
||||
public string $timeUnit;
|
||||
|
||||
public function checkDB(): bool | array {
|
||||
if(is_int($this->CONFIG['expireTime'])) {
|
||||
$this->timeUnit = strtoupper($this->CONFIG['expireTimeUnit']);
|
||||
if(!in_array($this->timeUnit, ['SECONDS', 'MINUTES', 'HOURS', 'DAYS', 'WEEKS', 'MONTHS', 'YEARS'])){
|
||||
$this->timeUnit = "HOURS";
|
||||
}
|
||||
$query = match ($this->dbType) {
|
||||
'pgsql' => 'SELECT id, filename FROM files WHERE date < EXTRACT(epoch from NOW() - INTERVAL \'' . $this->CONFIG['expireTime'] . ' ' . $this->timeUnit . '\')',
|
||||
default => 'SELECT id, filename FROM files WHERE date <= strftime(\'%s\', datetime(\'now\', \'-' . $this->CONFIG['expireTime'] . ' ' . $this->timeUnit . '\'));'
|
||||
};
|
||||
$q = $this->DB->prepare($query);
|
||||
$q->execute();
|
||||
$result = $q->fetchAll(PDO::FETCH_ASSOC);
|
||||
$q->closeCursor();
|
||||
$returnArray = [
|
||||
'ids' => [],
|
||||
'filenames' => []
|
||||
];
|
||||
foreach ($result as $array){
|
||||
$returnArray['ids'][] = $array['id'];
|
||||
$returnArray['filenames'][] = $array['filename'];
|
||||
}
|
||||
return $returnArray;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFiles(array $filenames): void {
|
||||
foreach ($filenames as $filename) {
|
||||
unlink($this->CONFIG['FILES_ROOT'] . $filename);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteFromDB(array $ids): void {
|
||||
foreach ($ids as $id) {
|
||||
$query = match ($this->dbType) {
|
||||
'pgsql' => 'DELETE FROM files WHERE id = (:id)',
|
||||
default => 'DELETE FROM files WHERE id = (:id)'
|
||||
};
|
||||
$q = $this->DB->prepare($query);
|
||||
$q->bindValue(':id', $id);
|
||||
$q->execute();
|
||||
$q->closeCursor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the config.json file and populates the CONFIG property with the settings
|
||||
* Also assembles the PDO DB connection and registers error handlers.
|
||||
*
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->response = new Response('json');
|
||||
if (!file_exists(__DIR__ . '/../config.json')) {
|
||||
$this->response->error(500, 'Cant read settings file.');
|
||||
}
|
||||
$this->CONFIG = json_decode(
|
||||
file_get_contents(__DIR__ . '/../config.json'),
|
||||
true,
|
||||
);
|
||||
ini_set('display_errors', 0);
|
||||
$this->dbType = $this->CONFIG['DB_MODE'];
|
||||
$this->DB = new PDO(
|
||||
$this->CONFIG['DB_MODE'] . ':' . $this->CONFIG['DB_PATH'],
|
||||
$this->CONFIG['DB_USER'],
|
||||
$this->CONFIG['DB_PASS']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
0
src/composer.json
Normal file → Executable file
0
src/composer.json
Normal file → Executable file
@ -1,26 +1,24 @@
|
||||
{
|
||||
"init": {
|
||||
"allowErrors": false
|
||||
},
|
||||
"dest": "dist",
|
||||
"pkgVersion": "1.7.6",
|
||||
"pkgVersion": "1.8.0",
|
||||
"pages": [
|
||||
"index.ejs",
|
||||
"faq.ejs",
|
||||
"tools.ejs"
|
||||
"api.ejs"
|
||||
],
|
||||
"DEBUG": false,
|
||||
"DEBUG": true,
|
||||
"max_upload_size": 128,
|
||||
"expireTime": "48",
|
||||
"expireTime": 8,
|
||||
"expireTimeUnit": "hours",
|
||||
"siteName": "Uguu",
|
||||
"subTitle": "wahooo",
|
||||
"DOMAIN": "domain.com",
|
||||
"FILE_DOMAIN": "files.domain.com",
|
||||
"abuseContact": "abuse@example.com",
|
||||
"infoContact": "info@example.com",
|
||||
"subTitle": "Temporary file hosting",
|
||||
"DOMAIN": "dev.uguu.se",
|
||||
"FILE_DOMAIN": "files.dev.uguu.se",
|
||||
"abuseContact": "abuse@email.com",
|
||||
"infoContact": "info@email.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.",
|
||||
"SiteMetaInfo": "Uguu is a temporary file hosting service!",
|
||||
"showGithub": true,
|
||||
"donationBanner": false,
|
||||
"paypalUrl": "",
|
||||
"bitcoinAddress": "",
|
||||
@ -33,9 +31,9 @@
|
||||
"DB_PASS": "NULL",
|
||||
"LOG_IP": false,
|
||||
"ANTI_DUPE": false,
|
||||
"BLACKLIST_DB": true,
|
||||
"BLACKLIST_DB": false,
|
||||
"FILTER_MODE": true,
|
||||
"RATE_LIMIT": false,
|
||||
"RATE_LIMIT": true,
|
||||
"RATE_LIMIT_TIMEOUT": 60,
|
||||
"RATE_LIMIT_FILES": 100,
|
||||
"FILES_ROOT": "/var/www/files/",
|
||||
|
0
src/static/css/uguu.css
Normal file → Executable file
0
src/static/css/uguu.css
Normal file → Executable file
0
src/static/dbSchemas/mysql_schema.sql
Normal file → Executable file
0
src/static/dbSchemas/mysql_schema.sql
Normal file → Executable file
0
src/static/dbSchemas/postgres_schema.sql
Normal file → Executable file
0
src/static/dbSchemas/postgres_schema.sql
Normal file → Executable file
0
src/static/dbSchemas/sqlite_schema.sql
Normal file → Executable file
0
src/static/dbSchemas/sqlite_schema.sql
Normal file → Executable file
0
src/static/img/favicon-32x32.png
Normal file → Executable file
0
src/static/img/favicon-32x32.png
Normal file → Executable file
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
0
src/static/img/kofi.png
Normal file → Executable file
0
src/static/img/kofi.png
Normal file → Executable file
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
159
src/static/js/uguu.js
Normal file → Executable file
159
src/static/js/uguu.js
Normal file → Executable file
@ -17,17 +17,17 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
/**
|
||||
* Sets up the elements inside file upload rows.
|
||||
*
|
||||
* @param {File} file
|
||||
* @return {HTMLLIElement} row
|
||||
*/
|
||||
function addRow(file)
|
||||
{
|
||||
const addRow = (file) => {
|
||||
const row = document.createElement('li');
|
||||
|
||||
const name = document.createElement('span');
|
||||
name.textContent = file.name;
|
||||
name.className = 'file-name';
|
||||
@ -47,27 +47,24 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
document.getElementById('upload-filelist').appendChild(row);
|
||||
return row;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the page while the file is being uploaded.
|
||||
*
|
||||
* @param {ProgressEvent} evt
|
||||
*/
|
||||
function handleUploadProgress(evt)
|
||||
{
|
||||
let xhr = evt.target;
|
||||
let bar = xhr.bar;
|
||||
let percentIndicator = xhr.percent;
|
||||
const handleUploadProgress = (evt) => {
|
||||
const xhr = evt.target;
|
||||
const bar = xhr.bar;
|
||||
const 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) {
|
||||
let progressPercent = Math.floor((evt.loaded / evt.total) * 100);
|
||||
const progressPercent = Math.floor((evt.loaded / evt.total) * 100);
|
||||
bar.setAttribute('value', progressPercent);
|
||||
percentIndicator.textContent = progressPercent + '%';
|
||||
percentIndicator.textContent = `${progressPercent}%`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Complete the uploading process by checking the response status and, if the
|
||||
@ -76,48 +73,45 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
*
|
||||
* @param {ProgressEvent} evt
|
||||
*/
|
||||
function handleUploadComplete(evt)
|
||||
{
|
||||
let xhr = evt.target;
|
||||
let bar = xhr.bar;
|
||||
let row = xhr.row;
|
||||
let percentIndicator = xhr.percent;
|
||||
const handleUploadComplete = (evt) => {
|
||||
const xhr = evt.target;
|
||||
const bar = xhr.bar;
|
||||
const row = xhr.row;
|
||||
const percentIndicator = xhr.percent;
|
||||
|
||||
percentIndicator.style.visibility = 'hidden';
|
||||
bar.style.visibility = 'hidden';
|
||||
row.removeChild(bar);
|
||||
row.removeChild(percentIndicator);
|
||||
let respStatus = xhr.status;
|
||||
const respStatus = xhr.status;
|
||||
|
||||
let url = document.createElement('span');
|
||||
const url = document.createElement('span');
|
||||
url.className = 'file-url';
|
||||
row.appendChild(url);
|
||||
|
||||
let link = document.createElement('a');
|
||||
const link = document.createElement('a');
|
||||
if (respStatus === 200) {
|
||||
let response = JSON.parse(xhr.responseText);
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
if (response.success) {
|
||||
link.textContent = response.files[0].url.replace(/.*?:\/\//g, '');
|
||||
link.href = response.files[0].url;
|
||||
link.target = "_BLANK";
|
||||
url.appendChild(link);
|
||||
|
||||
const copy = document.createElement('button');
|
||||
copy.className = 'upload-clipboard-btn';
|
||||
|
||||
const glyph = document.createElement('img');
|
||||
glyph.src = 'img/glyphicons-512-copy.png';
|
||||
copy.appendChild(glyph);
|
||||
url.appendChild(copy);
|
||||
copy.addEventListener("click", function () {
|
||||
/* 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 */
|
||||
url.appendChild(copy);
|
||||
|
||||
copy.addEventListener("click", () => {
|
||||
const element = document.createElement('a');
|
||||
element.textContent = response.files[0].url;
|
||||
link.appendChild(element);
|
||||
let range = document.createRange();
|
||||
const range = document.createRange();
|
||||
range.selectNode(element);
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
@ -125,17 +119,17 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
link.removeChild(element);
|
||||
});
|
||||
} else {
|
||||
bar.innerHTML = 'Error: ' + response.description;
|
||||
bar.innerHTML = `Error: ${response.description}`;
|
||||
}
|
||||
} else if (respStatus === 413) {
|
||||
link.textContent = 'File too big!';
|
||||
url.appendChild(link);
|
||||
} else {
|
||||
let response = JSON.parse(xhr.responseText);
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
link.textContent = response.description;
|
||||
url.appendChild(link);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the page while the file is being uploaded.
|
||||
@ -143,26 +137,25 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
* @param {File} file
|
||||
* @param {HTMLLIElement} row
|
||||
*/
|
||||
function uploadFile(file, row)
|
||||
{
|
||||
let bar = row.querySelector('.file-progress');
|
||||
let percentIndicator = row.querySelector('.progress-percent');
|
||||
let xhr = new XMLHttpRequest();
|
||||
const uploadFile = (file, row) => {
|
||||
const bar = row.querySelector('.file-progress');
|
||||
const percentIndicator = row.querySelector('.progress-percent');
|
||||
const 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.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;
|
||||
|
||||
let form = new FormData();
|
||||
const form = new FormData();
|
||||
form.append('files[]', file);
|
||||
xhr.send(form);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Prevents the browser for allowing the normal actions associated with an event.
|
||||
@ -171,11 +164,10 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
*
|
||||
* @param {Event} evt
|
||||
*/
|
||||
function stopDefaultEvent(evt)
|
||||
{
|
||||
const stopDefaultEvent = (evt) => {
|
||||
evt.stopPropagation();
|
||||
evt.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds 1 to the state and changes the text.
|
||||
@ -184,14 +176,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
* @param {HTMLButtonElement} element
|
||||
* @param {DragEvent} evt
|
||||
*/
|
||||
function handleDrag(state, element, evt)
|
||||
{
|
||||
const 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.
|
||||
@ -200,14 +191,13 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
* @param {HTMLButtonElement} element
|
||||
* @param {DragEvent} evt
|
||||
*/
|
||||
function handleDragAway(state, element, evt)
|
||||
{
|
||||
const 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.
|
||||
@ -216,71 +206,66 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
* @param {HTMLButtonElement} element
|
||||
* @param {DragEvent} evt
|
||||
*/
|
||||
function handleDragDrop(state, element, evt)
|
||||
{
|
||||
const handleDragDrop = (state, element, evt) => {
|
||||
stopDefaultEvent(evt);
|
||||
handleDragAway(state, element, evt);
|
||||
let len = evt.dataTransfer.files.length;
|
||||
const len = evt.dataTransfer.files.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
let file = evt.dataTransfer.files[i];
|
||||
let row = addRow(file);
|
||||
const file = evt.dataTransfer.files[i];
|
||||
const 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)
|
||||
{
|
||||
let len = evt.target.files.length;
|
||||
const uploadFiles = (evt) => {
|
||||
const len = evt.target.files.length;
|
||||
// For each file, make a row, and upload the file.
|
||||
for (let i = 0; i < len; i++) {
|
||||
let file = evt.target.files[i];
|
||||
let row = addRow(file);
|
||||
const file = evt.target.files[i];
|
||||
const row = addRow(file);
|
||||
uploadFile(file, row);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens up a "Select files.." dialog window to allow users to select files to upload.
|
||||
* 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)
|
||||
{
|
||||
const selectFiles = (target, evt) => {
|
||||
stopDefaultEvent(evt);
|
||||
target.click();
|
||||
}
|
||||
};
|
||||
|
||||
/* Handles the pasting function */
|
||||
window.addEventListener("paste", e => {
|
||||
let len = e.clipboardData.files.length;
|
||||
const len = e.clipboardData.files.length;
|
||||
for (let i = 0; i < len; i++) {
|
||||
let file = e.clipboardData.files[i];
|
||||
let row = addRow(file);
|
||||
const file = e.clipboardData.files[i];
|
||||
const 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. */
|
||||
let state = {dragCount: 0};
|
||||
let 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);
|
||||
const state = {dragCount: 0};
|
||||
const uploadButton = document.getElementById('upload-btn');
|
||||
window.addEventListener('dragenter', (evt) => handleDrag(state, uploadButton, evt), false);
|
||||
window.addEventListener('dragleave', (evt) => handleDragAway(state, uploadButton, evt), false);
|
||||
window.addEventListener('drop', (evt) => handleDragAway(state, uploadButton, evt), false);
|
||||
window.addEventListener('dragover', stopDefaultEvent, false);
|
||||
|
||||
|
||||
let uploadInput = document.getElementById('upload-input');
|
||||
const 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);
|
||||
uploadButton.addEventListener('click', () => selectFiles(uploadInput, event));
|
||||
uploadButton.addEventListener('drop', (evt) => handleDragDrop(state, uploadButton, evt), false);
|
||||
document.getElementById('upload-form').classList.add('js');
|
||||
});
|
33
src/static/php/checkExpire.php
Executable file
33
src/static/php/checkExpire.php
Executable file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Uguu
|
||||
*
|
||||
* @copyright Copyright (c) 2022-2023 Go Johansson (nokonoko) <neku@pomf.se>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Pomf\Uguu\Classes\expireChecker;
|
||||
|
||||
$check = new expireChecker();
|
||||
$dbResult = $check->checkDB();
|
||||
|
||||
if(empty($dbResult['ids'])){
|
||||
echo "No file(s) expired, nothing to do.";
|
||||
} else {
|
||||
$check->deleteFromDB($dbResult['ids']);
|
||||
$check->deleteFiles($dbResult['filenames']);
|
||||
}
|
0
src/static/php/grill.php
Normal file → Executable file
0
src/static/php/grill.php
Normal file → Executable file
3
src/static/php/upload.php
Normal file → Executable file
3
src/static/php/upload.php
Normal file → Executable file
@ -39,9 +39,8 @@
|
||||
$upload->send($res);
|
||||
}
|
||||
}
|
||||
|
||||
$response = new Response('json');
|
||||
$resType = (isset($_GET['output']) and !empty($_GET['output'])) ? strtolower(preg_replace('/[^a-zA-Z]/', '', $_GET['output'])) : 'json';
|
||||
$response = new Response($resType);
|
||||
if (!isset($_FILES['files']) or empty($_FILES['files'])) {
|
||||
$response->error(400, 'No input file(s)');
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
sqlite3 /path/to/db/uguu.sq3 "DELETE FROM files WHERE date <= strftime('%s', datetime('now', '-XXX hours'));"
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
hours=$((XXX*60))
|
||||
find /path/to/files/ -mmin +$hours -exec rm -f {} \;
|
14
src/templates/api.ejs
Executable file
14
src/templates/api.ejs
Executable file
@ -0,0 +1,14 @@
|
||||
<%- include('./partials/header.ejs'); -%>
|
||||
<div class="container">
|
||||
<div class="jumbotron">
|
||||
<h1><%= siteName %> Tools</h1>
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<section>
|
||||
<p>You may POST an array of files to <b><%= DOMAIN %>/upload.php</b>, by default you will get a json response.</p>
|
||||
<p>For example using Curl: <b>curl -i -F files[]=@yourfile.jpeg <%= DOMAIN %>/upload.php</b></p>
|
||||
<p>If you want a response in something else than json you add a flag to specify what format you want, for example <b><%= DOMAIN %>/upload.php?output=csv</b>.</p>
|
||||
<p>Valid response types are: json, csv, text, html and gyazo.</p>
|
||||
</section>
|
||||
</div>
|
||||
<%- include('./partials/footer.ejs'); -%>
|
18
src/templates/faq.ejs
Normal file → Executable file
18
src/templates/faq.ejs
Normal file → Executable file
@ -8,8 +8,8 @@
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<h2>What is <%= siteName %>?</h2>
|
||||
<p><%= siteName %> is a simple to use free file hosting service where files get
|
||||
deleted after <%= expireTime %>. It lets you share your photos, documents, music, videos and more with
|
||||
<p><%= siteName %> is a simple-to-use free file hosting service where files gets
|
||||
deleted after <%= expireTime %> <%= expireTimeUnit %>. It lets you share your photos, documents, music, videos and more with
|
||||
others online.</p>
|
||||
<h2>What files are allowed?</h2>
|
||||
<p>Any kind of file is allowed, as long as the file is legal in <%= ServerCountryLocation %> and you have the legal
|
||||
@ -27,7 +27,7 @@
|
||||
<p>Downloads and visits are not tracked or logged in respect for your privacy.</p>
|
||||
<h2>Can you remove my copyrighted file?</h2>
|
||||
<p>
|
||||
Please submit your copyright takedown notice to
|
||||
Please submit your copyright takedown notice to
|
||||
<a href="mailto:<%= abuseContact %>"><%= abuseContact %></a>
|
||||
. We will
|
||||
handle your notice within <%= expireTime %> and disable access to the infringing file after receiving a notice
|
||||
@ -35,11 +35,9 @@
|
||||
</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>
|
||||
.
|
||||
<%= siteName %> respects takedowns for other files when accompanied by a certified <%= ServerCountryLocation %> court order. If
|
||||
you are unable to obtain the order, a preliminary injunction 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
|
||||
@ -47,7 +45,7 @@
|
||||
appropriate to send accusations of illegal activity to us.</p>
|
||||
<p>
|
||||
You must contact the appropriate law enforcement office. They may then contact us if appropriate.
|
||||
If you are an law enforcement official and you need our assistance, please contact
|
||||
If you are a 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
|
||||
@ -55,7 +53,7 @@
|
||||
</p>
|
||||
<h2>I have a question...</h2>
|
||||
|
||||
Send an email to
|
||||
Send an email to
|
||||
<a href="mailto:<%= infoContact %>"><%= infoContact %></a>
|
||||
.
|
||||
|
||||
|
0
src/templates/index.ejs
Normal file → Executable file
0
src/templates/index.ejs
Normal file → Executable file
0
src/templates/partials/donation_banner.ejs
Normal file → Executable file
0
src/templates/partials/donation_banner.ejs
Normal file → Executable file
0
src/templates/partials/footer.ejs
Normal file → Executable file
0
src/templates/partials/footer.ejs
Normal file → Executable file
0
src/templates/partials/header.ejs
Normal file → Executable file
0
src/templates/partials/header.ejs
Normal file → Executable file
4
src/templates/partials/lead.ejs
Normal file → Executable file
4
src/templates/partials/lead.ejs
Normal file → Executable file
@ -1,7 +1,7 @@
|
||||
<h1><%= siteName %>~</h1>
|
||||
<p class="lead">
|
||||
Max upload size is <%= max_upload_size %> MiB & files expire after <%= expireTime %>H, read the
|
||||
Max upload size is <%= max_upload_size %> MiB & files expire after <%= expireTime %> <%= expireTimeUnit %>, read the
|
||||
<a href="faq.html">
|
||||
<abbr title="Frequently asked questions">FAQ</abbr>
|
||||
</a>
|
||||
</a>.
|
||||
</p>
|
0
src/templates/partials/malware_banner.ejs
Normal file → Executable file
0
src/templates/partials/malware_banner.ejs
Normal file → Executable file
9
src/templates/partials/nav.ejs
Normal file → Executable file
9
src/templates/partials/nav.ejs
Normal file → Executable file
@ -4,10 +4,15 @@
|
||||
<a href="/"><%= siteName %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="tools.html">Tools</a>
|
||||
<a href="api.html">API</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/nokonoko/uguu">Github</a>
|
||||
<a href="faq.html">FAQ</a>
|
||||
</li>
|
||||
<% if (showGithub) { %>
|
||||
<li>
|
||||
<a href="https://github.com/nokonoko/uguu">Github</a>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</nav>
|
0
src/templates/partials/upload_form.ejs
Normal file → Executable file
0
src/templates/partials/upload_form.ejs
Normal file → Executable file
@ -1,59 +0,0 @@
|
||||
<%- include('./partials/header.ejs'); -%>
|
||||
<div class="container">
|
||||
<div class="jumbotron">
|
||||
<h1><%= siteName %> 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 <%= DOMAIN %>/upload.php (JSON Response)
|
||||
</h3>
|
||||
<p>To upload using curl or make a tool you can post using: curl -i -F files[]=@yourfile.jpeg <%= DOMAIN %>/upload.php (JSON Response)</p>
|
||||
<section>
|
||||
<h2>ShareX</h2>
|
||||
<dl>
|
||||
<dt>Download</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>
|
||||
<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>
|
||||
</section>
|
||||
</div>
|
||||
<%- include('./partials/footer.ejs'); -%>
|
Loading…
Reference in New Issue
Block a user