Merge branch 'config' into display-appeal-src-ip
4
.dockerignore
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
/local-www
|
||||||
|
**/.gitkeep
|
4
.gitignore
vendored
|
@ -55,6 +55,7 @@ php_errors.log
|
||||||
#vichan custom
|
#vichan custom
|
||||||
favicon.ico
|
favicon.ico
|
||||||
/static/spoiler.png
|
/static/spoiler.png
|
||||||
|
local-www
|
||||||
|
|
||||||
piwik/
|
piwik/
|
||||||
jwplayer/
|
jwplayer/
|
||||||
|
@ -70,8 +71,7 @@ tf/
|
||||||
/random/
|
/random/
|
||||||
|
|
||||||
# Banners
|
# Banners
|
||||||
banners/*
|
static/banners/*
|
||||||
!banners/lain-bottom.png
|
|
||||||
|
|
||||||
#Fonts
|
#Fonts
|
||||||
stylesheets/fonts
|
stylesheets/fonts
|
||||||
|
|
29
Dockerfile
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
FROM php:8.1.8-fpm
|
||||||
|
|
||||||
|
COPY . /code
|
||||||
|
|
||||||
|
RUN docker-php-ext-install pdo pdo_mysql
|
||||||
|
RUN apt-get update -y && apt-get install -y libpng-dev libjpeg-dev libonig-dev
|
||||||
|
RUN docker-php-ext-install mbstring
|
||||||
|
RUN apt-get update -y && apt-get install -y libmcrypt-dev
|
||||||
|
# RUN docker-php-ext-install -j$(nproc) mcrypt
|
||||||
|
RUN docker-php-ext-install iconv
|
||||||
|
RUN apt-get update -y && apt-get install -y imagemagick
|
||||||
|
RUN apt-get update -y && apt-get install -y graphicsmagick
|
||||||
|
RUN apt-get update -y && apt-get install -y gifsicle
|
||||||
|
# RUN docker-php-ext-configure gd
|
||||||
|
# --with-jpeg=/usr/include
|
||||||
|
# --with-png-dir=/usr \
|
||||||
|
RUN docker-php-ext-install gd
|
||||||
|
RUN apt-get update -y \
|
||||||
|
&& apt-get install -y libmemcached11 libmemcachedutil2 build-essential libmemcached-dev libz-dev git \
|
||||||
|
&& pecl install memcached \
|
||||||
|
&& echo extension=memcached.so >> /usr/local/etc/php/conf.d/memcached.ini \
|
||||||
|
&& apt-get remove -y build-essential libmemcached-dev libz-dev \
|
||||||
|
&& apt-get autoremove -y \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf /tmp/pear \
|
||||||
|
&& curl -sS https://getcomposer.org/installer -o composer-setup.php \
|
||||||
|
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
|
||||||
|
&& docker-php-ext-install bcmath \
|
||||||
|
&& cd /code && composer install
|
18
banners.php
|
@ -1,16 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
function getBannerSrc(){
|
|
||||||
$files = scandir(__dir__.'/banners/');
|
|
||||||
$files = array_diff($files, array('.', '..'));
|
|
||||||
return $files[array_rand($files)];
|
|
||||||
}
|
|
||||||
|
|
||||||
$filename = getBannerSrc();
|
$files = scandir(__dir__ . '/static/banners/', SCANDIR_SORT_NONE);
|
||||||
$filename = "banners/" . $filename;
|
$files = array_diff($files, ['.', '..']);
|
||||||
$fp = fopen($filename, 'rb');
|
|
||||||
|
|
||||||
header("Content-Type: image/png");
|
$filename = $files[array_rand($files)];
|
||||||
header("Content-Length: " . filesize($filename));
|
header("Location: /static/banners/$filename", true, 307);
|
||||||
|
header('Cache-Control: no-cache');
|
||||||
fpassthru($fp);
|
|
||||||
?>
|
|
||||||
|
|
|
@ -5,17 +5,17 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./docker/nginx/Dockerfile
|
dockerfile: ./docker/nginx/Dockerfile
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "9091:80"
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
- leftypol-db
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/code
|
- ./local-www:/var/www/html
|
||||||
- ./docker/nginx/leftypol.conf:/etc/nginx/conf.d/default.conf
|
- ./docker/nginx/leftypol.conf:/etc/nginx/conf.d/default.conf
|
||||||
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
|
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
|
||||||
- ./docker/nginx/proxy.conf:/etc/nginx/conf.d/proxy.conf
|
- ./docker/nginx/proxy.conf:/etc/nginx/conf.d/proxy.conf
|
||||||
networks:
|
networks:
|
||||||
leftchan_net:
|
d_leftypol_org:
|
||||||
ipv4_address: 172.20.0.3
|
ipv4_address: 172.21.0.3
|
||||||
links:
|
links:
|
||||||
- php
|
- php
|
||||||
php:
|
php:
|
||||||
|
@ -23,30 +23,31 @@ services:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: ./docker/php/Dockerfile
|
dockerfile: ./docker/php/Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/code
|
- ./local-www:/var/www
|
||||||
- ./docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf
|
- ./docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf
|
||||||
networks:
|
networks:
|
||||||
leftchan_net:
|
d_leftypol_org:
|
||||||
ipv4_address: 172.20.0.4
|
ipv4_address: 172.21.0.4
|
||||||
#MySQL Service
|
#MySQL Service
|
||||||
db:
|
leftypol-db:
|
||||||
image: mysql:8.0.35
|
image: mysql:8.0.35
|
||||||
container_name: db
|
container_name: leftypol-db
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
tty: true
|
tty: true
|
||||||
ports:
|
ports:
|
||||||
- "3306:3306"
|
- "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
MYSQL_DATABASE: lainchan
|
MYSQL_DATABASE: vichan
|
||||||
MYSQL_ROOT_PASSWORD: M9q5lO0RxJVh
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
command: "--default-authentication-plugin=mysql_native_password"
|
||||||
networks:
|
networks:
|
||||||
leftchan_net:
|
d_leftypol_org:
|
||||||
ipv4_address: 172.20.0.2
|
ipv4_address: 172.21.0.2
|
||||||
|
|
||||||
#Docker Networks
|
#Docker Networks
|
||||||
networks:
|
networks:
|
||||||
leftchan_net:
|
d_leftypol_org:
|
||||||
ipam:
|
ipam:
|
||||||
driver: default
|
driver: default
|
||||||
config:
|
config:
|
||||||
- subnet: 172.20.0.0/16
|
- subnet: 172.21.0.0/16
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol
|
|
||||||
ln -s \
|
|
||||||
/code/banners/ \
|
|
||||||
/code/static/ \
|
|
||||||
/code/stylesheets/ \
|
|
||||||
/code/tools/ \
|
|
||||||
/code/walls/ \
|
|
||||||
/code/*.php \
|
|
||||||
/code/404.html \
|
|
||||||
/code/LICENSE.* \
|
|
||||||
/code/robots.txt \
|
|
||||||
/code/install.sql \
|
|
||||||
/var/www-leftypol/
|
|
||||||
|
|
||||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/js
|
|
||||||
ln -s /code/js/* /var/www-leftypol/js/
|
|
||||||
|
|
||||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/templates
|
|
||||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/templates/cache
|
|
||||||
ln -s /code/templates/* /var/www-leftypol/templates/
|
|
||||||
|
|
||||||
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/inc
|
|
||||||
ln -s /code/inc/* /var/www-leftypol/inc/
|
|
4
docker/doc.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
The `php-fpm` process runs containerized.
|
||||||
|
The php application always uses `/var/www` as it's work directory and home folder, and if `/var/www` is bind mounted it
|
||||||
|
is necessary to adjust the path passed via FastCGI to `php-fpm` by changing the root directory to `/var/www`.
|
||||||
|
This can achieved in nginx by setting the `fastcgi_param SCRIPT_FILENAME` to `/var/www/$fastcgi_script_name;`
|
|
@ -1,11 +1,8 @@
|
||||||
FROM nginx:1.25.3-alpine
|
FROM nginx:1.25.3-alpine
|
||||||
|
|
||||||
COPY . /code
|
COPY . /code
|
||||||
RUN addgroup --system leftypol \
|
RUN adduser --system www-data \
|
||||||
&& adduser --system leftypol \
|
&& adduser www-data www-data
|
||||||
&& adduser leftypol leftypol \
|
|
||||||
&& /code/docker/common-setup.sh
|
|
||||||
|
|
||||||
|
CMD [ "nginx", "-g", "daemon off;" ]
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
EXPOSE 80
|
||||||
EXPOSE 80 443
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ server {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
listen [::]:80 default_server ipv6only=on;
|
listen [::]:80 default_server ipv6only=on;
|
||||||
server_name leftypol;
|
server_name leftypol;
|
||||||
root /var/www-leftypol;
|
root /var/www/html;
|
||||||
add_header X-Frame-Options "SAMEORIGIN";
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
add_header X-Content-Type-Options "nosniff";
|
add_header X-Content-Type-Options "nosniff";
|
||||||
|
|
||||||
|
@ -15,23 +15,22 @@ server {
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
|
|
||||||
location ~ ^([^.\?]*[^\/])$ {
|
location ~ ^([^.\?]*[^\/])$ {
|
||||||
try_files $uri @addslash;
|
try_files $uri @addslash;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Expire rules for static content
|
# Expire rules for static content
|
||||||
# Media: images, icons, video, audio, HTC
|
# Media: images, icons, video, audio, HTC
|
||||||
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
|
location ~* \.(?:jpg|jpeg|gif|png|webp|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
|
||||||
expires 1M;
|
|
||||||
access_log off;
|
|
||||||
log_not_found off;
|
log_not_found off;
|
||||||
add_header Cache-Control "public";
|
# Public cache, never changes until max-age expires, max-age of 1 month, can still be served while being
|
||||||
|
# revalidated or if the server is erroring for 1 day.
|
||||||
|
add_header Cache-Control "public, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=86400";
|
||||||
}
|
}
|
||||||
# CSS and Javascript
|
# CSS and Javascript
|
||||||
location ~* \.(?:css|js)$ {
|
location ~* \.(?:css|js)$ {
|
||||||
expires 1y;
|
|
||||||
access_log off;
|
|
||||||
log_not_found off;
|
log_not_found off;
|
||||||
add_header Cache-Control "public";
|
# Public cache, max-age of 1 year, can still be served while being revalidated or if the server is erroring for 1 day.
|
||||||
|
add_header Cache-Control "public, max-age=31536000, stale-while-revalidate=86400, stale-if-error=86400";
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~* \.(html)$ {
|
location ~* \.(html)$ {
|
||||||
|
@ -39,7 +38,7 @@ server {
|
||||||
}
|
}
|
||||||
|
|
||||||
location @addslash {
|
location @addslash {
|
||||||
return 301 $uri/;
|
return 301 $uri/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
@ -56,7 +55,7 @@ server {
|
||||||
proxy_set_header Forwarded-Request-Id $x_request_id;
|
proxy_set_header Forwarded-Request-Id $x_request_id;
|
||||||
fastcgi_pass php-upstream;
|
fastcgi_pass php-upstream;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;
|
||||||
fastcgi_read_timeout 600;
|
fastcgi_read_timeout 600;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
# This and proxy.conf are based on
|
# This and proxy.conf are based on
|
||||||
# https://github.com/dead-guru/devichan/blob/master/nginx/nginx.conf
|
# https://github.com/dead-guru/devichan/blob/master/nginx/nginx.conf
|
||||||
|
|
||||||
user leftypol;
|
user www-data;
|
||||||
worker_processes auto;
|
worker_processes auto;
|
||||||
# daemon off;
|
# daemon off;
|
||||||
# error_log /var/log/nginx/error.log warn;
|
# error_log /var/log/nginx/error.log warn;
|
||||||
error_log /dev/stdout warn;
|
error_log /dev/stdout warn;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include /etc/nginx/mime.types;
|
include /etc/nginx/mime.types;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
|
|
|
@ -33,7 +33,7 @@ real_ip_header X-Forwarded-For;
|
||||||
|
|
||||||
set_real_ip_from 10.0.0.0/8;
|
set_real_ip_from 10.0.0.0/8;
|
||||||
set_real_ip_from 172.16.0.0/12;
|
set_real_ip_from 172.16.0.0/12;
|
||||||
set_real_ip_from 172.18.0.0/12;
|
set_real_ip_from 172.18.0.0;
|
||||||
set_real_ip_from 192.168.0.0/24;
|
set_real_ip_from 192.168.0.0/24;
|
||||||
set_real_ip_from 127.0.0.0/8;
|
set_real_ip_from 127.0.0.0/8;
|
||||||
|
|
||||||
|
|
|
@ -1,47 +1,89 @@
|
||||||
# Based on https://github.com/dead-guru/devichan/blob/master/php-fpm/Dockerfile
|
# Based on https://github.com/dead-guru/devichan/blob/master/php-fpm/Dockerfile
|
||||||
|
|
||||||
FROM composer AS composer
|
FROM composer AS composer
|
||||||
FROM php:8.1-fpm-bullseye
|
FROM php:7.2-fpm-alpine
|
||||||
COPY --from=composer /usr/bin/composer /usr/bin/composer
|
|
||||||
COPY . /code
|
|
||||||
|
|
||||||
RUN apt-get update && apt-get upgrade -y && apt-get install -y \
|
RUN apk add --no-cache \
|
||||||
zlib1g-dev libicu-dev g++ \
|
zlib \
|
||||||
libjpeg62-turbo-dev \
|
zlib-dev \
|
||||||
libzip-dev \
|
libpng \
|
||||||
libpng-dev \
|
libpng-dev \
|
||||||
libwebp-dev \
|
libjpeg-turbo \
|
||||||
libfreetype6-dev \
|
libjpeg-turbo-dev \
|
||||||
libxml2-dev \
|
libwebp \
|
||||||
git \
|
libwebp-dev \
|
||||||
zip \
|
libcurl \
|
||||||
ffmpeg \
|
curl-dev \
|
||||||
libonig-dev \
|
imagemagick \
|
||||||
unzip \
|
graphicsmagick \
|
||||||
libcurl4-openssl-dev \
|
gifsicle \
|
||||||
libmagickwand-dev \
|
ffmpeg \
|
||||||
gifsicle \
|
bind-tools \
|
||||||
graphicsmagick \
|
gettext \
|
||||||
gettext \
|
gettext-dev \
|
||||||
imagemagick \
|
icu-dev \
|
||||||
locales locales-all \
|
oniguruma \
|
||||||
libmagickwand-dev \
|
oniguruma-dev \
|
||||||
libmcrypt-dev \
|
libmcrypt \
|
||||||
|
libmcrypt-dev \
|
||||||
|
lz4-libs \
|
||||||
|
lz4-dev \
|
||||||
|
imagemagick-dev \
|
||||||
|
pcre-dev \
|
||||||
|
$PHPIZE_DEPS \
|
||||||
&& docker-php-ext-configure gd \
|
&& docker-php-ext-configure gd \
|
||||||
--with-webp=/usr/include/webp \
|
--with-webp-dir=/usr/include/webp \
|
||||||
--with-jpeg=/usr/include \
|
--with-jpeg-dir=/usr/include \
|
||||||
--with-freetype=/usr/include/freetype2/ \
|
&& docker-php-ext-install -j$(nproc) \
|
||||||
|
gd \
|
||||||
|
curl \
|
||||||
|
bcmath \
|
||||||
|
opcache \
|
||||||
|
pdo_mysql \
|
||||||
|
gettext \
|
||||||
|
intl \
|
||||||
|
mbstring \
|
||||||
|
&& pecl update-channels \
|
||||||
|
&& pecl install -o -f igbinary \
|
||||||
&& pecl install redis \
|
&& pecl install redis \
|
||||||
&& pecl install imagick \
|
&& pecl install imagick \
|
||||||
&& pecl install -o -f igbinary \
|
$$ docker-php-ext-enable \
|
||||||
&& docker-php-ext-install gd zip opcache intl pdo pdo_mysql mysqli bcmath gettext iconv mbstring curl \
|
igbinary \
|
||||||
&& docker-php-ext-enable igbinary redis imagick \
|
redis \
|
||||||
&& useradd -MU leftypol \
|
imagick \
|
||||||
&& /code/docker/common-setup.sh \
|
&& apk del \
|
||||||
&& ln -s /code/composer.json /code/composer.lock /var/www-leftypol/ \
|
zlib-dev \
|
||||||
&& cd /var/www-leftypol && composer install
|
libpng-dev \
|
||||||
|
libjpeg-turbo-dev \
|
||||||
|
libwebp-dev \
|
||||||
|
curl-dev \
|
||||||
|
gettext-dev \
|
||||||
|
oniguruma-dev \
|
||||||
|
libmcrypt-dev \
|
||||||
|
lz4-dev \
|
||||||
|
imagemagick-dev \
|
||||||
|
pcre-dev \
|
||||||
|
$PHPIZE_DEPS \
|
||||||
|
&& rm -rf /var/cache/*
|
||||||
|
RUN rmdir /var/www/html \
|
||||||
|
&& install -d -m 744 -o www-data -g www-data /var/www \
|
||||||
|
&& install -d -m 700 -o www-data -g www-data /var/tmp/vichan \
|
||||||
|
&& install -d -m 700 -o www-data -g www-data /var/cache/gen-cache \
|
||||||
|
&& install -d -m 700 -o www-data -g www-data /var/cache/template-cache
|
||||||
|
|
||||||
# RUN /code/docker/common-setup.sh php
|
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
|
||||||
WORKDIR "/var/www-leftypol"
|
|
||||||
CMD ["php-fpm"]
|
# Copy the bootstrap script.
|
||||||
|
COPY ./docker/php/bootstrap.sh /usr/local/bin/bootstrap.sh
|
||||||
|
|
||||||
|
# Copy the actual project (use .dockerignore to exclude stuff).
|
||||||
|
COPY . /code
|
||||||
|
|
||||||
|
# Make the instance configuration owned by www-data.
|
||||||
|
# Make it writable by php.
|
||||||
|
# Install the compose depedencies.
|
||||||
|
RUN cd /code && composer install
|
||||||
|
|
||||||
|
WORKDIR "/var/www"
|
||||||
|
CMD [ "bootstrap.sh" ]
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
79
docker/php/bootstrap.sh
Executable file
|
@ -0,0 +1,79 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
function set_cfg() {
|
||||||
|
if [ ! -f "/var/www/inc/$1" ]; then
|
||||||
|
echo "INFO: Resetting $1"
|
||||||
|
touch "/var/www/inc/$1"
|
||||||
|
chown www-data "/var/www/inc/$1"
|
||||||
|
chgrp www-data "/var/www/inc/$1"
|
||||||
|
chmod 600 "/var/www/inc/$1"
|
||||||
|
else
|
||||||
|
echo "INFO: Using existing $1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if ! mountpoint -q /var/www; then
|
||||||
|
echo "WARNING: '/var/www' is not a mountpoint. All the data will remain inside the container!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -w /var/www ] ; then
|
||||||
|
echo "ERROR: '/var/www' is not writable. Closing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Link the entrypoints from the exposed directory.
|
||||||
|
ln -nfs \
|
||||||
|
/code/tools/ \
|
||||||
|
/code/walls/ \
|
||||||
|
/code/*.php \
|
||||||
|
/code/LICENSE.* \
|
||||||
|
/code/404.html \
|
||||||
|
/code/install.sql \
|
||||||
|
/var/www/
|
||||||
|
# Static files accessible from the webserver must be copied.
|
||||||
|
cp -ur /code/static /var/www/
|
||||||
|
cp -ur /code/stylesheets /var/www/
|
||||||
|
|
||||||
|
# Ensure correct permissions are set, since this might be bind mount.
|
||||||
|
chown www-data /var/www
|
||||||
|
chgrp www-data /var/www
|
||||||
|
|
||||||
|
# Initialize an empty robots.txt with the default if it doesn't exist.
|
||||||
|
touch /var/www/robots.txt
|
||||||
|
|
||||||
|
# Link the cache and tmp files directory.
|
||||||
|
ln -nfs /var/tmp/vichan /var/www/tmp
|
||||||
|
|
||||||
|
# Link the javascript directory.
|
||||||
|
ln -nfs /code/js /var/www/
|
||||||
|
|
||||||
|
# Link the html templates directory and it's cache.
|
||||||
|
ln -nfs /code/templates /var/www/
|
||||||
|
ln -nfs -T /var/cache/template-cache /var/www/templates/cache
|
||||||
|
chown -h www-data /var/www/templates/cache
|
||||||
|
chgrp -h www-data /var/www/templates/cache
|
||||||
|
|
||||||
|
# Link the generic cache.
|
||||||
|
ln -nfs -T /var/cache/gen-cache /var/www/tmp/cache
|
||||||
|
chown -h www-data /var/www/tmp/cache
|
||||||
|
chgrp -h www-data /var/www/tmp/cache
|
||||||
|
|
||||||
|
# Create the included files directory and link them
|
||||||
|
install -d -m 700 -o www-data -g www-data /var/www/inc
|
||||||
|
for file in /code/inc/*; do
|
||||||
|
file="${file##*/}"
|
||||||
|
if [ ! -e /var/www/inc/$file ]; then
|
||||||
|
ln -s /code/inc/$file /var/www/inc/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Copy an empty instance configuration if the file is a link (it was linked because it did not exist before).
|
||||||
|
set_cfg 'instance-config.php'
|
||||||
|
|
||||||
|
# Link the composer dependencies.
|
||||||
|
ln -nfs /code/vendor /var/www/
|
||||||
|
|
||||||
|
# Start the php-fpm server.
|
||||||
|
exec php-fpm
|
|
@ -1,6 +1,12 @@
|
||||||
[www]
|
[www]
|
||||||
user = leftypol
|
access.log = /proc/self/fd/2
|
||||||
group = leftypol
|
|
||||||
|
; Ensure worker stdout and stderr are sent to the main error log.
|
||||||
|
catch_workers_output = yes
|
||||||
|
|
||||||
|
user = www-data
|
||||||
|
group = www-data
|
||||||
|
|
||||||
listen = 127.0.0.1:9000
|
listen = 127.0.0.1:9000
|
||||||
pm = static
|
pm = static
|
||||||
pm.max_children = 16
|
pm.max_children = 16
|
||||||
|
|
65
inc/bans.php
|
@ -12,12 +12,14 @@ class Bans {
|
||||||
return $ipstr;
|
return $ipstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($ipstart) != strlen($ipend))
|
if (strlen($ipstart) != strlen($ipend)) {
|
||||||
return '???'; // What the fuck are you doing, son?
|
return '???'; // What the fuck are you doing, son?
|
||||||
|
}
|
||||||
|
|
||||||
$range = CIDR::range_to_cidr(inet_ntop($ipstart), inet_ntop($ipend));
|
$range = CIDR::range_to_cidr(inet_ntop($ipstart), inet_ntop($ipend));
|
||||||
if ($range !== false)
|
if ($range !== false) {
|
||||||
return $range;
|
return $range;
|
||||||
|
}
|
||||||
|
|
||||||
return '???';
|
return '???';
|
||||||
}
|
}
|
||||||
|
@ -101,13 +103,13 @@ class Bans {
|
||||||
list($ipstart, $ipend) = self::calc_cidr($mask);
|
list($ipstart, $ipend) = self::calc_cidr($mask);
|
||||||
} elseif (preg_match('@^[:a-z\d]+/\d+$@i', $mask)) {
|
} elseif (preg_match('@^[:a-z\d]+/\d+$@i', $mask)) {
|
||||||
list($ipv6, $bits) = explode('/', $mask);
|
list($ipv6, $bits) = explode('/', $mask);
|
||||||
if ($bits > 128)
|
if ($bits > 128) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
list($ipstart, $ipend) = self::calc_cidr($mask);
|
list($ipstart, $ipend) = self::calc_cidr($mask);
|
||||||
} else {
|
} elseif (($ipstart = @inet_pton($mask)) === false) {
|
||||||
if (($ipstart = @inet_pton($mask)) === false)
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($ipstart, $ipend);
|
return array($ipstart, $ipend);
|
||||||
|
@ -135,8 +137,9 @@ class Bans {
|
||||||
if ($ban['expires'] && ($ban['seen'] || !$config['require_ban_view']) && $ban['expires'] < time()) {
|
if ($ban['expires'] && ($ban['seen'] || !$config['require_ban_view']) && $ban['expires'] < time()) {
|
||||||
self::delete($ban['id']);
|
self::delete($ban['id']);
|
||||||
} else {
|
} else {
|
||||||
if ($ban['post'])
|
if ($ban['post']) {
|
||||||
$ban['post'] = json_decode($ban['post'], true);
|
$ban['post'] = json_decode($ban['post'], true);
|
||||||
|
}
|
||||||
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||||
$ban_list[] = $ban;
|
$ban_list[] = $ban;
|
||||||
}
|
}
|
||||||
|
@ -149,16 +152,18 @@ class Bans {
|
||||||
$query = query("SELECT ``bans``.*, `username` FROM ``bans``
|
$query = query("SELECT ``bans``.*, `username` FROM ``bans``
|
||||||
LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`
|
LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`
|
||||||
ORDER BY `created` DESC") or error(db_error());
|
ORDER BY `created` DESC") or error(db_error());
|
||||||
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($board_access && $board_access[0] == '*') $board_access = false;
|
if ($board_access && $board_access[0] == '*') {
|
||||||
|
$board_access = false;
|
||||||
|
}
|
||||||
|
|
||||||
$out ? fputs($out, "[") : print("[");
|
$out ? fputs($out, "[") : print("[");
|
||||||
|
|
||||||
$end = end($bans);
|
$end = end($bans);
|
||||||
|
|
||||||
foreach ($bans as &$ban) {
|
foreach ($bans as &$ban) {
|
||||||
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
$ban['mask'] = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||||
|
|
||||||
$hide_message = false;
|
$hide_message = false;
|
||||||
foreach ($hide_regexes as $regex) {
|
foreach ($hide_regexes as $regex) {
|
||||||
|
@ -204,24 +209,25 @@ class Bans {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$out ? fputs($out, "]") : print("]");
|
$out ? fputs($out, "]") : print("]");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function seen($ban_id) {
|
static public function seen($ban_id) {
|
||||||
$query = query("UPDATE ``bans`` SET `seen` = 1 WHERE `id` = " . (int)$ban_id) or error(db_error());
|
query("UPDATE ``bans`` SET `seen` = 1 WHERE `id` = " . (int)$ban_id) or error(db_error());
|
||||||
rebuildThemes('bans');
|
rebuildThemes('bans');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function purge() {
|
static public function purge() {
|
||||||
$query = query("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < " . time() . " AND `seen` = 1") or error(db_error());
|
query("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < " . time() . " AND `seen` = 1") or error(db_error());
|
||||||
rebuildThemes('bans');
|
rebuildThemes('bans');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function delete($ban_id, $modlog = false, $boards = false, $dont_rebuild = false) {
|
static public function delete($ban_id, $modlog = false, $boards = false, $dont_rebuild = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($boards && $boards[0] == '*') $boards = false;
|
if ($boards && $boards[0] == '*') {
|
||||||
|
$boards = false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modlog) {
|
if ($modlog) {
|
||||||
$query = query("SELECT `ipstart`, `ipend`, `board` FROM ``bans`` WHERE `id` = " . (int)$ban_id) or error(db_error());
|
$query = query("SELECT `ipstart`, `ipend`, `board` FROM ``bans`` WHERE `id` = " . (int)$ban_id) or error(db_error());
|
||||||
|
@ -230,8 +236,9 @@ class Bans {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($boards !== false && !in_array($ban['board'], $boards))
|
if ($boards !== false && !in_array($ban['board'], $boards)) {
|
||||||
error($config['error']['noaccess']);
|
error($config['error']['noaccess']);
|
||||||
|
}
|
||||||
|
|
||||||
$mask = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
$mask = self::range_to_string(array($ban['ipstart'], $ban['ipend']));
|
||||||
|
|
||||||
|
@ -241,7 +248,9 @@ class Bans {
|
||||||
|
|
||||||
query("DELETE FROM ``bans`` WHERE `id` = " . (int)$ban_id) or error(db_error());
|
query("DELETE FROM ``bans`` WHERE `id` = " . (int)$ban_id) or error(db_error());
|
||||||
|
|
||||||
if (!$dont_rebuild) rebuildThemes('bans');
|
if (!$dont_rebuild) {
|
||||||
|
rebuildThemes('bans');
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -259,10 +268,11 @@ class Bans {
|
||||||
$query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
|
$query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ipstart, :ipend, :time, :expires, :board, :mod, :reason, 0, :post)");
|
||||||
|
|
||||||
$query->bindValue(':ipstart', $range[0]);
|
$query->bindValue(':ipstart', $range[0]);
|
||||||
if ($range[1] !== false && $range[1] != $range[0])
|
if ($range[1] !== false && $range[1] != $range[0]) {
|
||||||
$query->bindValue(':ipend', $range[1]);
|
$query->bindValue(':ipend', $range[1]);
|
||||||
else
|
} else {
|
||||||
$query->bindValue(':ipend', null, PDO::PARAM_NULL);
|
$query->bindValue(':ipend', null, PDO::PARAM_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
$query->bindValue(':mod', $mod_id);
|
$query->bindValue(':mod', $mod_id);
|
||||||
$query->bindValue(':time', time());
|
$query->bindValue(':time', time());
|
||||||
|
@ -271,8 +281,9 @@ class Bans {
|
||||||
$reason = escape_markup_modifiers($reason);
|
$reason = escape_markup_modifiers($reason);
|
||||||
markup($reason);
|
markup($reason);
|
||||||
$query->bindValue(':reason', $reason);
|
$query->bindValue(':reason', $reason);
|
||||||
} else
|
} else {
|
||||||
$query->bindValue(':reason', null, PDO::PARAM_NULL);
|
$query->bindValue(':reason', null, PDO::PARAM_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if ($length) {
|
if ($length) {
|
||||||
if (is_int($length) || ctype_digit($length)) {
|
if (is_int($length) || ctype_digit($length)) {
|
||||||
|
@ -285,16 +296,18 @@ class Bans {
|
||||||
$query->bindValue(':expires', null, PDO::PARAM_NULL);
|
$query->bindValue(':expires', null, PDO::PARAM_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ban_board)
|
if ($ban_board) {
|
||||||
$query->bindValue(':board', $ban_board);
|
$query->bindValue(':board', $ban_board);
|
||||||
else
|
} else {
|
||||||
$query->bindValue(':board', null, PDO::PARAM_NULL);
|
$query->bindValue(':board', null, PDO::PARAM_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if ($post) {
|
if ($post) {
|
||||||
$post['board'] = $board['uri'];
|
$post['board'] = $board['uri'];
|
||||||
$query->bindValue(':post', json_encode($post));
|
$query->bindValue(':post', json_encode($post));
|
||||||
} else
|
} else {
|
||||||
$query->bindValue(':post', null, PDO::PARAM_NULL);
|
$query->bindValue(':post', null, PDO::PARAM_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
|
|
@ -1170,6 +1170,7 @@
|
||||||
$config['error']['fileext'] = _('Unsupported image format.');
|
$config['error']['fileext'] = _('Unsupported image format.');
|
||||||
$config['error']['noboard'] = _('Invalid board!');
|
$config['error']['noboard'] = _('Invalid board!');
|
||||||
$config['error']['nonexistant'] = _('Thread specified does not exist.');
|
$config['error']['nonexistant'] = _('Thread specified does not exist.');
|
||||||
|
$config['error']['nopost'] = _('Post specified does not exist.');
|
||||||
$config['error']['locked'] = _('Thread locked. You may not reply at this time.');
|
$config['error']['locked'] = _('Thread locked. You may not reply at this time.');
|
||||||
$config['error']['reply_hard_limit'] = _('Thread has reached its maximum reply limit.');
|
$config['error']['reply_hard_limit'] = _('Thread has reached its maximum reply limit.');
|
||||||
$config['error']['image_hard_limit'] = _('Thread has reached its maximum image limit.');
|
$config['error']['image_hard_limit'] = _('Thread has reached its maximum image limit.');
|
||||||
|
@ -1991,4 +1992,3 @@
|
||||||
|
|
||||||
//Logo location for themes
|
//Logo location for themes
|
||||||
$config['logo'] = 'static/logo.png';
|
$config['logo'] = 'static/logo.png';
|
||||||
|
|
||||||
|
|
|
@ -497,6 +497,11 @@ class ImageBMP extends ImageBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ImageWEBP extends ImageBase {
|
||||||
|
public function from() {
|
||||||
|
$this->image = @imagecreatefromwebp($this->src);
|
||||||
|
}
|
||||||
|
public function to($src) {
|
||||||
|
imagewebp($this->image, $src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,12 +13,15 @@ $twig = false;
|
||||||
|
|
||||||
function load_twig() {
|
function load_twig() {
|
||||||
global $twig, $config;
|
global $twig, $config;
|
||||||
|
|
||||||
|
$cache_dir = "{$config['dir']['template']}/cache/";
|
||||||
|
|
||||||
$loader = new Twig_Loader_Filesystem($config['dir']['template']);
|
$loader = new Twig_Loader_Filesystem($config['dir']['template']);
|
||||||
$loader->setPaths($config['dir']['template']);
|
$loader->setPaths($config['dir']['template']);
|
||||||
$twig = new Twig_Environment($loader, array(
|
$twig = new Twig_Environment($loader, array(
|
||||||
'autoescape' => false,
|
'autoescape' => false,
|
||||||
'cache' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')) ?
|
'cache' => is_writable('templates/') || (is_dir($cache_dir) && is_writable($cache_dir)) ?
|
||||||
"{$config['dir']['template']}/cache" : false,
|
$cache_dir : false,
|
||||||
'debug' => $config['debug']
|
'debug' => $config['debug']
|
||||||
));
|
));
|
||||||
$twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
|
$twig->addExtension(new Twig_Extensions_Extension_Tinyboard());
|
||||||
|
@ -69,4 +72,3 @@ function Element($templateFile, array $options) {
|
||||||
throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
|
throw new Exception("Template file '${templateFile}' does not exist or is empty in '{$config['dir']['template']}'!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
install.php
|
@ -3,7 +3,7 @@
|
||||||
// Installation/upgrade file
|
// Installation/upgrade file
|
||||||
define('VERSION', '5.1.3');
|
define('VERSION', '5.1.3');
|
||||||
|
|
||||||
if (fopen('inc/instance-config.php' , 'a') === false) {
|
if (!is_writable('inc/instance-config.php') || !is_writable('inc/')) {
|
||||||
print('install.php does not have permission to write to /inc/, without permission the installer cannot continue');
|
print('install.php does not have permission to write to /inc/, without permission the installer cannot continue');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
@ -818,14 +818,14 @@ if ($step == 0) {
|
||||||
array(
|
array(
|
||||||
'category' => 'File permissions',
|
'category' => 'File permissions',
|
||||||
'name' => getcwd() . '/templates/cache',
|
'name' => getcwd() . '/templates/cache',
|
||||||
'result' => is_writable('templates') || (is_dir('templates/cache') && is_writable('templates/cache')),
|
'result' => is_dir('templates/cache/') && is_writable('templates/cache/'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'message' => 'You must give vichan permission to create (and write to) the <code>templates/cache</code> directory or performance will be drastically reduced.'
|
'message' => 'You must give vichan permission to create (and write to) the <code>templates/cache</code> directory or performance will be drastically reduced.'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'category' => 'File permissions',
|
'category' => 'File permissions',
|
||||||
'name' => getcwd() . '/tmp/cache',
|
'name' => getcwd() . '/tmp/cache',
|
||||||
'result' => is_dir('tmp/cache') && is_writable('tmp/cache'),
|
'result' => is_dir('tmp/cache/') && is_writable('tmp/cache/'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'message' => 'You must give vichan permission to write to the <code>tmp/cache</code> directory.'
|
'message' => 'You must give vichan permission to write to the <code>tmp/cache</code> directory.'
|
||||||
),
|
),
|
||||||
|
@ -945,12 +945,16 @@ if ($step == 0) {
|
||||||
$queries[] = Element('posts.sql', array('board' => 'b'));
|
$queries[] = Element('posts.sql', array('board' => 'b'));
|
||||||
|
|
||||||
$sql_errors = '';
|
$sql_errors = '';
|
||||||
|
$sql_err_count = 0;
|
||||||
foreach ($queries as $query) {
|
foreach ($queries as $query) {
|
||||||
if ($mysql_version < 50503)
|
if ($mysql_version < 50503)
|
||||||
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
|
$query = preg_replace('/(CHARSET=|CHARACTER SET )utf8mb4/', '$1utf8', $query);
|
||||||
$query = preg_replace('/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u', '$1``$2``', $query);
|
$query = preg_replace('/^([\w\s]*)`([0-9a-zA-Z$_\x{0080}-\x{FFFF}]+)`/u', '$1``$2``', $query);
|
||||||
if (!query($query))
|
if (!query($query)) {
|
||||||
$sql_errors .= '<li>' . db_error() . '</li>';
|
$sql_err_count++;
|
||||||
|
$error = db_error();
|
||||||
|
$sql_errors .= "<li>$sql_err_count<ul><li>$query</li><li>$error</li></ul></li>";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$page['title'] = 'Installation complete';
|
$page['title'] = 'Installation complete';
|
||||||
|
@ -989,4 +993,3 @@ if ($step == 0) {
|
||||||
|
|
||||||
echo Element('page.html', $page);
|
echo Element('page.html', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,7 +313,7 @@ CREATE TABLE `pages` (
|
||||||
`content` text,
|
`content` text,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `u_pages` (`name`,`board`)
|
UNIQUE KEY `u_pages` (`name`,`board`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
|
54
js/hud-pinning.js
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* hud-pinning.js
|
||||||
|
* https://git.leftypol.org/leftypol/leftypol
|
||||||
|
*
|
||||||
|
* Released under the MIT license
|
||||||
|
* Copyright (c) 2024 Zankaria <zankaria (dot) auxa (at) mailu (dot) io>
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* $config['additional_javascript'][] = 'js/jquery.min.js';
|
||||||
|
* $config['additional_javascript'][] = 'js/hud-pinning.js';
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* You know the bar on the top of the page that is created if you specify the $config['boards'] array? That one.
|
||||||
|
* Also know the bottom bar with the "Return" button and thread update controls? Also that one.
|
||||||
|
*
|
||||||
|
* Both bars are pinned on the top and bottom of the page. This script adds an option to unpin them.
|
||||||
|
*/
|
||||||
|
$(document).ready(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
if (window.Options && Options.get_tab('general') && window.jQuery) {
|
||||||
|
function setHudPinning(pin) {
|
||||||
|
let style = pin ? '' : 'initial';
|
||||||
|
$('#top-hud').css('position', style);
|
||||||
|
$('#bottom-hud').css('position', style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the option in the panel.
|
||||||
|
Options.extend_tab('general', '<label id="hud-pinning"><input type="checkbox">' + _('Unpin the top and bottom bars') + '</label>');
|
||||||
|
|
||||||
|
// Trigger if the panel's checkbox is toggled.
|
||||||
|
$('#hud-pinning>input').on('change', function() {
|
||||||
|
if (this.checked) {
|
||||||
|
localStorage.hud_pinning = 'false';
|
||||||
|
setHudPinning(false);
|
||||||
|
} else {
|
||||||
|
localStorage.hud_pinning = 'true';
|
||||||
|
setHudPinning(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reload on new post: allows it to work with auto-reload.js etc.
|
||||||
|
$(document).on('new_post', function(e, post) {
|
||||||
|
setHudPinning(localStorage.hud_pinning === 'true');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Enforce the setting on loading.
|
||||||
|
if (localStorage.hud_pinning === 'false') {
|
||||||
|
$('#hud-pinning>input').attr('checked', 'checked');
|
||||||
|
setHudPinning(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
54
post.php
|
@ -123,24 +123,24 @@ function db_select_thread_with_attributes($board, $thread_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the threads with the given id in the given board.
|
* Get the post with the given id in the given board.
|
||||||
*
|
*
|
||||||
* @param string $board Board to search in. MUST ALREADY BE SANITIZED.
|
* @param string $board Board to search in. MUST ALREADY BE SANITIZED.
|
||||||
* @param int $thread_id Id of the thread.
|
* @param int $id Id of the post.
|
||||||
* @return false|array Returns false if no thread exists. Otherwise, an array of arrays with the threads 'id', 'thread'
|
* @return false|array Returns false if no post exists. Otherwise, an array with the post's 'id', 'thread' and
|
||||||
* and 'body_nomarkup' properties.
|
* 'body_nomarkup' keys.
|
||||||
*/
|
*/
|
||||||
function db_select_threads_minimal($board, $thread_id)
|
function db_select_post_minimal($board, $id)
|
||||||
{
|
{
|
||||||
$query = prepare(sprintf("SELECT `id`, `thread`, `body_nomarkup` FROM ``posts_%s`` WHERE `id` = :id", $board));
|
$query = prepare(sprintf("SELECT `id`, `thread`, `body_nomarkup` FROM ``posts_%s`` WHERE `id` = :id", $board));
|
||||||
$query->bindValue(':id', $thread_id, PDO::PARAM_INT);
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
$threads = $query->fetch(PDO::FETCH_ASSOC);
|
$post = $query->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if (!$threads) {
|
if (!$post) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $threads;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -537,9 +537,21 @@ function handle_report()
|
||||||
markup($reason);
|
markup($reason);
|
||||||
|
|
||||||
foreach ($report as $id) {
|
foreach ($report as $id) {
|
||||||
$thread = db_select_threads_minimal($board['uri'], $id);
|
$post = db_select_post_minimal($board['uri'], $id);
|
||||||
|
if ($post === false) {
|
||||||
|
if ($config['syslog']) {
|
||||||
|
_syslog(LOG_INFO, "Failed to report non-existing post #{$id} in {$board['dir']}");
|
||||||
|
}
|
||||||
|
error($config['error']['nopost']);
|
||||||
|
}
|
||||||
|
|
||||||
$error = event('report', array('ip' => $_SERVER['REMOTE_ADDR'], 'board' => $board['uri'], 'post' => $post, 'reason' => $reason, 'link' => link_for($thread)));
|
$error = event('report', [
|
||||||
|
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||||
|
'board' => $board['uri'],
|
||||||
|
'post' => $post,
|
||||||
|
'reason' => $reason,
|
||||||
|
'link' => link_for($post)
|
||||||
|
]);
|
||||||
if ($error) {
|
if ($error) {
|
||||||
error($error);
|
error($error);
|
||||||
}
|
}
|
||||||
|
@ -548,7 +560,7 @@ function handle_report()
|
||||||
_syslog(
|
_syslog(
|
||||||
LOG_INFO,
|
LOG_INFO,
|
||||||
'Reported post: ' .
|
'Reported post: ' .
|
||||||
'/' . $board['dir'] . $config['dir']['res'] . link_for($thread) . ($thread['thread'] ? '#' . $id : '') .
|
'/' . $board['dir'] . $config['dir']['res'] . link_for($post) . ($post['thread'] ? '#' . $id : '') .
|
||||||
' for "' . $reason . '"'
|
' for "' . $reason . '"'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -579,20 +591,20 @@ function handle_report()
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postcontent = mb_substr($thread['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_';
|
$postcontent = mb_substr($post['body_nomarkup'], 0, 120) . '... _*(POST TRIMMED)*_';
|
||||||
$slackmessage = '<' . $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($thread['thread'] ? $thread['thread'] : $id) . ".html" . ($thread['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n';
|
$slackmessage = '<' . $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($post['thread'] ? $post['thread'] : $id) . ".html" . ($post['thread'] ? '#' . $id : '') . '> \n ' . $reason . '\n ' . $postcontent . '\n';
|
||||||
|
|
||||||
$slackresult = slack($slackmessage, $config['slack_channel']);
|
$slackresult = slack($slackmessage, $config['slack_channel']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($config['matrix'])) {
|
if (isset($config['matrix'])) {
|
||||||
$reported_post_url = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($thread['thread'] ? $thread['thread'] : $id) . ".html";
|
$reported_post_url = $config['domain'] . "/mod.php?/" . $board['dir'] . $config['dir']['res'] . ($post['thread'] ? $post['thread'] : $id) . ".html";
|
||||||
$post_url = $config['matrix']['host'] . "/_matrix/client/r0/rooms/" . $config['matrix']['room_id'] . "/send/m.room.message?access_token=" . $config['matrix']['access_token'];
|
$post_url = $config['matrix']['host'] . "/_matrix/client/r0/rooms/" . $config['matrix']['room_id'] . "/send/m.room.message?access_token=" . $config['matrix']['access_token'];
|
||||||
|
|
||||||
$trimmed_post = strlen($thread['body_nomarkup']) > $config['matrix']['max_message_length'] ? ' [...]' : '';
|
$trimmed_post = strlen($post['body_nomarkup']) > $config['matrix']['max_message_length'] ? ' [...]' : '';
|
||||||
$postcontent = mb_substr($thread['body_nomarkup'], 0, $config['matrix']['max_message_length']) . $trimmed_post;
|
$postcontent = mb_substr($post['body_nomarkup'], 0, $config['matrix']['max_message_length']) . $trimmed_post;
|
||||||
$matrix_message = $reported_post_url . ($thread['thread'] ? '#' . $id : '') . " \nReason:\n" . $reason . " \nPost:\n" . $postcontent . " \n";
|
$matrix_message = $reported_post_url . ($post['thread'] ? '#' . $id : '') . " \nReason:\n" . $reason . " \nPost:\n" . $postcontent . " \n";
|
||||||
$post_data = json_encode(
|
$post_data = json_encode(
|
||||||
array(
|
array(
|
||||||
"msgtype" => "m.text",
|
"msgtype" => "m.text",
|
||||||
|
@ -1147,7 +1159,7 @@ function handle_post()
|
||||||
if (!$size = @getimagesize($file['tmp_name'])) {
|
if (!$size = @getimagesize($file['tmp_name'])) {
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
if (!in_array($size[2], array(IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_BMP))) {
|
if (!in_array($size[2], [IMAGETYPE_PNG, IMAGETYPE_GIF, IMAGETYPE_WEBP, IMAGETYPE_JPEG, IMAGETYPE_BMP])) {
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
if ($size[0] > $config['max_width'] || $size[1] > $config['max_height']) {
|
if ($size[0] > $config['max_width'] || $size[1] > $config['max_height']) {
|
||||||
|
@ -1240,10 +1252,10 @@ function handle_post()
|
||||||
$thumb->_destroy();
|
$thumb->_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['redraw_image'] || (!@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg'))) {
|
if ($config['redraw_image'] || (!@$file['exif_stripped'] && $config['strip_exif'] && ($file['extension'] == 'jpg' || $file['extension'] == 'jpeg' || $file['extension'] == 'webp' || $file['extension'] == 'png'))) {
|
||||||
if (!$config['redraw_image'] && $config['use_exiftool']) {
|
if (!$config['redraw_image'] && $config['use_exiftool']) {
|
||||||
if (
|
if (
|
||||||
$error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= ' .
|
$error = shell_exec_error('exiftool -overwrite_original -ignoreMinorErrors -q -q -all= -Orientation ' .
|
||||||
escapeshellarg($file['tmp_name']))
|
escapeshellarg($file['tmp_name']))
|
||||||
) {
|
) {
|
||||||
error(_('Could not strip EXIF metadata!'), null, $error);
|
error(_('Could not strip EXIF metadata!'), null, $error);
|
||||||
|
|
16
site.conf
|
@ -1,16 +0,0 @@
|
||||||
server {
|
|
||||||
index index.php index.html;
|
|
||||||
error_log /var/log/nginx/error.log;
|
|
||||||
access_log /var/log/nginx/access.log;
|
|
||||||
root /code;
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
|
||||||
try_files $uri =404;
|
|
||||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
|
||||||
fastcgi_pass php:9000;
|
|
||||||
fastcgi_index index.php;
|
|
||||||
include fastcgi_params;
|
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
|
||||||
}
|
|
||||||
}
|
|
BIN
static/banned.jpg
Normal file
After Width: | Height: | Size: 820 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 184 KiB After Width: | Height: | Size: 184 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 380 KiB After Width: | Height: | Size: 380 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 2.1 MiB After Width: | Height: | Size: 2.1 MiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |