Browse Source

Merge pull request 'Dockerize leftypol, again' (#115) from dockerize2 into config

Reviewed-on: #115
pull/116/head
Zankaria 1 month ago
parent
commit
e5c8923c1c
  1. 4
      .dockerignore
  2. 1
      .gitignore
  3. 29
      Dockerfile
  4. 33
      docker-compose.yml
  5. 27
      docker/common-setup.sh
  6. 4
      docker/doc.md
  7. 11
      docker/nginx/Dockerfile
  8. 23
      docker/nginx/leftypol.conf
  9. 6
      docker/nginx/nginx.conf
  10. 2
      docker/nginx/proxy.conf
  11. 120
      docker/php/Dockerfile
  12. 80
      docker/php/bootstrap.sh
  13. 10
      docker/php/www.conf
  14. 22
      inc/template.php
  15. 141
      install.php
  16. 16
      site.conf

4
.dockerignore

@ -0,0 +1,4 @@
**/.git
**/.gitignore
/local-www
**/.gitkeep

1
.gitignore

@ -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/

29
Dockerfile

@ -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

33
docker-compose.yml

@ -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

27
docker/common-setup.sh

@ -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

@ -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;`

11
docker/nginx/Dockerfile

@ -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

23
docker/nginx/leftypol.conf

@ -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,9 +15,24 @@ server {
charset utf-8; charset utf-8;
location ~ ^([^.\?]*[^\/])$ { location ~ ^([^.\?]*[^\/])$ {
try_files $uri @addslash; try_files $uri @addslash;
} }
# Expire rules for static content
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
log_not_found off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
log_not_found off;
add_header Cache-Control "public";
}
# 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|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
@ -39,7 +54,7 @@ server {
} }
location @addslash { location @addslash {
return 301 $uri/; return 301 $uri/;
} }
location / { location / {
@ -56,7 +71,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;
} }

6
docker/nginx/nginx.conf

@ -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;

2
docker/nginx/proxy.conf

@ -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;

120
docker/php/Dockerfile

@ -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
COPY --from=composer /usr/bin/composer /usr/local/bin/composer
# Copy the bootstrap script.
COPY ./docker/php/bootstrap.sh /usr/local/bin/bootstrap.sh
# Copy the actual project (use .dockerignore to exclude stuff).
COPY . /code
# Make the instance configuration owned by www-data.
# Make it writable by php.
# Install the compose depedencies.
RUN cd /code && composer install
# RUN /code/docker/common-setup.sh php WORKDIR "/var/www"
WORKDIR "/var/www-leftypol" CMD [ "bootstrap.sh" ]
CMD ["php-fpm"] EXPOSE 9000
EXPOSE 9000

80
docker/php/bootstrap.sh

@ -0,0 +1,80 @@
#!/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/banners/ \
/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

10
docker/php/www.conf

@ -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

22
inc/template.php

@ -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']}'!");
} }
} }

141
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,22 +928,22 @@ 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; $sql_err_count = 0;
foreach ($queries as $query) { foreach ($queries as $query) {
@ -956,10 +956,10 @@ if ($step == 0) {
$sql_errors .= "<li>$sql_err_count<ul><li>$query</li><li>$error</li></ul></li>"; $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 {
@ -968,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);
} }

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;
}
}
Loading…
Cancel
Save