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.
|
||||||
EXPOSE 9000
|
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
|
||||||
|
|
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
|
||||||
|
|
157
inc/bans.php
|
@ -5,42 +5,44 @@ use Lifo\IP\CIDR;
|
||||||
class Bans {
|
class Bans {
|
||||||
static public function range_to_string($mask) {
|
static public function range_to_string($mask) {
|
||||||
list($ipstart, $ipend) = $mask;
|
list($ipstart, $ipend) = $mask;
|
||||||
|
|
||||||
if (!isset($ipend) || $ipend === false) {
|
if (!isset($ipend) || $ipend === false) {
|
||||||
// Not a range. Single IP address.
|
// Not a range. Single IP address.
|
||||||
$ipstr = inet_ntop($ipstart);
|
$ipstr = inet_ntop($ipstart);
|
||||||
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 '???';
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function calc_cidr($mask) {
|
private static function calc_cidr($mask) {
|
||||||
$cidr = new CIDR($mask);
|
$cidr = new CIDR($mask);
|
||||||
$range = $cidr->getRange();
|
$range = $cidr->getRange();
|
||||||
|
|
||||||
return array(inet_pton($range[0]), inet_pton($range[1]));
|
return array(inet_pton($range[0]), inet_pton($range[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parse_time($str) {
|
public static function parse_time($str) {
|
||||||
if (empty($str))
|
if (empty($str))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (($time = @strtotime($str)) !== false)
|
if (($time = @strtotime($str)) !== false)
|
||||||
return $time;
|
return $time;
|
||||||
|
|
||||||
if (!preg_match('/^((\d+)\s?ye?a?r?s?)?\s?+((\d+)\s?mon?t?h?s?)?\s?+((\d+)\s?we?e?k?s?)?\s?+((\d+)\s?da?y?s?)?((\d+)\s?ho?u?r?s?)?\s?+((\d+)\s?mi?n?u?t?e?s?)?\s?+((\d+)\s?se?c?o?n?d?s?)?$/', $str, $matches))
|
if (!preg_match('/^((\d+)\s?ye?a?r?s?)?\s?+((\d+)\s?mon?t?h?s?)?\s?+((\d+)\s?we?e?k?s?)?\s?+((\d+)\s?da?y?s?)?((\d+)\s?ho?u?r?s?)?\s?+((\d+)\s?mi?n?u?t?e?s?)?\s?+((\d+)\s?se?c?o?n?d?s?)?$/', $str, $matches))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$expire = 0;
|
$expire = 0;
|
||||||
|
|
||||||
if (isset($matches[2])) {
|
if (isset($matches[2])) {
|
||||||
// Years
|
// Years
|
||||||
$expire += (int)$matches[2]*60*60*24*365;
|
$expire += (int)$matches[2]*60*60*24*365;
|
||||||
|
@ -69,14 +71,14 @@ class Bans {
|
||||||
// Seconds
|
// Seconds
|
||||||
$expire += (int)$matches[14];
|
$expire += (int)$matches[14];
|
||||||
}
|
}
|
||||||
|
|
||||||
return time() + $expire;
|
return time() + $expire;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function parse_range($mask) {
|
static public function parse_range($mask) {
|
||||||
$ipstart = false;
|
$ipstart = false;
|
||||||
$ipend = false;
|
$ipend = false;
|
||||||
|
|
||||||
if (preg_match('@^(\d{1,3}\.){1,3}([\d*]{1,3})?$@', $mask) && substr_count($mask, '*') == 1) {
|
if (preg_match('@^(\d{1,3}\.){1,3}([\d*]{1,3})?$@', $mask) && substr_count($mask, '*') == 1) {
|
||||||
// IPv4 wildcard mask
|
// IPv4 wildcard mask
|
||||||
$parts = explode('.', $mask);
|
$parts = explode('.', $mask);
|
||||||
|
@ -97,51 +99,52 @@ class Bans {
|
||||||
list($ipv4, $bits) = explode('/', $mask);
|
list($ipv4, $bits) = explode('/', $mask);
|
||||||
if ($bits > 32)
|
if ($bits > 32)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function find($ip, $board = false, $get_mod_info = false) {
|
static public function find($ip, $board = false, $get_mod_info = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$query = prepare('SELECT ``bans``.*' . ($get_mod_info ? ', `username`' : '') . ' FROM ``bans``
|
$query = prepare('SELECT ``bans``.*' . ($get_mod_info ? ', `username`' : '') . ' FROM ``bans``
|
||||||
' . ($get_mod_info ? 'LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`' : '') . '
|
' . ($get_mod_info ? 'LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`' : '') . '
|
||||||
WHERE
|
WHERE
|
||||||
(' . ($board !== false ? '(`board` IS NULL OR `board` = :board) AND' : '') . '
|
(' . ($board !== false ? '(`board` IS NULL OR `board` = :board) AND' : '') . '
|
||||||
(`ipstart` = :ip OR (:ip >= `ipstart` AND :ip <= `ipend`)))
|
(`ipstart` = :ip OR (:ip >= `ipstart` AND :ip <= `ipend`)))
|
||||||
ORDER BY `expires` IS NULL, `expires` DESC');
|
ORDER BY `expires` IS NULL, `expires` DESC');
|
||||||
|
|
||||||
if ($board !== false)
|
if ($board !== false)
|
||||||
$query->bindValue(':board', $board, PDO::PARAM_STR);
|
$query->bindValue(':board', $board, PDO::PARAM_STR);
|
||||||
|
|
||||||
$query->bindValue(':ip', inet_pton($ip));
|
$query->bindValue(':ip', inet_pton($ip));
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
$ban_list = array();
|
$ban_list = array();
|
||||||
|
|
||||||
while ($ban = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($ban = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ban_list;
|
return $ban_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -182,7 +187,7 @@ class Bans {
|
||||||
$ban['single_addr'] = true;
|
$ban['single_addr'] = true;
|
||||||
}
|
}
|
||||||
if ($filter_staff || ($board_access !== false && !in_array($ban['board'], $board_access))) {
|
if ($filter_staff || ($board_access !== false && !in_array($ban['board'], $board_access))) {
|
||||||
$ban['username'] = '?';
|
$ban['username'] = '?';
|
||||||
}
|
}
|
||||||
if ($filter_ips || ($board_access !== false && !in_array($ban['board'], $board_access))) {
|
if ($filter_ips || ($board_access !== false && !in_array($ban['board'], $board_access))) {
|
||||||
@list($ban['mask'], $subnet) = explode("/", $ban['mask']);
|
@list($ban['mask'], $subnet) = explode("/", $ban['mask']);
|
||||||
|
@ -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');
|
|
||||||
}
|
|
||||||
|
|
||||||
static public function purge() {
|
|
||||||
$query = 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 purge() {
|
||||||
|
query("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < " . time() . " AND `seen` = 1") or error(db_error());
|
||||||
|
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,50 +236,55 @@ 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']));
|
||||||
|
|
||||||
modLog("Removed ban #{$ban_id} for " .
|
modLog("Removed ban #{$ban_id} for " .
|
||||||
(filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/$mask\">$mask</a>" : $mask));
|
(filter_var($mask, FILTER_VALIDATE_IP) !== false ? "<a href=\"?/IP/$mask\">$mask</a>" : $mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false) {
|
static public function new_ban($mask, $reason, $length = false, $ban_board = false, $mod_id = false, $post = false) {
|
||||||
global $mod, $pdo, $board;
|
global $mod, $pdo, $board;
|
||||||
|
|
||||||
if ($mod_id === false) {
|
if ($mod_id === false) {
|
||||||
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
|
$mod_id = isset($mod['id']) ? $mod['id'] : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$range = self::parse_range($mask);
|
$range = self::parse_range($mask);
|
||||||
$mask = self::range_to_string($range);
|
$mask = self::range_to_string($range);
|
||||||
|
|
||||||
$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());
|
||||||
|
|
||||||
if ($reason !== '') {
|
if ($reason !== '') {
|
||||||
$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)) {
|
||||||
$length = time() + $length;
|
$length = time() + $length;
|
||||||
|
@ -284,20 +295,22 @@ class Bans {
|
||||||
} else {
|
} else {
|
||||||
$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));
|
||||||
|
|
||||||
if (isset($mod['id']) && $mod['id'] == $mod_id) {
|
if (isset($mod['id']) && $mod['id'] == $mod_id) {
|
||||||
modLog('Created a new ' .
|
modLog('Created a new ' .
|
||||||
($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') .
|
($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') .
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On top of the static file caching system, you can enable the additional caching system which is
|
* On top of the static file caching system, you can enable the additional caching system which is
|
||||||
* designed to minimize SQL queries and can significantly increase speed when posting or using the
|
* designed to minimize SQL queries and can significantly increase speed when posting or using the
|
||||||
* moderator interface. APC is the recommended method of caching.
|
* moderator interface. APC is the recommended method of caching.
|
||||||
*
|
*
|
||||||
* http://tinyboard.org/docs/index.php?p=Config/Cache
|
* http://tinyboard.org/docs/index.php?p=Config/Cache
|
||||||
|
@ -209,22 +209,22 @@
|
||||||
// http://www.projecthoneypot.org/httpbl.php
|
// http://www.projecthoneypot.org/httpbl.php
|
||||||
// $config['dnsbl'][] = array('<your access key>.%.dnsbl.httpbl.org', function($ip) {
|
// $config['dnsbl'][] = array('<your access key>.%.dnsbl.httpbl.org', function($ip) {
|
||||||
// $octets = explode('.', $ip);
|
// $octets = explode('.', $ip);
|
||||||
//
|
//
|
||||||
// // days since last activity
|
// // days since last activity
|
||||||
// if ($octets[1] > 14)
|
// if ($octets[1] > 14)
|
||||||
// return false;
|
// return false;
|
||||||
//
|
//
|
||||||
// // "threat score" (http://www.projecthoneypot.org/threat_info.php)
|
// // "threat score" (http://www.projecthoneypot.org/threat_info.php)
|
||||||
// if ($octets[2] < 5)
|
// if ($octets[2] < 5)
|
||||||
// return false;
|
// return false;
|
||||||
//
|
//
|
||||||
// return true;
|
// return true;
|
||||||
// }, 'dnsbl.httpbl.org'); // hide our access key
|
// }, 'dnsbl.httpbl.org'); // hide our access key
|
||||||
|
|
||||||
// Skip checking certain IP addresses against blacklists (for troubleshooting or whatever)
|
// Skip checking certain IP addresses against blacklists (for troubleshooting or whatever)
|
||||||
$config['dnsbl_exceptions'][] = '127.0.0.1';
|
$config['dnsbl_exceptions'][] = '127.0.0.1';
|
||||||
|
|
||||||
// To prevent bump atacks; returns the thread to last position after the last post is deleted.
|
// To prevent bump atacks; returns the thread to last position after the last post is deleted.
|
||||||
$config['anti_bump_flood'] = false;
|
$config['anti_bump_flood'] = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -768,7 +768,7 @@
|
||||||
* 'gd' PHP GD (default). Only handles the most basic image formats (GIF, JPEG, PNG).
|
* 'gd' PHP GD (default). Only handles the most basic image formats (GIF, JPEG, PNG).
|
||||||
* GD is a prerequisite for Tinyboard no matter what method you choose.
|
* GD is a prerequisite for Tinyboard no matter what method you choose.
|
||||||
*
|
*
|
||||||
* 'imagick' PHP's ImageMagick bindings. Fast and efficient, supporting many image formats.
|
* 'imagick' PHP's ImageMagick bindings. Fast and efficient, supporting many image formats.
|
||||||
* A few minor bugs. http://pecl.php.net/package/imagick
|
* A few minor bugs. http://pecl.php.net/package/imagick
|
||||||
*
|
*
|
||||||
* 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in
|
* 'convert' The command line version of ImageMagick (`convert`). Fixes most of the bugs in
|
||||||
|
@ -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.');
|
||||||
|
@ -1776,7 +1777,7 @@
|
||||||
|
|
||||||
// event_handler('post', function($post) {
|
// event_handler('post', function($post) {
|
||||||
// // do something else
|
// // do something else
|
||||||
//
|
//
|
||||||
// // return an error (reject post)
|
// // return an error (reject post)
|
||||||
// return 'Sorry, you cannot post that!';
|
// return 'Sorry, you cannot post that!';
|
||||||
// });
|
// });
|
||||||
|
@ -1991,4 +1992,3 @@
|
||||||
|
|
||||||
//Logo location for themes
|
//Logo location for themes
|
||||||
$config['logo'] = 'static/logo.png';
|
$config['logo'] = 'static/logo.png';
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ function loadConfig() {
|
||||||
require_once('tmp/cache/cache_config.php');
|
require_once('tmp/cache/cache_config.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['cache_config']) &&
|
if (isset($config['cache_config']) &&
|
||||||
$config['cache_config'] &&
|
$config['cache_config'] &&
|
||||||
$config = Cache::get('config_' . $boardsuffix ) ) {
|
$config = Cache::get('config_' . $boardsuffix ) ) {
|
||||||
$events = Cache::get('events_' . $boardsuffix );
|
$events = Cache::get('events_' . $boardsuffix );
|
||||||
|
@ -76,7 +76,7 @@ function loadConfig() {
|
||||||
else {
|
else {
|
||||||
$config = array();
|
$config = array();
|
||||||
|
|
||||||
reset_events();
|
reset_events();
|
||||||
|
|
||||||
$arrays = array(
|
$arrays = array(
|
||||||
'db',
|
'db',
|
||||||
|
@ -309,7 +309,7 @@ function loadConfig() {
|
||||||
else if (is_callable($config['anonymous'])){
|
else if (is_callable($config['anonymous'])){
|
||||||
$config['anonymous'] = $config['anonymous']($boardsuffix);
|
$config['anonymous'] = $config['anonymous']($boardsuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['debug']) {
|
if ($config['debug']) {
|
||||||
if (!isset($debug)) {
|
if (!isset($debug)) {
|
||||||
$debug = array(
|
$debug = array(
|
||||||
|
@ -350,7 +350,7 @@ function define_groups() {
|
||||||
define($group_name, $group_value);
|
define($group_name, $group_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ksort($config['mod']['groups']);
|
ksort($config['mod']['groups']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ function rebuildThemes($action, $boardname = false) {
|
||||||
$config = $_config;
|
$config = $_config;
|
||||||
$board = $_board;
|
$board = $_board;
|
||||||
|
|
||||||
// Reload the locale
|
// Reload the locale
|
||||||
if ($config['locale'] != $current_locale) {
|
if ($config['locale'] != $current_locale) {
|
||||||
$current_locale = $config['locale'];
|
$current_locale = $config['locale'];
|
||||||
init_locale($config['locale']);
|
init_locale($config['locale']);
|
||||||
|
@ -409,7 +409,7 @@ function rebuildThemes($action, $boardname = false) {
|
||||||
$config = $_config;
|
$config = $_config;
|
||||||
$board = $_board;
|
$board = $_board;
|
||||||
|
|
||||||
// Reload the locale
|
// Reload the locale
|
||||||
if ($config['locale'] != $current_locale) {
|
if ($config['locale'] != $current_locale) {
|
||||||
$current_locale = $config['locale'];
|
$current_locale = $config['locale'];
|
||||||
init_locale($config['locale']);
|
init_locale($config['locale']);
|
||||||
|
@ -561,7 +561,7 @@ function purge($uri) {
|
||||||
global $config, $debug;
|
global $config, $debug;
|
||||||
|
|
||||||
// Fix for Unicode
|
// Fix for Unicode
|
||||||
$uri = rawurlencode($uri);
|
$uri = rawurlencode($uri);
|
||||||
|
|
||||||
$noescape = "/!~*()+:";
|
$noescape = "/!~*()+:";
|
||||||
$noescape = preg_split('//', $noescape);
|
$noescape = preg_split('//', $noescape);
|
||||||
|
@ -757,7 +757,7 @@ function listBoards($just_uri = false) {
|
||||||
$boards[] = $board;
|
$boards[] = $board;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['cache']['enabled'])
|
if ($config['cache']['enabled'])
|
||||||
cache::set($cache_name, $boards);
|
cache::set($cache_name, $boards);
|
||||||
|
|
||||||
|
@ -823,10 +823,10 @@ function displayBan($ban) {
|
||||||
$post = new Thread($ban['post'], null, false, false);
|
$post = new Thread($ban['post'], null, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$denied_appeals = array();
|
$denied_appeals = array();
|
||||||
$pending_appeal = false;
|
$pending_appeal = false;
|
||||||
|
|
||||||
if ($config['ban_appeals']) {
|
if ($config['ban_appeals']) {
|
||||||
$query = query("SELECT `time`, `denied` FROM ``ban_appeals`` WHERE `ban_id` = " . (int)$ban['id']) or error(db_error());
|
$query = query("SELECT `time`, `denied` FROM ``ban_appeals`` WHERE `ban_id` = " . (int)$ban['id']) or error(db_error());
|
||||||
while ($ban_appeal = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($ban_appeal = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
|
@ -837,7 +837,7 @@ function displayBan($ban) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show banned page and exit
|
// Show banned page and exit
|
||||||
die(
|
die(
|
||||||
Element('page.html', array(
|
Element('page.html', array(
|
||||||
|
@ -862,7 +862,7 @@ function checkBan($board = false) {
|
||||||
if (!isset($_SERVER['REMOTE_ADDR'])) {
|
if (!isset($_SERVER['REMOTE_ADDR'])) {
|
||||||
// Server misconfiguration
|
// Server misconfiguration
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event('check-ban', $board))
|
if (event('check-ban', $board))
|
||||||
return true;
|
return true;
|
||||||
|
@ -877,7 +877,7 @@ function checkBan($board = false) {
|
||||||
|
|
||||||
foreach ($ips as $ip) {
|
foreach ($ips as $ip) {
|
||||||
$bans = Bans::find($_SERVER['REMOTE_ADDR'], $board, $config['show_modname']);
|
$bans = Bans::find($_SERVER['REMOTE_ADDR'], $board, $config['show_modname']);
|
||||||
|
|
||||||
foreach ($bans as &$ban) {
|
foreach ($bans as &$ban) {
|
||||||
if ($ban['expires'] && $ban['expires'] < time()) {
|
if ($ban['expires'] && $ban['expires'] < time()) {
|
||||||
Bans::delete($ban['id']);
|
Bans::delete($ban['id']);
|
||||||
|
@ -906,9 +906,9 @@ function checkBan($board = false) {
|
||||||
if (time() - $last_time_purged < $config['purge_bans'] )
|
if (time() - $last_time_purged < $config['purge_bans'] )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bans::purge();
|
Bans::purge();
|
||||||
|
|
||||||
if ($config['cache']['enabled'])
|
if ($config['cache']['enabled'])
|
||||||
cache::set('purged_bans_last', time());
|
cache::set('purged_bans_last', time());
|
||||||
}
|
}
|
||||||
|
@ -965,7 +965,7 @@ function threadExists($id) {
|
||||||
|
|
||||||
function insertFloodPost(array $post) {
|
function insertFloodPost(array $post) {
|
||||||
global $board;
|
global $board;
|
||||||
|
|
||||||
$query = prepare("INSERT INTO ``flood`` VALUES (NULL, :ip, :board, :time, :posthash, :filehash, :isreply)");
|
$query = prepare("INSERT INTO ``flood`` VALUES (NULL, :ip, :board, :time, :posthash, :filehash, :isreply)");
|
||||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||||
$query->bindValue(':board', $board['uri']);
|
$query->bindValue(':board', $board['uri']);
|
||||||
|
@ -1006,7 +1006,7 @@ function post(array $post) {
|
||||||
$query->bindValue(':body', $post['body']);
|
$query->bindValue(':body', $post['body']);
|
||||||
$query->bindValue(':body_nomarkup', $post['body_nomarkup']);
|
$query->bindValue(':body_nomarkup', $post['body_nomarkup']);
|
||||||
$query->bindValue(':time', isset($post['time']) ? $post['time'] : time(), PDO::PARAM_INT);
|
$query->bindValue(':time', isset($post['time']) ? $post['time'] : time(), PDO::PARAM_INT);
|
||||||
$query->bindValue(':password', $post['password']);
|
$query->bindValue(':password', $post['password']);
|
||||||
$query->bindValue(':ip', isset($post['ip']) ? $post['ip'] : $_SERVER['REMOTE_ADDR']);
|
$query->bindValue(':ip', isset($post['ip']) ? $post['ip'] : $_SERVER['REMOTE_ADDR']);
|
||||||
|
|
||||||
if ($post['op'] && $post['mod'] && isset($post['sticky']) && $post['sticky']) {
|
if ($post['op'] && $post['mod'] && isset($post['sticky']) && $post['sticky']) {
|
||||||
|
@ -1186,7 +1186,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) {
|
||||||
// Delete posts and maybe replies
|
// Delete posts and maybe replies
|
||||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
event('delete', $post);
|
event('delete', $post);
|
||||||
|
|
||||||
$thread_id = $post['thread'];
|
$thread_id = $post['thread'];
|
||||||
if (!$post['thread']) {
|
if (!$post['thread']) {
|
||||||
// Delete thread HTML page
|
// Delete thread HTML page
|
||||||
|
@ -1287,7 +1287,7 @@ function clean($pid = false) {
|
||||||
$query = prepare(sprintf("SELECT `id` AS `thread_id`, (SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset, 9001", $board['uri'], $board['uri']));
|
$query = prepare(sprintf("SELECT `id` AS `thread_id`, (SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `sticky` DESC, `bump` DESC LIMIT :offset, 9001", $board['uri'], $board['uri']));
|
||||||
$query->bindValue(':offset', $offset, PDO::PARAM_INT);
|
$query->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if ($post['reply_count'] < $config['early_404_replies']) {
|
if ($post['reply_count'] < $config['early_404_replies']) {
|
||||||
deletePost($post['thread_id'], false, false);
|
deletePost($post['thread_id'], false, false);
|
||||||
|
@ -1326,7 +1326,7 @@ function index($page, $mod=false, $brief = false) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$threads = array();
|
$threads = array();
|
||||||
|
|
||||||
while ($th = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($th = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$thread = new Thread($th, $mod ? '?/' : $config['root'], $mod);
|
$thread = new Thread($th, $mod ? '?/' : $config['root'], $mod);
|
||||||
|
|
||||||
|
@ -1377,7 +1377,7 @@ function index($page, $mod=false, $brief = false) {
|
||||||
$thread->omitted = $omitted['post_count'] - ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
|
$thread->omitted = $omitted['post_count'] - ($th['sticky'] ? $config['threads_preview_sticky'] : $config['threads_preview']);
|
||||||
$thread->omitted_images = $omitted['image_count'] - $num_images;
|
$thread->omitted_images = $omitted['image_count'] - $num_images;
|
||||||
}
|
}
|
||||||
|
|
||||||
$threads[] = $thread;
|
$threads[] = $thread;
|
||||||
|
|
||||||
if (!$brief) {
|
if (!$brief) {
|
||||||
|
@ -1594,7 +1594,7 @@ function checkMute() {
|
||||||
// Not expired yet
|
// Not expired yet
|
||||||
error(sprintf($config['error']['youaremuted'], $mute['time'] + $mutetime - time()));
|
error(sprintf($config['error']['youaremuted'], $mute['time'] + $mutetime - time()));
|
||||||
} else {
|
} else {
|
||||||
// Already expired
|
// Already expired
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1883,8 +1883,8 @@ function wordfilters(&$body) {
|
||||||
|
|
||||||
foreach ($config['wordfilters'] as $filter) {
|
foreach ($config['wordfilters'] as $filter) {
|
||||||
if (isset($filter[3]) && $filter[3]) {
|
if (isset($filter[3]) && $filter[3]) {
|
||||||
$refilter = $filter[0];
|
$refilter = $filter[0];
|
||||||
if (strncmp($filter[0], "/", 1) !== 0)
|
if (strncmp($filter[0], "/", 1) !== 0)
|
||||||
{
|
{
|
||||||
$refilter = "/.*" . $filter[0] . "/";
|
$refilter = "/.*" . $filter[0] . "/";
|
||||||
}
|
}
|
||||||
|
@ -1895,8 +1895,8 @@ function wordfilters(&$body) {
|
||||||
return $match;
|
return $match;
|
||||||
} else {
|
} else {
|
||||||
if (isset($filter[2]) && $filter[2]) {
|
if (isset($filter[2]) && $filter[2]) {
|
||||||
$refilter = $filter[0];
|
$refilter = $filter[0];
|
||||||
if (strncmp($filter[0], "/", 1) !== 0)
|
if (strncmp($filter[0], "/", 1) !== 0)
|
||||||
{
|
{
|
||||||
$refilter = "/.*" . $filter[0] . "/";
|
$refilter = "/.*" . $filter[0] . "/";
|
||||||
}
|
}
|
||||||
|
@ -1912,7 +1912,7 @@ function wordfilters(&$body) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
, $body);
|
, $body);
|
||||||
} else {
|
} else {
|
||||||
if (isset($filter[2]) && $filter[2]) {
|
if (isset($filter[2]) && $filter[2]) {
|
||||||
if (is_callable($filter[1]))
|
if (is_callable($filter[1]))
|
||||||
$body = preg_replace_callback($filter[0], $filter[1], $body);
|
$body = preg_replace_callback($filter[0], $filter[1], $body);
|
||||||
|
@ -1958,7 +1958,7 @@ function markup_url($matches) {
|
||||||
'rel' => 'nofollow',
|
'rel' => 'nofollow',
|
||||||
'target' => '_blank',
|
'target' => '_blank',
|
||||||
);
|
);
|
||||||
|
|
||||||
event('markup-url', $link);
|
event('markup-url', $link);
|
||||||
$link = (array)$link;
|
$link = (array)$link;
|
||||||
|
|
||||||
|
@ -1993,7 +1993,7 @@ function newline_to_full_stop($body) {
|
||||||
|
|
||||||
function extract_modifiers($body) {
|
function extract_modifiers($body) {
|
||||||
$modifiers = array();
|
$modifiers = array();
|
||||||
|
|
||||||
if (preg_match_all('@<tinyboard ([\w\s]+)>(.*?)</tinyboard>@us', $body, $matches, PREG_SET_ORDER)) {
|
if (preg_match_all('@<tinyboard ([\w\s]+)>(.*?)</tinyboard>@us', $body, $matches, PREG_SET_ORDER)) {
|
||||||
foreach ($matches as $match) {
|
foreach ($matches as $match) {
|
||||||
if (preg_match('/^escape /', $match[1]))
|
if (preg_match('/^escape /', $match[1]))
|
||||||
|
@ -2001,7 +2001,7 @@ function extract_modifiers($body) {
|
||||||
$modifiers[$match[1]] = html_entity_decode($match[2]);
|
$modifiers[$match[1]] = html_entity_decode($match[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $modifiers;
|
return $modifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2024,10 +2024,10 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
global $board, $config, $markup_urls;
|
global $board, $config, $markup_urls;
|
||||||
|
|
||||||
$modifiers = extract_modifiers($body);
|
$modifiers = extract_modifiers($body);
|
||||||
|
|
||||||
$body = preg_replace('@<tinyboard (?!escape )([\w\s]+)>(.+?)</tinyboard>@us', '', $body);
|
$body = preg_replace('@<tinyboard (?!escape )([\w\s]+)>(.+?)</tinyboard>@us', '', $body);
|
||||||
$body = preg_replace('@<(tinyboard) escape ([\w\s]+)>@i', '<$1 $2>', $body);
|
$body = preg_replace('@<(tinyboard) escape ([\w\s]+)>@i', '<$1 $2>', $body);
|
||||||
|
|
||||||
if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') {
|
if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -2069,7 +2069,7 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
error($config['error']['toomanylinks']);
|
error($config['error']['toomanylinks']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($config['markup_repair_tidy'])
|
if ($config['markup_repair_tidy'])
|
||||||
$body = str_replace(' ', ' ', $body);
|
$body = str_replace(' ', ' ', $body);
|
||||||
|
|
||||||
|
@ -2093,21 +2093,21 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
|
|
||||||
$skip_chars = 0;
|
$skip_chars = 0;
|
||||||
$body_tmp = $body;
|
$body_tmp = $body;
|
||||||
|
|
||||||
$search_cites = array();
|
$search_cites = array();
|
||||||
foreach ($cites as $matches) {
|
foreach ($cites as $matches) {
|
||||||
$search_cites[] = '`id` = ' . $matches[2][0];
|
$search_cites[] = '`id` = ' . $matches[2][0];
|
||||||
}
|
}
|
||||||
$search_cites = array_unique($search_cites);
|
$search_cites = array_unique($search_cites);
|
||||||
|
|
||||||
$query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' .
|
$query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' .
|
||||||
implode(' OR ', $search_cites), $board['uri'])) or error(db_error());
|
implode(' OR ', $search_cites), $board['uri'])) or error(db_error());
|
||||||
|
|
||||||
$cited_posts = array();
|
$cited_posts = array();
|
||||||
while ($cited = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($cited = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false;
|
$cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($cites as $matches) {
|
foreach ($cites as $matches) {
|
||||||
$cite = $matches[2][0];
|
$cite = $matches[2][0];
|
||||||
|
|
||||||
|
@ -2140,34 +2140,34 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
|
|
||||||
$skip_chars = 0;
|
$skip_chars = 0;
|
||||||
$body_tmp = $body;
|
$body_tmp = $body;
|
||||||
|
|
||||||
if (isset($cited_posts)) {
|
if (isset($cited_posts)) {
|
||||||
// Carry found posts from local board >>X links
|
// Carry found posts from local board >>X links
|
||||||
foreach ($cited_posts as $cite => $thread) {
|
foreach ($cited_posts as $cite => $thread) {
|
||||||
$cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] .
|
$cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] .
|
||||||
($thread ? $thread : $cite) . '.html#' . $cite;
|
($thread ? $thread : $cite) . '.html#' . $cite;
|
||||||
}
|
}
|
||||||
|
|
||||||
$cited_posts = array(
|
$cited_posts = array(
|
||||||
$board['uri'] => $cited_posts
|
$board['uri'] => $cited_posts
|
||||||
);
|
);
|
||||||
} else
|
} else
|
||||||
$cited_posts = array();
|
$cited_posts = array();
|
||||||
|
|
||||||
$crossboard_indexes = array();
|
$crossboard_indexes = array();
|
||||||
$search_cites_boards = array();
|
$search_cites_boards = array();
|
||||||
|
|
||||||
foreach ($cites as $matches) {
|
foreach ($cites as $matches) {
|
||||||
$_board = $matches[2][0];
|
$_board = $matches[2][0];
|
||||||
$cite = @$matches[3][0];
|
$cite = @$matches[3][0];
|
||||||
|
|
||||||
if (!isset($search_cites_boards[$_board]))
|
if (!isset($search_cites_boards[$_board]))
|
||||||
$search_cites_boards[$_board] = array();
|
$search_cites_boards[$_board] = array();
|
||||||
$search_cites_boards[$_board][] = $cite;
|
$search_cites_boards[$_board][] = $cite;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmp_board = $board['uri'];
|
$tmp_board = $board['uri'];
|
||||||
|
|
||||||
foreach ($search_cites_boards as $_board => $search_cites) {
|
foreach ($search_cites_boards as $_board => $search_cites) {
|
||||||
$clauses = array();
|
$clauses = array();
|
||||||
foreach ($search_cites as $cite) {
|
foreach ($search_cites as $cite) {
|
||||||
|
@ -2176,7 +2176,7 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
$clauses[] = '`id` = ' . $cite;
|
$clauses[] = '`id` = ' . $cite;
|
||||||
}
|
}
|
||||||
$clauses = array_unique($clauses);
|
$clauses = array_unique($clauses);
|
||||||
|
|
||||||
if ($board['uri'] != $_board) {
|
if ($board['uri'] != $_board) {
|
||||||
if (!openBoard($_board)){
|
if (!openBoard($_board)){
|
||||||
if (in_array($_board,array_keys($config['boards_alias']))){
|
if (in_array($_board,array_keys($config['boards_alias']))){
|
||||||
|
@ -2191,25 +2191,25 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
else {
|
else {
|
||||||
continue; // Unknown board
|
continue; // Unknown board
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($clauses)) {
|
if (!empty($clauses)) {
|
||||||
$cited_posts[$_board] = array();
|
$cited_posts[$_board] = array();
|
||||||
|
|
||||||
$query = query(sprintf('SELECT `thread`, `id`, `slug` FROM ``posts_%s`` WHERE ' .
|
$query = query(sprintf('SELECT `thread`, `id`, `slug` FROM ``posts_%s`` WHERE ' .
|
||||||
implode(' OR ', $clauses), $board['uri'])) or error(db_error());
|
implode(' OR ', $clauses), $board['uri'])) or error(db_error());
|
||||||
|
|
||||||
while ($cite = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($cite = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$cited_posts[$_board][$cite['id']] = $config['root'] . $board['dir'] . $config['dir']['res'] .
|
$cited_posts[$_board][$cite['id']] = $config['root'] . $board['dir'] . $config['dir']['res'] .
|
||||||
link_for($cite) . '#' . $cite['id'];
|
link_for($cite) . '#' . $cite['id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$crossboard_indexes[$_board] = $config['root'] . $board['dir'] . $config['file_index'];
|
$crossboard_indexes[$_board] = $config['root'] . $board['dir'] . $config['file_index'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore old board
|
// Restore old board
|
||||||
if ($board['uri'] != $tmp_board)
|
if ($board['uri'] != $tmp_board)
|
||||||
openBoard($tmp_board);
|
openBoard($tmp_board);
|
||||||
|
@ -2285,7 +2285,7 @@ function markup(&$body, $track_cites = false, $op = false) {
|
||||||
$code = rtrim(ltrim($code, "\r\n"));
|
$code = rtrim(ltrim($code, "\r\n"));
|
||||||
|
|
||||||
$code = "<pre class='code lang-$code_lang'>".str_replace(array("\n","\t"), array(" ","	"), htmlspecialchars($code, ENT_COMPAT, "UTF-8", false))."</pre>";
|
$code = "<pre class='code lang-$code_lang'>".str_replace(array("\n","\t"), array(" ","	"), htmlspecialchars($code, ENT_COMPAT, "UTF-8", false))."</pre>";
|
||||||
|
|
||||||
$body = str_replace("<code $id>", $code, $body);
|
$body = str_replace("<code $id>", $code, $body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2323,7 +2323,7 @@ function utf8tohtml($utf8) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function ordutf8($string, &$offset) {
|
function ordutf8($string, &$offset) {
|
||||||
$code = ord(substr($string, $offset,1));
|
$code = ord(substr($string, $offset,1));
|
||||||
if ($code >= 128) { // otherwise 0xxxxxxx
|
if ($code >= 128) { // otherwise 0xxxxxxx
|
||||||
if ($code < 224)
|
if ($code < 224)
|
||||||
$bytesnumber = 2; // 110xxxxx
|
$bytesnumber = 2; // 110xxxxx
|
||||||
|
@ -2387,7 +2387,7 @@ function buildThread($id, $return = false, $mod = false) {
|
||||||
// Check if any posts were found
|
// Check if any posts were found
|
||||||
if (!isset($thread))
|
if (!isset($thread))
|
||||||
error($config['error']['nonexistant']);
|
error($config['error']['nonexistant']);
|
||||||
|
|
||||||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||||
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
$antibot = $mod || $return ? false : create_antibot($board['uri'], $id);
|
||||||
|
|
||||||
|
@ -2438,16 +2438,16 @@ function buildThread($id, $return = false, $mod = false) {
|
||||||
function buildThread50($id, $return = false, $mod = false, $thread = null, $antibot = false) {
|
function buildThread50($id, $return = false, $mod = false, $thread = null, $antibot = false) {
|
||||||
global $board, $config, $build_pages;
|
global $board, $config, $build_pages;
|
||||||
$id = round($id);
|
$id = round($id);
|
||||||
|
|
||||||
if ($antibot)
|
if ($antibot)
|
||||||
$antibot->reset();
|
$antibot->reset();
|
||||||
|
|
||||||
if (!$thread) {
|
if (!$thread) {
|
||||||
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id` DESC LIMIT :limit", $board['uri']));
|
$query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id` DESC LIMIT :limit", $board['uri']));
|
||||||
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
$query->bindValue(':id', $id, PDO::PARAM_INT);
|
||||||
$query->bindValue(':limit', $config['noko50_count']+1, PDO::PARAM_INT);
|
$query->bindValue(':limit', $config['noko50_count']+1, PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
$num_images = 0;
|
$num_images = 0;
|
||||||
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
|
||||||
if (!isset($thread)) {
|
if (!isset($thread)) {
|
||||||
|
@ -2455,7 +2455,7 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
|
||||||
} else {
|
} else {
|
||||||
if ($post['files'])
|
if ($post['files'])
|
||||||
$num_images += $post['num_files'];
|
$num_images += $post['num_files'];
|
||||||
|
|
||||||
$thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod));
|
$thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2470,10 +2470,10 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
|
||||||
SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri']));
|
SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `files` IS NOT NULL AND `thread` = :thread", $board['uri'], $board['uri']));
|
||||||
$count->bindValue(':thread', $id, PDO::PARAM_INT);
|
$count->bindValue(':thread', $id, PDO::PARAM_INT);
|
||||||
$count->execute() or error(db_error($count));
|
$count->execute() or error(db_error($count));
|
||||||
|
|
||||||
$c = $count->fetch();
|
$c = $count->fetch();
|
||||||
$thread->omitted = $c['num'] - $config['noko50_count'];
|
$thread->omitted = $c['num'] - $config['noko50_count'];
|
||||||
|
|
||||||
$c = $count->fetch();
|
$c = $count->fetch();
|
||||||
$thread->omitted_images = $c['num'] - $num_images;
|
$thread->omitted_images = $c['num'] - $num_images;
|
||||||
}
|
}
|
||||||
|
@ -2486,13 +2486,13 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
|
||||||
$thread->omitted += count($allPosts) - count($thread->posts);
|
$thread->omitted += count($allPosts) - count($thread->posts);
|
||||||
foreach ($allPosts as $index => $post) {
|
foreach ($allPosts as $index => $post) {
|
||||||
if ($index == count($allPosts)-count($thread->posts))
|
if ($index == count($allPosts)-count($thread->posts))
|
||||||
break;
|
break;
|
||||||
if ($post->files)
|
if ($post->files)
|
||||||
$thread->omitted_images += $post->num_files;
|
$thread->omitted_images += $post->num_files;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
$hasnoko50 = $thread->postCount() >= $config['noko50_min'];
|
||||||
|
|
||||||
$body = Element('thread.html', array(
|
$body = Element('thread.html', array(
|
||||||
'board' => $board,
|
'board' => $board,
|
||||||
|
@ -2506,7 +2506,7 @@ function buildThread50($id, $return = false, $mod = false, $thread = null, $anti
|
||||||
'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)),
|
'antibot' => $mod ? false : ($antibot ? $antibot : create_antibot($board['uri'], $id)),
|
||||||
'boardlist' => createBoardlist($mod),
|
'boardlist' => createBoardlist($mod),
|
||||||
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index'])
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($return) {
|
if ($return) {
|
||||||
return $body;
|
return $body;
|
||||||
|
@ -2585,7 +2585,7 @@ function hcf($a, $b){
|
||||||
$b = $a-$b;
|
$b = $a-$b;
|
||||||
$a = $a-$b;
|
$a = $a-$b;
|
||||||
}
|
}
|
||||||
if ($b==(round($b/$a))*$a)
|
if ($b==(round($b/$a))*$a)
|
||||||
$gcd=$a;
|
$gcd=$a;
|
||||||
else {
|
else {
|
||||||
for ($i=round($a/2);$i;$i--) {
|
for ($i=round($a/2);$i;$i--) {
|
||||||
|
@ -2880,7 +2880,7 @@ function process_filenames($file, $board_dir, $multiple, $i){
|
||||||
|
|
||||||
if ($multiple)
|
if ($multiple)
|
||||||
$file['file_id'] .= "-$i";
|
$file['file_id'] .= "-$i";
|
||||||
|
|
||||||
$file['file'] = $board_dir . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension'];
|
$file['file'] = $board_dir . $config['dir']['img'] . $file['file_id'] . '.' . $file['extension'];
|
||||||
$file['thumb'] = $board_dir . $config['dir']['thumb'] . $file['file_id'] . '.' . ($config['thumb_ext'] ? $config['thumb_ext'] : $file['extension']);
|
$file['thumb'] = $board_dir . $config['dir']['thumb'] . $file['file_id'] . '.' . ($config['thumb_ext'] ? $config['thumb_ext'] : $file['extension']);
|
||||||
return $file;
|
return $file;
|
||||||
|
|
|
@ -11,7 +11,7 @@ class Image {
|
||||||
public $src, $format, $image, $size;
|
public $src, $format, $image, $size;
|
||||||
public function __construct($src, $format = false, $size = false) {
|
public function __construct($src, $format = false, $size = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$this->src = $src;
|
$this->src = $src;
|
||||||
$this->format = $format;
|
$this->format = $format;
|
||||||
|
|
||||||
|
@ -25,21 +25,21 @@ class Image {
|
||||||
error(_('Unsupported file format: ') . $this->format);
|
error(_('Unsupported file format: ') . $this->format);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->image = new $classname($this, $size);
|
$this->image = new $classname($this, $size);
|
||||||
|
|
||||||
if (!$this->image->valid()) {
|
if (!$this->image->valid()) {
|
||||||
$this->delete();
|
$this->delete();
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->size = (object)array('width' => $this->image->_width(), 'height' => $this->image->_height());
|
$this->size = (object)array('width' => $this->image->_width(), 'height' => $this->image->_height());
|
||||||
if ($this->size->width < 1 || $this->size->height < 1) {
|
if ($this->size->width < 1 || $this->size->height < 1) {
|
||||||
$this->delete();
|
$this->delete();
|
||||||
error($config['error']['invalidimg']);
|
error($config['error']['invalidimg']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resize($extension, $max_width, $max_height) {
|
public function resize($extension, $max_width, $max_height) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -63,16 +63,16 @@ class Image {
|
||||||
error(_('Unsupported file format: ') . $extension);
|
error(_('Unsupported file format: ') . $extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumb = new $classname(false);
|
$thumb = new $classname(false);
|
||||||
$thumb->src = $this->src;
|
$thumb->src = $this->src;
|
||||||
$thumb->format = $this->format;
|
$thumb->format = $this->format;
|
||||||
$thumb->original_width = $this->size->width;
|
$thumb->original_width = $this->size->width;
|
||||||
$thumb->original_height = $this->size->height;
|
$thumb->original_height = $this->size->height;
|
||||||
|
|
||||||
$x_ratio = $max_width / $this->size->width;
|
$x_ratio = $max_width / $this->size->width;
|
||||||
$y_ratio = $max_height / $this->size->height;
|
$y_ratio = $max_height / $this->size->height;
|
||||||
|
|
||||||
if (($this->size->width <= $max_width) && ($this->size->height <= $max_height)) {
|
if (($this->size->width <= $max_width) && ($this->size->height <= $max_height)) {
|
||||||
$width = $this->size->width;
|
$width = $this->size->width;
|
||||||
$height = $this->size->height;
|
$height = $this->size->height;
|
||||||
|
@ -83,16 +83,16 @@ class Image {
|
||||||
$width = ceil($y_ratio * $this->size->width);
|
$width = ceil($y_ratio * $this->size->width);
|
||||||
$height = $max_height;
|
$height = $max_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
$thumb->_resize($this->image->image, $width, $height);
|
$thumb->_resize($this->image->image, $width, $height);
|
||||||
|
|
||||||
return $thumb;
|
return $thumb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function to($dst) {
|
public function to($dst) {
|
||||||
$this->image->to($dst);
|
$this->image->to($dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
file_unlink($this->src);
|
file_unlink($this->src);
|
||||||
}
|
}
|
||||||
|
@ -115,26 +115,26 @@ class ImageGD {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageBase extends ImageGD {
|
class ImageBase extends ImageGD {
|
||||||
public $image, $src, $original, $original_width, $original_height, $width, $height;
|
public $image, $src, $original, $original_width, $original_height, $width, $height;
|
||||||
public function valid() {
|
public function valid() {
|
||||||
return (bool)$this->image;
|
return (bool)$this->image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct($img, $size = false) {
|
public function __construct($img, $size = false) {
|
||||||
if (method_exists($this, 'init'))
|
if (method_exists($this, 'init'))
|
||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
if ($size && $size[0] > 0 && $size[1] > 0) {
|
if ($size && $size[0] > 0 && $size[1] > 0) {
|
||||||
$this->width = $size[0];
|
$this->width = $size[0];
|
||||||
$this->height = $size[1];
|
$this->height = $size[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($img !== false) {
|
if ($img !== false) {
|
||||||
$this->src = $img->src;
|
$this->src = $img->src;
|
||||||
$this->from();
|
$this->from();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _width() {
|
public function _width() {
|
||||||
if (method_exists($this, 'width'))
|
if (method_exists($this, 'width'))
|
||||||
return $this->width();
|
return $this->width();
|
||||||
|
@ -157,7 +157,7 @@ class ImageBase extends ImageGD {
|
||||||
$this->original = &$original;
|
$this->original = &$original;
|
||||||
$this->width = $width;
|
$this->width = $width;
|
||||||
$this->height = $height;
|
$this->height = $height;
|
||||||
|
|
||||||
if (method_exists($this, 'resize'))
|
if (method_exists($this, 'resize'))
|
||||||
$this->resize();
|
$this->resize();
|
||||||
else
|
else
|
||||||
|
@ -200,31 +200,31 @@ class ImageImagick extends ImageBase {
|
||||||
}
|
}
|
||||||
public function resize() {
|
public function resize() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '')) {
|
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '')) {
|
||||||
$this->image = new Imagick();
|
$this->image = new Imagick();
|
||||||
$this->image->setFormat('gif');
|
$this->image->setFormat('gif');
|
||||||
|
|
||||||
$keep_frames = array();
|
$keep_frames = array();
|
||||||
for ($i = 0; $i < $this->original->getNumberImages(); $i += floor($this->original->getNumberImages() / $config['thumb_keep_animation_frames']))
|
for ($i = 0; $i < $this->original->getNumberImages(); $i += floor($this->original->getNumberImages() / $config['thumb_keep_animation_frames']))
|
||||||
$keep_frames[] = $i;
|
$keep_frames[] = $i;
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$delay = 0;
|
$delay = 0;
|
||||||
foreach ($this->original as $frame) {
|
foreach ($this->original as $frame) {
|
||||||
$delay += $frame->getImageDelay();
|
$delay += $frame->getImageDelay();
|
||||||
|
|
||||||
if (in_array($i, $keep_frames)) {
|
if (in_array($i, $keep_frames)) {
|
||||||
// $frame->scaleImage($this->width, $this->height, false);
|
// $frame->scaleImage($this->width, $this->height, false);
|
||||||
$frame->sampleImage($this->width, $this->height);
|
$frame->sampleImage($this->width, $this->height);
|
||||||
$frame->setImagePage($this->width, $this->height, 0, 0);
|
$frame->setImagePage($this->width, $this->height, 0, 0);
|
||||||
$frame->setImageDelay($delay);
|
$frame->setImageDelay($delay);
|
||||||
$delay = 0;
|
$delay = 0;
|
||||||
|
|
||||||
$this->image->addImage($frame->getImage());
|
$this->image->addImage($frame->getImage());
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->image = clone $this->original;
|
$this->image = clone $this->original;
|
||||||
$this->image->scaleImage($this->width, $this->height, false);
|
$this->image->scaleImage($this->width, $this->height, false);
|
||||||
|
@ -235,15 +235,15 @@ class ImageImagick extends ImageBase {
|
||||||
|
|
||||||
class ImageConvert extends ImageBase {
|
class ImageConvert extends ImageBase {
|
||||||
public $width, $height, $temp, $gm = false, $gifsicle = false;
|
public $width, $height, $temp, $gm = false, $gifsicle = false;
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($config['thumb_method'] == 'gm' || $config['thumb_method'] == 'gm+gifsicle')
|
if ($config['thumb_method'] == 'gm' || $config['thumb_method'] == 'gm+gifsicle')
|
||||||
$this->gm = true;
|
$this->gm = true;
|
||||||
if ($config['thumb_method'] == 'convert+gifsicle' || $config['thumb_method'] == 'gm+gifsicle')
|
if ($config['thumb_method'] == 'convert+gifsicle' || $config['thumb_method'] == 'gm+gifsicle')
|
||||||
$this->gifsicle = true;
|
$this->gifsicle = true;
|
||||||
|
|
||||||
$this->temp = false;
|
$this->temp = false;
|
||||||
}
|
}
|
||||||
public function get_size($src, $try_gd_first = true) {
|
public function get_size($src, $try_gd_first = true) {
|
||||||
|
@ -265,7 +265,7 @@ class ImageConvert extends ImageBase {
|
||||||
if ($size) {
|
if ($size) {
|
||||||
$this->width = $size[0];
|
$this->width = $size[0];
|
||||||
$this->height = $size[1];
|
$this->height = $size[1];
|
||||||
|
|
||||||
$this->image = true;
|
$this->image = true;
|
||||||
} else {
|
} else {
|
||||||
// mark as invalid
|
// mark as invalid
|
||||||
|
@ -274,7 +274,7 @@ class ImageConvert extends ImageBase {
|
||||||
}
|
}
|
||||||
public function to($src) {
|
public function to($src) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (!$this->temp) {
|
if (!$this->temp) {
|
||||||
if ($config['strip_exif']) {
|
if ($config['strip_exif']) {
|
||||||
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
if($error = shell_exec_error(($this->gm ? 'gm ' : '') . 'convert ' .
|
||||||
|
@ -306,16 +306,16 @@ class ImageConvert extends ImageBase {
|
||||||
}
|
}
|
||||||
public function resize() {
|
public function resize() {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if ($this->temp) {
|
if ($this->temp) {
|
||||||
// remove old
|
// remove old
|
||||||
$this->destroy();
|
$this->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->temp = tempnam($config['tmp'], 'convert') . ($config['thumb_ext'] == '' ? '' : '.' . $config['thumb_ext']);
|
$this->temp = tempnam($config['tmp'], 'convert') . ($config['thumb_ext'] == '' ? '' : '.' . $config['thumb_ext']);
|
||||||
|
|
||||||
$config['thumb_keep_animation_frames'] = (int)$config['thumb_keep_animation_frames'];
|
$config['thumb_keep_animation_frames'] = (int)$config['thumb_keep_animation_frames'];
|
||||||
|
|
||||||
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) {
|
if ($this->format == 'gif' && ($config['thumb_ext'] == 'gif' || $config['thumb_ext'] == '') && $config['thumb_keep_animation_frames'] > 1) {
|
||||||
if ($this->gifsicle) {
|
if ($this->gifsicle) {
|
||||||
if (($error = shell_exec("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " .
|
if (($error = shell_exec("gifsicle -w --unoptimize -O2 --resize {$this->width}x{$this->height} < " .
|
||||||
|
@ -380,7 +380,7 @@ class ImageConvert extends ImageBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For when -auto-orient doesn't exist (older versions)
|
// For when -auto-orient doesn't exist (older versions)
|
||||||
static public function jpeg_exif_orientation($src, $exif = false) {
|
static public function jpeg_exif_orientation($src, $exif = false) {
|
||||||
if (!$exif) {
|
if (!$exif) {
|
||||||
|
@ -398,16 +398,16 @@ class ImageConvert extends ImageBase {
|
||||||
// 8888
|
// 8888
|
||||||
// 88
|
// 88
|
||||||
// 88
|
// 88
|
||||||
|
|
||||||
return '-flop';
|
return '-flop';
|
||||||
case 3:
|
case 3:
|
||||||
|
|
||||||
// 88
|
// 88
|
||||||
// 88
|
// 88
|
||||||
// 8888
|
// 8888
|
||||||
// 88
|
// 88
|
||||||
// 888888
|
// 888888
|
||||||
|
|
||||||
return '-flip -flop';
|
return '-flip -flop';
|
||||||
case 4:
|
case 4:
|
||||||
// 88
|
// 88
|
||||||
|
@ -415,31 +415,31 @@ class ImageConvert extends ImageBase {
|
||||||
// 8888
|
// 8888
|
||||||
// 88
|
// 88
|
||||||
// 888888
|
// 888888
|
||||||
|
|
||||||
return '-flip';
|
return '-flip';
|
||||||
case 5:
|
case 5:
|
||||||
// 8888888888
|
// 8888888888
|
||||||
// 88 88
|
// 88 88
|
||||||
// 88
|
// 88
|
||||||
|
|
||||||
return '-rotate 90 -flop';
|
return '-rotate 90 -flop';
|
||||||
case 6:
|
case 6:
|
||||||
// 88
|
// 88
|
||||||
// 88 88
|
// 88 88
|
||||||
// 8888888888
|
// 8888888888
|
||||||
|
|
||||||
return '-rotate 90';
|
return '-rotate 90';
|
||||||
case 7:
|
case 7:
|
||||||
// 88
|
// 88
|
||||||
// 88 88
|
// 88 88
|
||||||
// 8888888888
|
// 8888888888
|
||||||
|
|
||||||
return '-rotate "-90" -flop';
|
return '-rotate "-90" -flop';
|
||||||
case 8:
|
case 8:
|
||||||
// 8888888888
|
// 8888888888
|
||||||
// 88 88
|
// 88 88
|
||||||
// 88
|
// 88
|
||||||
|
|
||||||
return '-rotate "-90"';
|
return '-rotate "-90"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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());
|
||||||
|
@ -27,17 +30,17 @@ function load_twig() {
|
||||||
|
|
||||||
function Element($templateFile, array $options) {
|
function Element($templateFile, array $options) {
|
||||||
global $config, $debug, $twig, $build_pages;
|
global $config, $debug, $twig, $build_pages;
|
||||||
|
|
||||||
if (!$twig)
|
if (!$twig)
|
||||||
load_twig();
|
load_twig();
|
||||||
|
|
||||||
if (function_exists('create_pm_header') && ((isset($options['mod']) && $options['mod']) || isset($options['__mod'])) && !preg_match('!^mod/!', $templateFile)) {
|
if (function_exists('create_pm_header') && ((isset($options['mod']) && $options['mod']) || isset($options['__mod'])) && !preg_match('!^mod/!', $templateFile)) {
|
||||||
$options['pm'] = create_pm_header();
|
$options['pm'] = create_pm_header();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($options['body']) && $config['debug']) {
|
if (isset($options['body']) && $config['debug']) {
|
||||||
$_debug = $debug;
|
$_debug = $debug;
|
||||||
|
|
||||||
if (isset($debug['start'])) {
|
if (isset($debug['start'])) {
|
||||||
$_debug['time']['total'] = '~' . round((microtime(true) - $_debug['start']) * 1000, 2) . 'ms';
|
$_debug['time']['total'] = '~' . round((microtime(true) - $_debug['start']) * 1000, 2) . 'ms';
|
||||||
$_debug['time']['init'] = '~' . round(($_debug['start_debug'] - $_debug['start']) * 1000, 2) . 'ms';
|
$_debug['time']['init'] = '~' . round(($_debug['start_debug'] - $_debug['start']) * 1000, 2) . 'ms';
|
||||||
|
@ -55,18 +58,17 @@ function Element($templateFile, array $options) {
|
||||||
str_replace("\n", '<br/>', utf8tohtml(print_r($_debug, true))) .
|
str_replace("\n", '<br/>', utf8tohtml(print_r($_debug, true))) .
|
||||||
'</pre>';
|
'</pre>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the template file
|
// Read the template file
|
||||||
if (@file_get_contents("{$config['dir']['template']}/${templateFile}")) {
|
if (@file_get_contents("{$config['dir']['template']}/${templateFile}")) {
|
||||||
$body = $twig->render($templateFile, $options);
|
$body = $twig->render($templateFile, $options);
|
||||||
|
|
||||||
if ($config['minify_html'] && preg_match('/\.html$/', $templateFile)) {
|
if ($config['minify_html'] && preg_match('/\.html$/', $templateFile)) {
|
||||||
$body = trim(preg_replace("/[\t\r\n]/", '', $body));
|
$body = trim(preg_replace("/[\t\r\n]/", '', $body));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
} else {
|
} else {
|
||||||
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']}'!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
149
install.php
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// 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();
|
||||||
}
|
}
|
||||||
|
@ -39,41 +39,41 @@ function checkGifsicle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($config['has_installed'])) {
|
if (file_exists($config['has_installed'])) {
|
||||||
|
|
||||||
// Check the version number
|
// Check the version number
|
||||||
$version = trim(file_get_contents($config['has_installed']));
|
$version = trim(file_get_contents($config['has_installed']));
|
||||||
if (empty($version))
|
if (empty($version))
|
||||||
$version = 'v0.9.1';
|
$version = 'v0.9.1';
|
||||||
|
|
||||||
function __query($sql) {
|
function __query($sql) {
|
||||||
sql_open();
|
sql_open();
|
||||||
|
|
||||||
if (mysql_version() >= 50503)
|
if (mysql_version() >= 50503)
|
||||||
return query($sql);
|
return query($sql);
|
||||||
else
|
else
|
||||||
return query(str_replace('utf8mb4', 'utf8', $sql));
|
return query(str_replace('utf8mb4', 'utf8', $sql));
|
||||||
}
|
}
|
||||||
|
|
||||||
$boards = listBoards();
|
$boards = listBoards();
|
||||||
|
|
||||||
switch ($version) {
|
switch ($version) {
|
||||||
case 'v0.9':
|
case 'v0.9':
|
||||||
case 'v0.9.1':
|
case 'v0.9.1':
|
||||||
// Upgrade to v0.9.2-dev
|
// Upgrade to v0.9.2-dev
|
||||||
|
|
||||||
foreach ($boards as &$_board) {
|
foreach ($boards as &$_board) {
|
||||||
// Add `capcode` field after `trip`
|
// Add `capcode` field after `trip`
|
||||||
query(sprintf("ALTER TABLE `posts_%s` ADD `capcode` VARCHAR( 50 ) NULL AFTER `trip`", $_board['uri'])) or error(db_error());
|
query(sprintf("ALTER TABLE `posts_%s` ADD `capcode` VARCHAR( 50 ) NULL AFTER `trip`", $_board['uri'])) or error(db_error());
|
||||||
|
|
||||||
// Resize `trip` to 15 characters
|
// Resize `trip` to 15 characters
|
||||||
query(sprintf("ALTER TABLE `posts_%s` CHANGE `trip` `trip` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", $_board['uri'])) or error(db_error());
|
query(sprintf("ALTER TABLE `posts_%s` CHANGE `trip` `trip` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", $_board['uri'])) or error(db_error());
|
||||||
}
|
}
|
||||||
case 'v0.9.2-dev':
|
case 'v0.9.2-dev':
|
||||||
// Upgrade to v0.9.2-dev-1
|
// Upgrade to v0.9.2-dev-1
|
||||||
|
|
||||||
// New table: `theme_settings`
|
// New table: `theme_settings`
|
||||||
query("CREATE TABLE IF NOT EXISTS `theme_settings` ( `name` varchar(40) NOT NULL, `value` text, UNIQUE KEY `name` (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;") or error(db_error());
|
query("CREATE TABLE IF NOT EXISTS `theme_settings` ( `name` varchar(40) NOT NULL, `value` text, UNIQUE KEY `name` (`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;") or error(db_error());
|
||||||
|
|
||||||
// New table: `news`
|
// New table: `news`
|
||||||
query("CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `time` int(11) NOT NULL, `subject` text NOT NULL, `body` text NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;") or error(db_error());
|
query("CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `time` int(11) NOT NULL, `subject` text NOT NULL, `body` text NOT NULL, UNIQUE KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;") or error(db_error());
|
||||||
case 'v0.9.2.1-dev':
|
case 'v0.9.2.1-dev':
|
||||||
|
@ -81,7 +81,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
// Fix broken version number/mistake
|
// Fix broken version number/mistake
|
||||||
$version = 'v0.9.2-dev-1';
|
$version = 'v0.9.2-dev-1';
|
||||||
// Upgrade to v0.9.2-dev-2
|
// Upgrade to v0.9.2-dev-2
|
||||||
|
|
||||||
foreach ($boards as &$_board) {
|
foreach ($boards as &$_board) {
|
||||||
// Increase field sizes
|
// Increase field sizes
|
||||||
query(sprintf("ALTER TABLE `posts_%s` CHANGE `subject` `subject` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL", $_board['uri'])) or error(db_error());
|
query(sprintf("ALTER TABLE `posts_%s` CHANGE `subject` `subject` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL", $_board['uri'])) or error(db_error());
|
||||||
|
@ -89,7 +89,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
}
|
}
|
||||||
case 'v0.9.2-dev-2':
|
case 'v0.9.2-dev-2':
|
||||||
// Upgrade to v0.9.2-dev-3 (v0.9.2)
|
// Upgrade to v0.9.2-dev-3 (v0.9.2)
|
||||||
|
|
||||||
foreach ($boards as &$_board) {
|
foreach ($boards as &$_board) {
|
||||||
// Add `custom_fields` field
|
// Add `custom_fields` field
|
||||||
query(sprintf("ALTER TABLE `posts_%s` ADD `embed` TEXT NULL", $_board['uri'])) or error(db_error());
|
query(sprintf("ALTER TABLE `posts_%s` ADD `embed` TEXT NULL", $_board['uri'])) or error(db_error());
|
||||||
|
@ -97,7 +97,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
case 'v0.9.2-dev-3': // v0.9.2-dev-3 == v0.9.2
|
case 'v0.9.2-dev-3': // v0.9.2-dev-3 == v0.9.2
|
||||||
case 'v0.9.2':
|
case 'v0.9.2':
|
||||||
// Upgrade to v0.9.3-dev-1
|
// Upgrade to v0.9.3-dev-1
|
||||||
|
|
||||||
// Upgrade `theme_settings` table
|
// Upgrade `theme_settings` table
|
||||||
query("TRUNCATE TABLE `theme_settings`") or error(db_error());
|
query("TRUNCATE TABLE `theme_settings`") or error(db_error());
|
||||||
query("ALTER TABLE `theme_settings` ADD `theme` VARCHAR( 40 ) NOT NULL FIRST") or error(db_error());
|
query("ALTER TABLE `theme_settings` ADD `theme` VARCHAR( 40 ) NOT NULL FIRST") or error(db_error());
|
||||||
|
@ -129,7 +129,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
foreach ($boards as &$board) {
|
foreach ($boards as &$board) {
|
||||||
$tables[] = "posts_{$board['uri']}";
|
$tables[] = "posts_{$board['uri']}";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tables as &$table) {
|
foreach ($tables as &$table) {
|
||||||
query("ALTER TABLE `{$table}` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci") or error(db_error());
|
query("ALTER TABLE `{$table}` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci") or error(db_error());
|
||||||
}
|
}
|
||||||
|
@ -153,10 +153,10 @@ if (file_exists($config['has_installed'])) {
|
||||||
query("ALTER TABLE `boards` DROP PRIMARY KEY") or error(db_error());
|
query("ALTER TABLE `boards` DROP PRIMARY KEY") or error(db_error());
|
||||||
query("ALTER TABLE `reports` DROP INDEX `id`") or error(db_error());
|
query("ALTER TABLE `reports` DROP INDEX `id`") or error(db_error());
|
||||||
query("ALTER TABLE `boards` DROP INDEX `uri`") or error(db_error());
|
query("ALTER TABLE `boards` DROP INDEX `uri`") or error(db_error());
|
||||||
|
|
||||||
query("ALTER IGNORE TABLE `robot` ADD PRIMARY KEY (`hash`)") or error(db_error());
|
query("ALTER IGNORE TABLE `robot` ADD PRIMARY KEY (`hash`)") or error(db_error());
|
||||||
query("ALTER TABLE `bans` ADD FULLTEXT (`ip`)") or error(db_error());
|
query("ALTER TABLE `bans` ADD FULLTEXT (`ip`)") or error(db_error());
|
||||||
query("ALTER TABLE `ip_notes` ADD INDEX (`ip`)") or error(db_error());
|
query("ALTER TABLE `ip_notes` ADD INDEX (`ip`)") or error(db_error());
|
||||||
query("ALTER TABLE `modlogs` ADD INDEX (`time`)") or error(db_error());
|
query("ALTER TABLE `modlogs` ADD INDEX (`time`)") or error(db_error());
|
||||||
query("ALTER TABLE `boards` ADD PRIMARY KEY(`uri`)") or error(db_error());
|
query("ALTER TABLE `boards` ADD PRIMARY KEY(`uri`)") or error(db_error());
|
||||||
query("ALTER TABLE `mutes` ADD INDEX (`ip`)") or error(db_error());
|
query("ALTER TABLE `mutes` ADD INDEX (`ip`)") or error(db_error());
|
||||||
|
@ -174,9 +174,9 @@ if (file_exists($config['has_installed'])) {
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="?confirm=1">I have read and understood the agreement. Proceed to upgrading.</a>
|
<a href="?confirm=1">I have read and understood the agreement. Proceed to upgrading.</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
file_write($config['has_installed'], 'v0.9.4-dev-2');
|
file_write($config['has_installed'], 'v0.9.4-dev-2');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'v0.9.4-dev-3':
|
case 'v0.9.4-dev-3':
|
||||||
|
@ -194,14 +194,14 @@ if (file_exists($config['has_installed'])) {
|
||||||
}
|
}
|
||||||
query("CREATE TABLE IF NOT EXISTS `cites` ( `board` varchar(8) NOT NULL, `post` int(11) NOT NULL, `target_board` varchar(8) NOT NULL, `target` int(11) NOT NULL, KEY `target` (`target_board`,`target`), KEY `post` (`board`,`post`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;") or error(db_error());
|
query("CREATE TABLE IF NOT EXISTS `cites` ( `board` varchar(8) NOT NULL, `post` int(11) NOT NULL, `target_board` varchar(8) NOT NULL, `target` int(11) NOT NULL, KEY `target` (`target_board`,`target`), KEY `post` (`board`,`post`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;") or error(db_error());
|
||||||
case 'v0.9.5-dev-2':
|
case 'v0.9.5-dev-2':
|
||||||
query("ALTER TABLE `boards`
|
query("ALTER TABLE `boards`
|
||||||
CHANGE `uri` `uri` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
CHANGE `uri` `uri` VARCHAR( 15 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||||
CHANGE `title` `title` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
CHANGE `title` `title` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||||
CHANGE `subtitle` `subtitle` VARCHAR( 120 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL") or error(db_error());
|
CHANGE `subtitle` `subtitle` VARCHAR( 120 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL") or error(db_error());
|
||||||
case 'v0.9.5-dev-3':
|
case 'v0.9.5-dev-3':
|
||||||
// v0.9.5
|
// v0.9.5
|
||||||
case 'v0.9.5':
|
case 'v0.9.5':
|
||||||
query("ALTER TABLE `boards`
|
query("ALTER TABLE `boards`
|
||||||
CHANGE `uri` `uri` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
CHANGE `uri` `uri` VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||||
CHANGE `title` `title` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
CHANGE `title` `title` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
|
||||||
CHANGE `subtitle` `subtitle` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL") or error(db_error());
|
CHANGE `subtitle` `subtitle` TINYTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL") or error(db_error());
|
||||||
|
@ -228,12 +228,12 @@ if (file_exists($config['has_installed'])) {
|
||||||
$query->bindValue(':newboard', $board['uri']);
|
$query->bindValue(':newboard', $board['uri']);
|
||||||
$query->bindValue(':oldboard', $board['id']);
|
$query->bindValue(':oldboard', $board['id']);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
$query = prepare("UPDATE `modlogs` SET `board` = :newboard WHERE `board` = :oldboard");
|
$query = prepare("UPDATE `modlogs` SET `board` = :newboard WHERE `board` = :oldboard");
|
||||||
$query->bindValue(':newboard', $board['uri']);
|
$query->bindValue(':newboard', $board['uri']);
|
||||||
$query->bindValue(':oldboard', $board['id']);
|
$query->bindValue(':oldboard', $board['id']);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
$query = prepare("UPDATE `reports` SET `board` = :newboard WHERE `board` = :oldboard");
|
$query = prepare("UPDATE `reports` SET `board` = :newboard WHERE `board` = :oldboard");
|
||||||
$query->bindValue(':newboard', $board['uri']);
|
$query->bindValue(':newboard', $board['uri']);
|
||||||
$query->bindValue(':oldboard', $board['id']);
|
$query->bindValue(':oldboard', $board['id']);
|
||||||
|
@ -271,10 +271,10 @@ if (file_exists($config['has_installed'])) {
|
||||||
if (strlen($user['password']) == 40) {
|
if (strlen($user['password']) == 40) {
|
||||||
mt_srand(microtime(true) * 100000 + memory_get_usage(true));
|
mt_srand(microtime(true) * 100000 + memory_get_usage(true));
|
||||||
$salt = md5(uniqid(mt_rand(), true));
|
$salt = md5(uniqid(mt_rand(), true));
|
||||||
|
|
||||||
$user['salt'] = $salt;
|
$user['salt'] = $salt;
|
||||||
$user['password'] = hash('sha256', $user['salt'] . $user['password']);
|
$user['password'] = hash('sha256', $user['salt'] . $user['password']);
|
||||||
|
|
||||||
$_query = prepare("UPDATE `mods` SET `password` = :password, `salt` = :salt WHERE `id` = :id");
|
$_query = prepare("UPDATE `mods` SET `password` = :password, `salt` = :salt WHERE `id` = :id");
|
||||||
$_query->bindValue(':id', $user['id']);
|
$_query->bindValue(':id', $user['id']);
|
||||||
$_query->bindValue(':password', $user['password']);
|
$_query->bindValue(':password', $user['password']);
|
||||||
|
@ -306,7 +306,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
CHANGE `embed` `embed` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
CHANGE `embed` `embed` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
|
||||||
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;", $board['uri'])) or error(db_error());
|
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;", $board['uri'])) or error(db_error());
|
||||||
}
|
}
|
||||||
|
|
||||||
__query("ALTER TABLE `antispam`
|
__query("ALTER TABLE `antispam`
|
||||||
CHANGE `board` `board` VARCHAR( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
|
CHANGE `board` `board` VARCHAR( 120 ) CHARACTER SET ASCII COLLATE ascii_general_ci NOT NULL ,
|
||||||
CHANGE `hash` `hash` CHAR( 40 ) CHARACTER SET ASCII COLLATE ascii_bin NOT NULL ,
|
CHANGE `hash` `hash` CHAR( 40 ) CHARACTER SET ASCII COLLATE ascii_bin NOT NULL ,
|
||||||
|
@ -466,44 +466,44 @@ if (file_exists($config['has_installed'])) {
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1") or error(db_error());
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1") or error(db_error());
|
||||||
$listquery = query("SELECT * FROM ``bans`` ORDER BY `id`") or error(db_error());
|
$listquery = query("SELECT * FROM ``bans`` ORDER BY `id`") or error(db_error());
|
||||||
while ($ban = $listquery->fetch(PDO::FETCH_ASSOC)) {
|
while ($ban = $listquery->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$query = prepare("INSERT INTO ``bans_new_temp`` VALUES
|
$query = prepare("INSERT INTO ``bans_new_temp`` VALUES
|
||||||
(NULL, :ipstart, :ipend, :created, :expires, :board, :creator, :reason, :seen, NULL)");
|
(NULL, :ipstart, :ipend, :created, :expires, :board, :creator, :reason, :seen, NULL)");
|
||||||
|
|
||||||
$range = Bans::parse_range($ban['ip']);
|
$range = Bans::parse_range($ban['ip']);
|
||||||
if ($range === false) {
|
if ($range === false) {
|
||||||
// Invalid retard ban; just skip it.
|
// Invalid retard ban; just skip it.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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(':created', $ban['set']);
|
$query->bindValue(':created', $ban['set']);
|
||||||
|
|
||||||
if ($ban['expires'])
|
if ($ban['expires'])
|
||||||
$query->bindValue(':expires', $ban['expires']);
|
$query->bindValue(':expires', $ban['expires']);
|
||||||
else
|
else
|
||||||
$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);
|
||||||
|
|
||||||
$query->bindValue(':creator', $ban['mod']);
|
$query->bindValue(':creator', $ban['mod']);
|
||||||
|
|
||||||
if ($ban['reason'])
|
if ($ban['reason'])
|
||||||
$query->bindValue(':reason', $ban['reason']);
|
$query->bindValue(':reason', $ban['reason']);
|
||||||
else
|
else
|
||||||
$query->bindValue(':reason', null, PDO::PARAM_NULL);
|
$query->bindValue(':reason', null, PDO::PARAM_NULL);
|
||||||
|
|
||||||
$query->bindValue(':seen', $ban['seen']);
|
$query->bindValue(':seen', $ban['seen']);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop old bans table
|
// Drop old bans table
|
||||||
query("DROP TABLE ``bans``") or error(db_error());
|
query("DROP TABLE ``bans``") or error(db_error());
|
||||||
// Replace with new table
|
// Replace with new table
|
||||||
|
@ -535,9 +535,9 @@ if (file_exists($config['has_installed'])) {
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="?confirm2=1">I have read and understood the agreement. Proceed to upgrading.</a>
|
<a href="?confirm2=1">I have read and understood the agreement. Proceed to upgrading.</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
file_write($config['has_installed'], '4.4.97');
|
file_write($config['has_installed'], '4.4.97');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '4.4.98-pre':
|
case '4.4.98-pre':
|
||||||
|
@ -553,9 +553,9 @@ if (file_exists($config['has_installed'])) {
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="?confirm3=1">I have read and understood the warning. Proceed to upgrading.</a>
|
<a href="?confirm3=1">I have read and understood the warning. Proceed to upgrading.</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
file_write($config['has_installed'], '4.5.2');
|
file_write($config['has_installed'], '4.5.2');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +614,7 @@ if (file_exists($config['has_installed'])) {
|
||||||
|
|
||||||
// Update version number
|
// Update version number
|
||||||
file_write($config['has_installed'], VERSION);
|
file_write($config['has_installed'], VERSION);
|
||||||
|
|
||||||
$page['title'] = 'Upgraded';
|
$page['title'] = 'Upgraded';
|
||||||
$page['body'] = '<p style="text-align:center">Successfully upgraded from ' . $version . ' to <strong>' . VERSION . '</strong>.</p>';
|
$page['body'] = '<p style="text-align:center">Successfully upgraded from ' . $version . ' to <strong>' . VERSION . '</strong>.</p>';
|
||||||
break;
|
break;
|
||||||
|
@ -626,8 +626,8 @@ if (file_exists($config['has_installed'])) {
|
||||||
$page['title'] = 'Already installed';
|
$page['title'] = 'Already installed';
|
||||||
$page['body'] = '<p style="text-align:center">It appears that vichan is already installed (' . $version . ') and there is nothing to upgrade! Delete <strong>' . $config['has_installed'] . '</strong> to reinstall.</p>';
|
$page['body'] = '<p style="text-align:center">It appears that vichan is already installed (' . $version . ') and there is nothing to upgrade! Delete <strong>' . $config['has_installed'] . '</strong> to reinstall.</p>';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
die(Element('page.html', $page));
|
die(Element('page.html', $page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,11 +659,11 @@ if ($step == 0) {
|
||||||
<p style="text-align:center">
|
<p style="text-align:center">
|
||||||
<a href="?step=1">I have read and understood the agreement. Proceed to installation.</a>
|
<a href="?step=1">I have read and understood the agreement. Proceed to installation.</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
echo Element('page.html', $page);
|
echo Element('page.html', $page);
|
||||||
} elseif ($step == 1) {
|
} elseif ($step == 1) {
|
||||||
$page['title'] = 'Pre-installation test';
|
$page['title'] = 'Pre-installation test';
|
||||||
|
|
||||||
$can_exec = true;
|
$can_exec = true;
|
||||||
if (!function_exists('shell_exec'))
|
if (!function_exists('shell_exec'))
|
||||||
$can_exec = false;
|
$can_exec = false;
|
||||||
|
@ -673,12 +673,12 @@ if ($step == 0) {
|
||||||
$can_exec = false;
|
$can_exec = false;
|
||||||
elseif (trim(shell_exec('echo "TEST"')) !== 'TEST')
|
elseif (trim(shell_exec('echo "TEST"')) !== 'TEST')
|
||||||
$can_exec = false;
|
$can_exec = false;
|
||||||
|
|
||||||
if (!defined('PHP_VERSION_ID')) {
|
if (!defined('PHP_VERSION_ID')) {
|
||||||
$version = explode('.', PHP_VERSION);
|
$version = explode('.', PHP_VERSION);
|
||||||
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
|
define('PHP_VERSION_ID', ($version[0] * 10000 + $version[1] * 100 + $version[2]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Required extensions
|
// Required extensions
|
||||||
$extensions = array(
|
$extensions = array(
|
||||||
'PDO' => array(
|
'PDO' => array(
|
||||||
|
@ -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.'
|
||||||
),
|
),
|
||||||
|
@ -854,7 +854,7 @@ if ($step == 0) {
|
||||||
);
|
);
|
||||||
|
|
||||||
$config['font_awesome'] = true;
|
$config['font_awesome'] = true;
|
||||||
|
|
||||||
$additional_config = array();
|
$additional_config = array();
|
||||||
foreach ($tests as $test) {
|
foreach ($tests as $test) {
|
||||||
if ($test['result'] && isset($test['effect'])) {
|
if ($test['result'] && isset($test['effect'])) {
|
||||||
|
@ -877,10 +877,10 @@ if ($step == 0) {
|
||||||
} elseif ($step == 2) {
|
} elseif ($step == 2) {
|
||||||
// Basic config
|
// Basic config
|
||||||
$page['title'] = 'Configuration';
|
$page['title'] = 'Configuration';
|
||||||
|
|
||||||
$config['cookies']['salt'] = substr(base64_encode(sha1(rand())), 0, 30);
|
$config['cookies']['salt'] = substr(base64_encode(sha1(rand())), 0, 30);
|
||||||
$config['secure_trip_salt'] = substr(base64_encode(sha1(rand())), 0, 30);
|
$config['secure_trip_salt'] = substr(base64_encode(sha1(rand())), 0, 30);
|
||||||
|
|
||||||
echo Element('page.html', array(
|
echo Element('page.html', array(
|
||||||
'body' => Element('installer/config.html', array(
|
'body' => Element('installer/config.html', array(
|
||||||
'config' => $config,
|
'config' => $config,
|
||||||
|
@ -893,7 +893,7 @@ if ($step == 0) {
|
||||||
$more = $_POST['more'];
|
$more = $_POST['more'];
|
||||||
unset($_POST['more']);
|
unset($_POST['more']);
|
||||||
|
|
||||||
$instance_config =
|
$instance_config =
|
||||||
'<'.'?php
|
'<'.'?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -905,13 +905,13 @@ if ($step == 0) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
';
|
';
|
||||||
|
|
||||||
create_config_from_array($instance_config, $_POST);
|
create_config_from_array($instance_config, $_POST);
|
||||||
|
|
||||||
$instance_config .= "\n";
|
$instance_config .= "\n";
|
||||||
$instance_config .= $more;
|
$instance_config .= $more;
|
||||||
$instance_config .= "\n";
|
$instance_config .= "\n";
|
||||||
|
|
||||||
if (@file_put_contents('inc/instance-config.php', $instance_config)) {
|
if (@file_put_contents('inc/instance-config.php', $instance_config)) {
|
||||||
header('Location: ?step=4', true, $config['redirect_http']);
|
header('Location: ?step=4', true, $config['redirect_http']);
|
||||||
} else {
|
} else {
|
||||||
|
@ -928,34 +928,38 @@ if ($step == 0) {
|
||||||
}
|
}
|
||||||
} elseif ($step == 4) {
|
} elseif ($step == 4) {
|
||||||
// SQL installation
|
// SQL installation
|
||||||
|
|
||||||
buildJavascript();
|
buildJavascript();
|
||||||
|
|
||||||
$sql = @file_get_contents('install.sql') or error("Couldn't load install.sql.");
|
$sql = @file_get_contents('install.sql') or error("Couldn't load install.sql.");
|
||||||
|
|
||||||
sql_open();
|
sql_open();
|
||||||
$mysql_version = mysql_version();
|
$mysql_version = mysql_version();
|
||||||
|
|
||||||
// This code is probably horrible, but what I'm trying
|
// This code is probably horrible, but what I'm trying
|
||||||
// to do is find all of the SQL queires and put them
|
// to do is find all of the SQL queires and put them
|
||||||
// in an array.
|
// in an array.
|
||||||
preg_match_all("/(^|\n)((SET|CREATE|INSERT).+)\n\n/msU", $sql, $queries);
|
preg_match_all("/(^|\n)((SET|CREATE|INSERT).+)\n\n/msU", $sql, $queries);
|
||||||
$queries = $queries[2];
|
$queries = $queries[2];
|
||||||
|
|
||||||
$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';
|
||||||
$page['body'] = '<p style="text-align:center">Thank you for using vichan. Please remember to report any bugs you discover. <a href="http://tinyboard.org/docs/?p=Config">How do I edit the config files?</a></p>';
|
$page['body'] = '<p style="text-align:center">Thank you for using vichan. Please remember to report any bugs you discover. <a href="http://tinyboard.org/docs/?p=Config">How do I edit the config files?</a></p>';
|
||||||
|
|
||||||
if (!empty($sql_errors)) {
|
if (!empty($sql_errors)) {
|
||||||
$page['body'] .= '<div class="ban"><h2>SQL errors</h2><p>SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a vichan installation; if so, you can probably ignore this.</p><p>The errors encountered were:</p><ul>' . $sql_errors . '</ul><p><a href="?step=5">Ignore errors and complete installation.</a></p></div>';
|
$page['body'] .= '<div class="ban"><h2>SQL errors</h2><p>SQL errors were encountered when trying to install the database. This may be the result of using a database which is already occupied with a vichan installation; if so, you can probably ignore this.</p><p>The errors encountered were:</p><ul>' . $sql_errors . '</ul><p><a href="?step=5">Ignore errors and complete installation.</a></p></div>';
|
||||||
} else {
|
} else {
|
||||||
|
@ -964,29 +968,28 @@ if ($step == 0) {
|
||||||
setupBoard($_board);
|
setupBoard($_board);
|
||||||
buildIndex();
|
buildIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_write($config['has_installed'], VERSION);
|
file_write($config['has_installed'], VERSION);
|
||||||
/*if (!file_unlink(__FILE__)) {
|
/*if (!file_unlink(__FILE__)) {
|
||||||
$page['body'] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
|
$page['body'] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
echo Element('page.html', $page);
|
echo Element('page.html', $page);
|
||||||
} elseif ($step == 5) {
|
} elseif ($step == 5) {
|
||||||
$page['title'] = 'Installation complete';
|
$page['title'] = 'Installation complete';
|
||||||
$page['body'] = '<p style="text-align:center">Thank you for using vichan. Please remember to report any bugs you discover.</p>';
|
$page['body'] = '<p style="text-align:center">Thank you for using vichan. Please remember to report any bugs you discover.</p>';
|
||||||
|
|
||||||
$boards = listBoards();
|
$boards = listBoards();
|
||||||
foreach ($boards as &$_board) {
|
foreach ($boards as &$_board) {
|
||||||
setupBoard($_board);
|
setupBoard($_board);
|
||||||
buildIndex();
|
buildIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
file_write($config['has_installed'], VERSION);
|
file_write($config['has_installed'], VERSION);
|
||||||
if (!file_unlink(__FILE__)) {
|
if (!file_unlink(__FILE__)) {
|
||||||
$page['body'] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
|
$page['body'] .= '<div class="ban"><h2>Delete install.php!</h2><p>I couldn\'t remove <strong>install.php</strong>. You will have to remove it manually.</p></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
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 |