Compare commits

...

15 Commits

  1. 3
      .dockerignore
  2. 1
      .gitignore
  3. 29
      Dockerfile
  4. 5
      composer.json
  5. 249
      composer.lock
  6. 2
      docker-compose.yml
  7. 55
      docker/common-setup.sh
  8. 4
      docker/doc.md
  9. 11
      docker/nginx/Dockerfile
  10. 8
      docker/nginx/leftypol.conf
  11. 6
      docker/nginx/nginx.conf
  12. 2
      docker/nginx/proxy.conf
  13. 34
      docker/php/Dockerfile
  14. 74
      docker/php/bootstrap.sh
  15. 7
      docker/php/www.conf
  16. 27
      inc/cache.php
  17. 2
      inc/config.php
  18. 6
      inc/error.php
  19. 44
      inc/lib/twig/extensions/Extension/I18n.php
  20. 137
      inc/lib/twig/extensions/Extension/Tinyboard.php
  21. 133
      inc/lib/twig/extensions/Node/Trans.php
  22. 80
      inc/lib/twig/extensions/TokenParser/Trans.php
  23. 138
      inc/mod/pages.php
  24. 172
      inc/template.php
  25. 139
      install.php
  26. 4
      templates/banned.html
  27. 4
      templates/generic_page.html
  28. 4
      templates/header.html
  29. 4
      templates/index.html
  30. 20
      templates/installer/check-requirements.html
  31. 52
      templates/main.js
  32. 12
      templates/mod/config-editor-php.html
  33. 82
      templates/mod/config-editor.html
  34. 2
      templates/mod/dashboard.html
  35. 18
      templates/mod/debug/apc.html
  36. 2
      templates/mod/debug/recent_posts.html
  37. 2
      templates/mod/inbox.html
  38. 2
      templates/mod/log.html
  39. 16
      templates/mod/move.html
  40. 2
      templates/mod/move_reply.html
  41. 2
      templates/mod/news.html
  42. 2
      templates/mod/noticeboard.html
  43. 2
      templates/mod/recent_posts.html
  44. 2
      templates/mod/search_results.html
  45. 2
      templates/mod/themes.html
  46. 14
      templates/mod/user.html
  47. 4
      templates/mod/view_ip.html
  48. 4
      templates/notbanned.html
  49. 4
      templates/page.html
  50. 4
      templates/post_form.html
  51. 8
      templates/post_reply.html
  52. 6
      templates/post_thread.html
  53. 4
      templates/post_thread_fileboard.html
  54. 10
      templates/themes/basic/index.html
  55. 4
      templates/themes/calendar/calendar.html
  56. 8
      templates/themes/catalog/catalog.html
  57. 7
      templates/themes/categories/news.html
  58. 4
      templates/themes/categories/sidebar.html
  59. 4
      templates/themes/donate/donate.html
  60. 4
      templates/themes/faq/index.html
  61. 6
      templates/themes/frameset/news.html
  62. 4
      templates/themes/frameset/sidebar.html
  63. 4
      templates/themes/irc/irc.html
  64. 4
      templates/themes/radio/radio.html
  65. 4
      templates/themes/recent/recent.html
  66. 4
      templates/themes/rss/rss.xml
  67. 4
      templates/themes/rules/rules.html
  68. 4
      templates/themes/sitemap/sitemap.xml
  69. 4
      templates/themes/staffapplication/staffapplication.html
  70. 4
      templates/themes/stream/stream.html
  71. 4
      templates/thread.html
  72. 4
      templates/thread2_old.html
  73. 0
      tmp/cache/.gitkeep
  74. 2
      tools/rebuild.php
  75. 2
      tools/rebuild2.php

3
.dockerignore

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

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

5
composer.json

@ -3,10 +3,11 @@
"description": "leftypol imageboard", "description": "leftypol imageboard",
"type": "project", "type": "project",
"require": { "require": {
"twig/twig": "^1.44.2", "twig/twig": "^2.14.5",
"lifo/ip": "^1.0", "lifo/ip": "^1.0",
"gettext/gettext": "^1.0", "gettext/gettext": "^1.0",
"mrclay/minify": "^2.1.6" "mrclay/minify": "^2.1.6",
"phpmyadmin/twig-i18n-extension": "^4.1"
}, },
"autoload": { "autoload": {
"classmap": ["inc/"], "classmap": ["inc/"],

249
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "346d80deda89b0298a414b565213f312", "content-hash": "9390756f1db53a7bb4475fe5b68c9f9d",
"packages": [ "packages": [
{ {
"name": "gettext/gettext", "name": "gettext/gettext",
@ -25,12 +25,12 @@
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
"psr-0": {
"Gettext": ""
},
"files": [ "files": [
"Gettext/translator_functions.php" "Gettext/translator_functions.php"
] ],
"psr-0": {
"Gettext": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -157,6 +157,62 @@
}, },
"time": "2017-11-03T21:04:01+00:00" "time": "2017-11-03T21:04:01+00:00"
}, },
{
"name": "phpmyadmin/twig-i18n-extension",
"version": "4.1.0",
"source": {
"type": "git",
"url": "https://github.com/phpmyadmin/twig-i18n-extension.git",
"reference": "a514a2afd29717a2a68c298582cc2739e8edeed0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpmyadmin/twig-i18n-extension/zipball/a514a2afd29717a2a68c298582cc2739e8edeed0",
"reference": "a514a2afd29717a2a68c298582cc2739e8edeed0",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0",
"twig/twig": "^1.42.3|^2.0|^3.0"
},
"require-dev": {
"phpmyadmin/coding-standard": "^3.0.0",
"phpmyadmin/motranslator": "^5.2",
"phpstan/phpstan": "^1.9.4",
"phpunit/phpunit": "^7 || ^8 || ^9"
},
"type": "library",
"autoload": {
"psr-4": {
"PhpMyAdmin\\Twig\\Extensions\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "[email protected]"
},
{
"name": "The phpMyAdmin Team",
"email": "[email protected]",
"homepage": "https://www.phpmyadmin.net/team/"
}
],
"description": "Internationalization support for Twig via the gettext library",
"keywords": [
"gettext",
"i18n"
],
"support": {
"issues": "https://github.com/phpmyadmin/twig-i18n-extension/issues",
"source": "https://github.com/phpmyadmin/twig-i18n-extension"
},
"time": "2023-09-12T18:31:42+00:00"
},
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
"version": "v1.24.0", "version": "v1.24.0",
@ -191,12 +247,12 @@
} }
}, },
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@ -239,32 +295,187 @@
], ],
"time": "2021-10-20T20:35:02+00:00" "time": "2021-10-20T20:35:02+00:00"
}, },
{
"name": "symfony/polyfill-mbstring",
"version": "v1.29.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"provide": {
"ext-mbstring": "*"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-29T20:11:03+00:00"
},
{
"name": "symfony/polyfill-php72",
"version": "v1.29.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
"reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/861391a8da9a04cbad2d232ddd9e4893220d6e25",
"reference": "861391a8da9a04cbad2d232ddd9e4893220d6e25",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php72\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "[email protected]"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php72/tree/v1.29.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-01-29T20:11:03+00:00"
},
{ {
"name": "twig/twig", "name": "twig/twig",
"version": "v1.44.6", "version": "v2.15.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/twigphp/Twig.git", "url": "https://github.com/twigphp/Twig.git",
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3" "reference": "3e059001d6d597dd50ea7c74dd2464b4adea48d3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/twigphp/Twig/zipball/ae39480f010ef88adc7938503c9b02d3baf2f3b3", "url": "https://api.github.com/repos/twigphp/Twig/zipball/3e059001d6d597dd50ea7c74dd2464b4adea48d3",
"reference": "ae39480f010ef88adc7938503c9b02d3baf2f3b3", "reference": "3e059001d6d597dd50ea7c74dd2464b4adea48d3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.2.5", "php": ">=7.1.3",
"symfony/polyfill-ctype": "^1.8" "symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-mbstring": "^1.3",
"symfony/polyfill-php72": "^1.8"
}, },
"require-dev": { "require-dev": {
"psr/container": "^1.0", "psr/container": "^1.0",
"symfony/phpunit-bridge": "^4.4.9|^5.0.9" "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.44-dev" "dev-master": "2.15-dev"
} }
}, },
"autoload": { "autoload": {
@ -303,7 +514,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/twigphp/Twig/issues", "issues": "https://github.com/twigphp/Twig/issues",
"source": "https://github.com/twigphp/Twig/tree/v1.44.6" "source": "https://github.com/twigphp/Twig/tree/v2.15.4"
}, },
"funding": [ "funding": [
{ {
@ -315,7 +526,7 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2021-11-25T13:31:46+00:00" "time": "2022-12-27T12:26:20+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],

2
docker-compose.yml

@ -23,7 +23,7 @@ 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: leftchan_net:

55
docker/common-setup.sh

@ -1,27 +1,32 @@
#!/bin/sh #!/bin/sh
set -eu #set -eu
#
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol #install -m 544 -o www-data -g www-data -d /var/www
ln -s \ #ln -s \
/code/banners/ \ # /code/banners/ \
/code/static/ \ # /code/static/ \
/code/stylesheets/ \ # /code/stylesheets/ \
/code/tools/ \ # /code/tools/ \
/code/walls/ \ # /code/walls/ \
/code/*.php \ # /code/*.php \
/code/404.html \ # /code/404.html \
/code/LICENSE.* \ # /code/LICENSE.* \
/code/robots.txt \ # /code/robots.txt \
/code/install.sql \ # /code/install.sql \
/var/www-leftypol/ # /var/www/
#
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/js #install -m 540 -o www-data -g www-data -d /var/tmp/leftypol
ln -s /code/js/* /var/www-leftypol/js/ #install -m 540 -o www-data -g www-data -d /var/tmp/leftypol/cache
#ln -s /var/tmp/leftypol /var/www/tmp
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 #install -m 544 -o www-data -g www-data -d /var/www/js
ln -s /code/templates/* /var/www-leftypol/templates/ #ln -s /code/js/* /var/www/js/
#
install -m 775 -o leftypol -g leftypol -d /var/www-leftypol/inc #install -m 544 -o www-data -g www-data -d /var/www/templates
ln -s /code/inc/* /var/www-leftypol/inc/ #install -m 544 -o www-data -g www-data -d /var/www/templates/cache
#ln -s /code/templates/* /var/www/templates/
#
#install -m 544 -o www-data -g www-data -d /var/www/inc
#ln -s /code/inc/* /var/www/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

8
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,7 +15,7 @@ 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
@ -39,7 +39,7 @@ server {
} }
location @addslash { location @addslash {
return 301 $uri/; return 301 $uri/;
} }
location / { location / {
@ -56,7 +56,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;

34
docker/php/Dockerfile

@ -2,8 +2,6 @@
FROM composer AS composer FROM composer AS composer
FROM php:8.1-fpm-bullseye FROM php:8.1-fpm-bullseye
COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY . /code
RUN apt-get update && apt-get upgrade -y && apt-get install -y \ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
zlib1g-dev libicu-dev g++ \ zlib1g-dev libicu-dev g++ \
@ -36,12 +34,28 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
&& pecl install -o -f igbinary \ && pecl install -o -f igbinary \
&& docker-php-ext-install gd zip opcache intl pdo pdo_mysql mysqli bcmath gettext iconv mbstring curl \ && docker-php-ext-install gd zip opcache intl pdo pdo_mysql mysqli bcmath gettext iconv mbstring curl \
&& docker-php-ext-enable igbinary redis imagick \ && docker-php-ext-enable igbinary redis imagick \
&& useradd -MU leftypol \ && rm -rf /var/cache/* \
&& /code/docker/common-setup.sh \ && rmdir /var/www/html \
&& ln -s /code/composer.json /code/composer.lock /var/www-leftypol/ \ && install -d -m 744 -o www-data -g www-data /var/www \
&& cd /var/www-leftypol && composer install && install -d -m 700 -o www-data -g www-data /var/tmp/leftypol \
&& 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 chown www-data /code/inc/instance-config.php && chgrp www-data /code/inc/instance-config.php \
&& chmod 660 /code/inc/instance-config.php \
&& 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

74
docker/php/bootstrap.sh

@ -0,0 +1,74 @@
#!/bin/sh
set -eu
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/static/ \
/code/stylesheets/ \
/code/tools/ \
/code/walls/ \
/code/*.php \
/code/LICENSE.* \
/code/404.html \
/code/install.sql \
/var/www/
# Ensure correct permissions are set, since this might be bind mount.
chown www-data /var/www
chgrp www-data /var/www
# Initialize robots.txt with the default if it doesn't exist.
cp -n /code/robots.txt /var/www
# Link the cache and tmp files directory.
ln -nfs /var/tmp/leftypol /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).
if [ -L '/var/www/inc/instance-config.php' ]; then
echo 'INFO: Resetting instance configuration'
rm /var/www/inc/instance-config.php
cp /code/inc/instance-config.php /var/www/inc/instance-config.php
chown www-data /var/www/inc/instance-config.php
chgrp www-data /var/www/inc/instance-config.php
chmod 600 /var/www/inc/instance-config.php
else
echo 'INFO: Using existing instance configuration'
fi
# Link the composer dependencies.
ln -nfs /code/vendor /var/www/
# Start the php-fpm server.
exec php-fpm

7
docker/php/www.conf

@ -1,9 +1,6 @@
[www] [www]
user = leftypol user = www-data
group = leftypol 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
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

27
inc/cache.php

@ -175,3 +175,30 @@ class Cache {
} }
} }
class Twig_Cache_TinyboardFilesystem extends Twig\Cache\FilesystemCache
{
private $directory;
private $options;
/**
* {@inheritdoc}
*/
public function __construct($directory, $options = 0)
{
parent::__construct($directory, $options);
$this->directory = $directory;
}
/**
* This function was removed in Twig 2.x due to developer views on the Twig library. Who says we can't keep it for ourselves though?
*/
public function clear()
{
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->directory), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
if ($file->isFile()) {
@unlink($file->getPathname());
}
}
}
}

2
inc/config.php

@ -43,6 +43,8 @@
$config['check_updates'] = false; $config['check_updates'] = false;
// How often to check for updates // How often to check for updates
$config['check_updates_time'] = 43200; // 12 hours $config['check_updates_time'] = 43200; // 12 hours
// Skip cache in twig. this is already enabled with debug
$config['twig_auto_reload'] = true;
// Shows some extra information at the bottom of pages. Good for development/debugging. // Shows some extra information at the bottom of pages. Good for development/debugging.
$config['debug'] = false; $config['debug'] = false;

6
inc/error.php

@ -1,8 +1,8 @@
<?php <?php
function error_handler($errno,$errstr,$errfile, $errline, $errcontext){ function error_handler($errno, $errstr, $errfile, $errline) {
if(error_reporting() & $errno){ if (error_reporting() & $errno) {
$config['debug']=true; $config['debug'] = true;
error($errstr . ' in ' . $errfile . ' at line ' . $errline); error($errstr . ' in ' . $errfile . ' at line ' . $errline);
} }
return false; return false;

44
inc/lib/twig/extensions/Extension/I18n.php

@ -1,44 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) 2010 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Extensions_Extension_I18n extends Twig_Extension
{
/**
* Returns the token parser instances to add to the existing list.
*
* @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
*/
public function getTokenParsers()
{
return array(new Twig_Extensions_TokenParser_Trans());
}
/**
* Returns a list of filters to add to the existing list.
*
* @return array An array of filters
*/
public function getFilters()
{
return array(
new Twig_SimpleFilter('trans', 'gettext'),
);
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'i18n';
}
}

137
inc/lib/twig/extensions/Extension/Tinyboard.php

@ -1,137 +0,0 @@
<?php
class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
{
/**
* Returns a list of filters to add to the existing list.
*
* @return array An array of filters
*/
public function getFilters()
{
return array(
new Twig_SimpleFilter('filesize', 'format_bytes'),
new Twig_SimpleFilter('truncate', 'twig_truncate_filter'),
new Twig_SimpleFilter('truncate_body', 'truncate'),
new Twig_SimpleFilter('truncate_filename', 'twig_filename_truncate_filter'),
new Twig_SimpleFilter('extension', 'twig_extension_filter'),
new Twig_SimpleFilter('sprintf', 'sprintf'),
new Twig_SimpleFilter('capcode', 'capcode'),
new Twig_SimpleFilter('remove_modifiers', 'remove_modifiers'),
new Twig_SimpleFilter('remove_markup', 'remove_markup'),
new Twig_SimpleFilter('newline_to_full_stop', 'newline_to_full_stop'),
new Twig_SimpleFilter('hasPermission', 'twig_hasPermission_filter'),
new Twig_SimpleFilter('date', 'twig_date_filter'),
new Twig_SimpleFilter('poster_id', 'poster_id'),
new Twig_SimpleFilter('remove_whitespace', 'twig_remove_whitespace_filter'),
new Twig_SimpleFilter('count', 'count'),
new Twig_SimpleFilter('ago', 'ago'),
new Twig_SimpleFilter('until', 'until'),
new Twig_SimpleFilter('push', 'twig_push_filter'),
new Twig_SimpleFilter('bidi_cleanup', 'bidi_cleanup'),
new Twig_SimpleFilter('addslashes', 'addslashes'),
);
}
/**
* Returns a list of functions to add to the existing list.
*
* @return array An array of filters
*/
public function getFunctions()
{
return array(
new Twig_SimpleFunction('time', 'time'),
new Twig_SimpleFunction('floor', 'floor'),
new Twig_SimpleFunction('timezone', 'twig_timezone_function'),
new Twig_SimpleFunction('hiddenInputs', 'hiddenInputs'),
new Twig_SimpleFunction('hiddenInputsHash', 'hiddenInputsHash'),
new Twig_SimpleFunction('ratio', 'twig_ratio_function'),
new Twig_SimpleFunction('secure_link_confirm', 'twig_secure_link_confirm'),
new Twig_SimpleFunction('secure_link', 'twig_secure_link'),
new Twig_SimpleFunction('link_for', 'link_for')
);
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'tinyboard';
}
}
function twig_timezone_function() {
return 'Z';
}
function twig_push_filter($array, $value) {
array_push($array, $value);
return $array;
}
function twig_remove_whitespace_filter($data) {
return preg_replace('/[\t\r\n]/', '', $data);
}
function twig_date_filter($date, $format) {
return gmstrftime($format, $date);
}
function twig_hasPermission_filter($mod, $permission, $board = null) {
return hasPermission($permission, $board, $mod);
}
function twig_extension_filter($value, $case_insensitive = true) {
$ext = mb_substr($value, mb_strrpos($value, '.') + 1);
if($case_insensitive)
$ext = mb_strtolower($ext);
return $ext;
}
function twig_sprintf_filter( $value, $var) {
return sprintf($value, $var);
}
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') {
if (mb_strlen($value) > $length) {
if ($preserve) {
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) {
$length = $breakpoint;
}
}
return mb_substr($value, 0, $length) . $separator;
}
return $value;
}
function twig_filename_truncate_filter($value, $length = 30, $separator = '…') {
if (mb_strlen($value) > $length) {
$value = strrev($value);
$array = array_reverse(explode(".", $value, 2));
$array = array_map("strrev", $array);
$filename = &$array[0];
$extension = isset($array[1]) ? $array[1] : false;
$filename = mb_substr($filename, 0, $length - ($extension ? mb_strlen($extension) + 1 : 0)) . $separator;
return implode(".", $array);
}
return $value;
}
function twig_ratio_function($w, $h) {
return fraction($w, $h, ':');
}
function twig_secure_link_confirm($text, $title, $confirm_message, $href) {
global $config;
return '<a onclick="if (event.which==2) return true;if (confirm(\'' . htmlentities(addslashes($confirm_message)) . '\')) document.location=\'?/' . htmlspecialchars(addslashes($href . '/' . make_secure_link_token($href))) . '\';return false;" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>';
}
function twig_secure_link($href) {
return $href . '/' . make_secure_link_token($href);
}

133
inc/lib/twig/extensions/Node/Trans.php

@ -1,133 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) 2010 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Represents a trans node.
*
* @package twig
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Twig_Extensions_Node_Trans extends Twig_Node
{
public function __construct(Twig_NodeInterface $body, Twig_NodeInterface $plural = null, Twig_Node_Expression $count = null, $lineno, $tag = null)
{
parent::__construct(array('count' => $count, 'body' => $body, 'plural' => $plural), array(), $lineno, $tag);
}
/**
* Compiles the node to PHP.
*
* @param Twig_Compiler A Twig_Compiler instance
*/
public function compile(Twig_Compiler $compiler)
{
$compiler->addDebugInfo($this);
list($msg, $vars) = $this->compileString($this->getNode('body'));
if (null !== $this->getNode('plural')) {
list($msg1, $vars1) = $this->compileString($this->getNode('plural'));
$vars = array_merge($vars, $vars1);
}
$function = null === $this->getNode('plural') ? 'gettext' : 'ngettext';
if ($vars) {
$compiler
->write('echo strtr('.$function.'(')
->subcompile($msg)
;
if (null !== $this->getNode('plural')) {
$compiler
->raw(', ')
->subcompile($msg1)
->raw(', abs(')
->subcompile($this->getNode('count'))
->raw(')')
;
}
$compiler->raw('), array(');
foreach ($vars as $var) {
if ('count' === $var->getAttribute('name')) {
$compiler
->string('%count%')
->raw(' => abs(')
->subcompile($this->getNode('count'))
->raw('), ')
;
} else {
$compiler
->string('%'.$var->getAttribute('name').'%')
->raw(' => ')
->subcompile($var)
->raw(', ')
;
}
}
$compiler->raw("));\n");
} else {
$compiler
->write('echo '.$function.'(')
->subcompile($msg)
;
if (null !== $this->getNode('plural')) {
$compiler
->raw(', ')
->subcompile($msg1)
->raw(', abs(')
->subcompile($this->getNode('count'))
->raw(')')
;
}
$compiler->raw(");\n");
}
}
protected function compileString(Twig_NodeInterface $body)
{
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant || $body instanceof Twig_Node_Expression_TempName) {
return array($body, array());
}
$vars = array();
if (count($body)) {
$msg = '';
foreach ($body as $node) {
if (get_class($node) === 'Twig_Node' && $node->getNode(0) instanceof Twig_Node_SetTemp) {
$node = $node->getNode(1);
}
if ($node instanceof Twig_Node_Print) {
$n = $node->getNode('expr');
while ($n instanceof Twig_Node_Expression_Filter) {
$n = $n->getNode('node');
}
$msg .= sprintf('%%%s%%', $n->getAttribute('name'));
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
} else {
$msg .= $node->getAttribute('data');
}
}
} else {
$msg = $body->getAttribute('data');
}
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars);
}
}

80
inc/lib/twig/extensions/TokenParser/Trans.php

@ -1,80 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) 2010 Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
class Twig_Extensions_TokenParser_Trans extends Twig_TokenParser
{
/**
* Parses a token and returns a node.
*
* @param Twig_Token $token A Twig_Token instance
*
* @return Twig_NodeInterface A Twig_NodeInterface instance
*/
public function parse(Twig_Token $token)
{
$lineno = $token->getLine();
$stream = $this->parser->getStream();
$count = null;
$plural = null;
if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) {
$body = $this->parser->getExpressionParser()->parseExpression();
} else {
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideForFork'));
if ('plural' === $stream->next()->getValue()) {
$count = $this->parser->getExpressionParser()->parseExpression();
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$plural = $this->parser->subparse(array($this, 'decideForEnd'), true);
}
}
$stream->expect(Twig_Token::BLOCK_END_TYPE);
$this->checkTransString($body, $lineno);
return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag());
}
public function decideForFork(Twig_Token $token)
{
return $token->test(array('plural', 'endtrans'));
}
public function decideForEnd(Twig_Token $token)
{
return $token->test('endtrans');
}
/**
* Gets the tag name associated with this token parser.
*
* @param string The tag name
*/
public function getTag()
{
return 'trans';
}
protected function checkTransString(Twig_NodeInterface $body, $lineno)
{
foreach ($body as $i => $node) {
if (
$node instanceof Twig_Node_Text
||
($node instanceof Twig_Node_Print && $node->getNode('expr') instanceof Twig_Node_Expression_Name)
) {
continue;
}
throw new Twig_Error_Syntax(sprintf('The text to be translated with "trans" can only contain references to simple variables'), $lineno);
}
}
}

138
inc/mod/pages.php

@ -2698,75 +2698,75 @@ function mod_new_pm($username) {
} }
function mod_rebuild() { function mod_rebuild() {
global $config, $twig; global $config, $twig;
if (!hasPermission($config['mod']['rebuild'])) if (!hasPermission($config['mod']['rebuild']))
error($config['error']['noaccess']); error($config['error']['noaccess']);
if (isset($_POST['rebuild'])) { if (isset($_POST['rebuild'])) {
@set_time_limit($config['mod']['rebuild_timelimit']); @set_time_limit($config['mod']['rebuild_timelimit']);
$log = array(); $log = array();
$boards = listBoards(); $boards = listBoards();
$rebuilt_scripts = array(); $rebuilt_scripts = array();
if (isset($_POST['rebuild_cache'])) { if (isset($_POST['rebuild_cache'])) {
if ($config['cache']['enabled']) { if ($config['cache']['enabled']) {
$log[] = 'Flushing cache'; $log[] = 'Flushing cache';
Cache::flush(); Cache::flush();
} }
$log[] = 'Clearing template cache'; $log[] = 'Clearing template cache';
load_twig(); load_twig();
$twig->clearCacheFiles(); $twig->getCache()->clear();
} }
if (isset($_POST['rebuild_themes'])) { if (isset($_POST['rebuild_themes'])) {
$log[] = 'Regenerating theme files'; $log[] = 'Regenerating theme files';
rebuildThemes('all'); rebuildThemes('all');
} }
if (isset($_POST['rebuild_javascript'])) { if (isset($_POST['rebuild_javascript'])) {
$log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>'; $log[] = 'Rebuilding <strong>' . $config['file_script'] . '</strong>';
buildJavascript(); buildJavascript();
$rebuilt_scripts[] = $config['file_script']; $rebuilt_scripts[] = $config['file_script'];
} }
foreach ($boards as $board) { foreach ($boards as $board) {
if (!(isset($_POST['boards_all']) || isset($_POST['board_' . $board['uri']]))) if (!(isset($_POST['boards_all']) || isset($_POST['board_' . $board['uri']])))
continue; continue;
openBoard($board['uri']); openBoard($board['uri']);
$config['try_smarter'] = false; $config['try_smarter'] = false;
if (isset($_POST['rebuild_index'])) { if (isset($_POST['rebuild_index'])) {
buildIndex(); buildIndex();
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages'; $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Creating index pages';
} }
if (isset($_POST['rebuild_javascript']) && !in_array($config['file_script'], $rebuilt_scripts)) { if (isset($_POST['rebuild_javascript']) && !in_array($config['file_script'], $rebuilt_scripts)) {
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>'; $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding <strong>' . $config['file_script'] . '</strong>';
buildJavascript(); buildJavascript();
$rebuilt_scripts[] = $config['file_script']; $rebuilt_scripts[] = $config['file_script'];
} }
if (isset($_POST['rebuild_thread'])) { if (isset($_POST['rebuild_thread'])) {
$query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error());
while ($post = $query->fetch(PDO::FETCH_ASSOC)) { while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
$log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id']; $log[] = '<strong>' . sprintf($config['board_abbreviation'], $board['uri']) . '</strong>: Rebuilding thread #' . $post['id'];
buildThread($post['id']); buildThread($post['id']);
} }
} }
} }
mod_page(_('Rebuild'), 'mod/rebuilt.html', array('logs' => $log)); mod_page(_('Rebuild'), $config['file_mod_rebuilt'], array('logs' => $log));
return; return;
} }
mod_page(_('Rebuild'), 'mod/rebuild.html', array( mod_page(_('Rebuild'), $config['file_mod_rebuild'], array(
'boards' => listBoards(), 'boards' => listBoards(),
'token' => make_secure_link_token('rebuild') 'token' => make_secure_link_token('rebuild')
)); ));
} }
function mod_reports() { function mod_reports() {

172
inc/template.php

@ -13,31 +13,40 @@ $twig = false;
function load_twig() { function load_twig() {
global $twig, $config; global $twig, $config;
$loader = new Twig_Loader_Filesystem($config['dir']['template']);
$cache_dir = "{$config['dir']['template']}/cache";
if (is_link($cache_dir)) {
$cache_dir = realpath($cache_dir);
}
$loader = new Twig\Loader\FilesystemLoader($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, new Twig_Cache_TinyboardFilesystem($cache_dir) : false,
'debug' => $config['debug'] 'debug' => $config['debug'],
'auto_reload' => $config['twig_auto_reload']
)); ));
$twig->addExtension(new Twig_Extensions_Extension_Tinyboard()); if ($config['debug'])
$twig->addExtension(new Twig_Extensions_Extension_I18n()); $twig->addExtension(new \Twig\Extension\DebugExtension());
$twig->addExtension(new Tinyboard());
$twig->addExtension(new PhpMyAdmin\Twig\Extensions\I18nExtension());
} }
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 +64,153 @@ 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']}'!");
} }
} }
class Tinyboard extends Twig\Extension\AbstractExtension
{
/**
* Returns a list of filters to add to the existing list.
*
* @return array An array of filters
*/
public function getFilters()
{
return array(
new Twig\TwigFilter('filesize', 'format_bytes'),
new Twig\TwigFilter('truncate', 'twig_truncate_filter'),
new Twig\TwigFilter('truncate_body', 'truncate'),
new Twig\TwigFilter('truncate_filename', 'twig_filename_truncate_filter'),
new Twig\TwigFilter('extension', 'twig_extension_filter'),
new Twig\TwigFilter('sprintf', 'sprintf'),
new Twig\TwigFilter('capcode', 'capcode'),
new Twig\TwigFilter('remove_modifiers', 'remove_modifiers'),
new Twig\TwigFilter('hasPermission', 'twig_hasPermission_filter'),
new Twig\TwigFilter('date', 'twig_date_filter'),
new Twig\TwigFilter('poster_id', 'poster_id'),
new Twig\TwigFilter('remove_whitespace', 'twig_remove_whitespace_filter'),
new Twig\TwigFilter('count', 'count'),
new Twig\TwigFilter('ago', 'ago'),
new Twig\TwigFilter('until', 'until'),
new Twig\TwigFilter('push', 'twig_push_filter'),
new Twig\TwigFilter('bidi_cleanup', 'bidi_cleanup'),
new Twig\TwigFilter('addslashes', 'addslashes'),
new Twig\TwigFilter('cloak_ip', 'cloak_ip'),
new Twig\TwigFilter('cloak_mask', 'cloak_mask'),
);
}
/**
* Returns a list of functions to add to the existing list.
*
* @return array An array of filters
*/
public function getFunctions()
{
return array(
new Twig\TwigFunction('time', 'time'),
new Twig\TwigFunction('floor', 'floor'),
new Twig\TwigFunction('timezone', 'twig_timezone_function'),
new Twig\TwigFunction('hiddenInputs', 'hiddenInputs'),
new Twig\TwigFunction('hiddenInputsHash', 'hiddenInputsHash'),
new Twig\TwigFunction('ratio', 'twig_ratio_function'),
new Twig\TwigFunction('secure_link_confirm', 'twig_secure_link_confirm'),
new Twig\TwigFunction('secure_link', 'twig_secure_link'),
new Twig\TwigFunction('link_for', 'link_for')
);
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'tinyboard';
}
}
function twig_timezone_function() {
return 'Z';
}
function twig_push_filter($array, $value) {
array_push($array, $value);
return $array;
}
function twig_remove_whitespace_filter($data) {
return preg_replace('/[\t\r\n]/', '', $data);
}
function twig_date_filter($date, $format) {
return gmstrftime($format, $date);
}
function twig_hasPermission_filter($mod, $permission, $board = null) {
return hasPermission($permission, $board, $mod);
}
function twig_extension_filter($value, $case_insensitive = true) {
$ext = mb_substr($value, mb_strrpos($value, '.') + 1);
if($case_insensitive)
$ext = mb_strtolower($ext);
return $ext;
}
function twig_sprintf_filter( $value, $var) {
return sprintf($value, $var);
}
function twig_truncate_filter($value, $length = 30, $preserve = false, $separator = '…') {
if (mb_strlen($value) > $length) {
if ($preserve) {
if (false !== ($breakpoint = mb_strpos($value, ' ', $length))) {
$length = $breakpoint;
}
}
return mb_substr($value, 0, $length) . $separator;
}
return $value;
}
function twig_filename_truncate_filter($value, $length = 30, $separator = '…') {
if (mb_strlen($value) > $length) {
$value = strrev($value);
$array = array_reverse(explode(".", $value, 2));
$array = array_map("strrev", $array);
$filename = &$array[0];
$extension = isset($array[1]) ? $array[1] : false;
$filename = mb_substr($filename, 0, $length - ($extension ? mb_strlen($extension) + 1 : 0)) . $separator;
return implode(".", $array);
}
return $value;
}
function twig_ratio_function($w, $h) {
return fraction($w, $h, ':');
}
function twig_secure_link_confirm($text, $title, $confirm_message, $href) {
global $config;
return '<a onclick="if (event.which==2) return true;if (confirm(\'' . htmlentities(addslashes($confirm_message)) . '\')) document.location=\'?/' . htmlspecialchars(addslashes($href . '/' . make_secure_link_token($href))) . '\';return false;" title="' . htmlentities($title) . '" href="?/' . $href . '">' . $text . '</a>';
}
function twig_secure_link($href) {
return $href . '/' . make_secure_link_token($href);
}

139
install.php

@ -1,6 +1,6 @@
<?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 (fopen('inc/instance-config.php' , 'a') === false) {
@ -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 = '';
foreach ($queries as $query) { foreach ($queries as $query) {
if ($mysql_version < 50503) if ($mysql_version < 50503)
@ -952,10 +952,10 @@ if ($step == 0) {
if (!query($query)) if (!query($query))
$sql_errors .= '<li>' . db_error() . '</li>'; $sql_errors .= '<li>' . db_error() . '</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 +964,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);
} }

4
templates/banned.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
{# Automatically removes unnecessary whitespace #} {# Automatically removes unnecessary whitespace #}
<div class="ban"> <div class="ban">
<iframe width="420" height="315" src="https://www.youtube.com/embed/FXPKJUE86d0" frameborder="0" allowfullscreen></iframe> <iframe width="420" height="315" src="https://www.youtube.com/embed/FXPKJUE86d0" frameborder="0" allowfullscreen></iframe>
@ -143,4 +143,4 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
{% endfilter %} {% endapply %}

4
templates/generic_page.html

@ -49,8 +49,8 @@
{% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %} {% for footer in config.footer %}<p class="unimportant" style="text-align:center;">{{ footer }}</p>{% endfor %}
</footer> </footer>
</div> </div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

4
templates/header.html

@ -30,7 +30,7 @@
{% endif %} {% endif %}
{% if config.recaptcha %} {% if config.recaptcha %}
<script src="//www.google.com/recaptcha/api.js"></script> <script src="//www.google.com/recaptcha/api.js"></script>
<style type="text/css">{% raw %} <style type="text/css">{% verbatim %}
#recaptcha_area { #recaptcha_area {
float: none !important; float: none !important;
padding: 0 !important; padding: 0 !important;
@ -58,4 +58,4 @@
.recaptchatable, #recaptcha_area tr, #recaptcha_area td, #recaptcha_area th { .recaptchatable, #recaptcha_area tr, #recaptcha_area td, #recaptcha_area th {
padding: 0 !important; padding: 0 !important;
} }
{% endraw %}</style>{% endif %} {% endverbatim %}</style>{% endif %}

4
templates/index.html

@ -132,9 +132,9 @@
</div> </div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

20
templates/installer/check-requirements.html

@ -31,15 +31,17 @@
{% if errors or warnings %} {% if errors or warnings %}
<p><strong>There were {{ errors }} error(s) and {{ warnings }} warning(s).</strong></p> <p><strong>There were {{ errors }} error(s) and {{ warnings }} warning(s).</strong></p>
<ul> <ul>
{% for test in tests if not test.result%} {% for test in tests %}
<li style="margin-bottom:5px"> {% if not test.result %}
{% if test.required %} <li style="margin-bottom:5px">
<i style="font-size:11pt;color:#d00" class="fa fa-exclamation"></i> <strong>Error:</strong> {% if test.required %}
{% else %} <i style="font-size:11pt;color:#d00" class="fa fa-exclamation"></i> <strong>Error:</strong>
<i style="font-size:11pt;color:#f80" class="fa fa-warning"></i> <strong>Warning:</strong> {% else %}
{% endif %} <i style="font-size:11pt;color:#f80" class="fa fa-warning"></i> <strong>Warning:</strong>
{{ test.message }} {% endif %}
</li> {{ test.message }}
</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% if errors %} {% if errors %}

52
templates/main.js

@ -1,4 +1,4 @@
{% raw %} {% verbatim %}
/* gettext-compatible _ function, example of usage: /* gettext-compatible _ function, example of usage:
* *
@ -109,16 +109,16 @@ function alert(a, do_confirm, confirm_ok_action, confirm_cancel_action) {
var saved = {}; var saved = {};
var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0|addslashes }}{% raw %}'; var selectedstyle = '{% endverbatim %}{{ config.default_stylesheet.0|addslashes }}{% verbatim %}';
var styles = { var styles = {
{% endraw %} {% endverbatim %}
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}', {% for stylesheet in stylesheets %}{% verbatim %}'{% endverbatim %}{{ stylesheet.name|addslashes }}{% verbatim %}' : '{% endverbatim %}{{ stylesheet.uri|addslashes }}{% verbatim %}',
{% endraw %}{% endfor %}{% raw %} {% endverbatim %}{% endfor %}{% verbatim %}
}; };
var codestyles = { var codestyles = {
{% endraw %} {% endverbatim %}
{% for stylesheet in code_stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}', {% for stylesheet in code_stylesheets %}{% verbatim %}'{% endverbatim %}{{ stylesheet.name|addslashes }}{% verbatim %}' : '{% endverbatim %}{{ stylesheet.uri|addslashes }}{% verbatim %}',
{% endraw %}{% endfor %}{% raw %} {% endverbatim %}{% endfor %}{% verbatim %}
}; };
if (typeof board_name === 'undefined') { if (typeof board_name === 'undefined') {
@ -126,16 +126,16 @@ if (typeof board_name === 'undefined') {
} }
function changeStyle(styleName, link) { function changeStyle(styleName, link) {
{% endraw %} {% endverbatim %}
{% if config.stylesheets_board %}{% raw %} {% if config.stylesheets_board %}{% verbatim %}
if (board_name) { if (board_name) {
stylesheet_choices[board_name] = styleName; stylesheet_choices[board_name] = styleName;
localStorage.board_stylesheets = JSON.stringify(stylesheet_choices); localStorage.board_stylesheets = JSON.stringify(stylesheet_choices);
} }
{% endraw %}{% else %} {% endverbatim %}{% else %}
localStorage.stylesheet = styleName; localStorage.stylesheet = styleName;
{% endif %} {% endif %}
{% raw %} {% verbatim %}
// Main stylesheet // Main stylesheet
if (!document.getElementById('stylesheet')) { if (!document.getElementById('stylesheet')) {
@ -178,9 +178,9 @@ function changeStyle(styleName, link) {
} }
{% endraw %} {% endverbatim %}
{% if config.stylesheets_board %} {% if config.stylesheets_board %}
{% raw %} {% verbatim %}
if (!localStorage.board_stylesheets) { if (!localStorage.board_stylesheets) {
localStorage.board_stylesheets = '{}'; localStorage.board_stylesheets = '{}';
@ -197,7 +197,7 @@ function changeStyle(styleName, link) {
} }
{% endraw%} {% endraw%}
{% else %} {% else %}
{% raw %} {% verbatim %}
if (localStorage.stylesheet) { if (localStorage.stylesheet) {
for (var styleName in styles) { for (var styleName in styles) {
if (styleName == localStorage.stylesheet) { if (styleName == localStorage.stylesheet) {
@ -206,9 +206,9 @@ function changeStyle(styleName, link) {
} }
} }
} }
{% endraw %} {% endverbatim %}
{% endif %} {% endif %}
{% raw %} {% verbatim %}
function init_stylechooser() { function init_stylechooser() {
var newElement = document.createElement('div'); var newElement = document.createElement('div');
@ -261,7 +261,7 @@ function highlightReply(id) {
function generatePassword() { function generatePassword() {
var pass = ''; var pass = '';
var chars = '{% endraw %}{{ config.genpassword_chars }}{% raw %}'; var chars = '{% endverbatim %}{{ config.genpassword_chars }}{% verbatim %}';
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
var rnd = Math.floor(Math.random() * chars.length); var rnd = Math.floor(Math.random() * chars.length);
pass += chars.substring(rnd, rnd + 1); pass += chars.substring(rnd, rnd + 1);
@ -355,15 +355,15 @@ function rememberStuff() {
if (sessionStorage.body) { if (sessionStorage.body) {
var saved = JSON.parse(sessionStorage.body); var saved = JSON.parse(sessionStorage.body);
if (get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}')) { if (get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) {
// Remove successful posts // Remove successful posts
var successful = JSON.parse(get_cookie('{% endraw %}{{ config.cookies.js }}{% raw %}')); var successful = JSON.parse(get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}'));
for (var url in successful) { for (var url in successful) {
saved[url] = null; saved[url] = null;
} }
sessionStorage.body = JSON.stringify(saved); sessionStorage.body = JSON.stringify(saved);
document.cookie = '{% endraw %}{{ config.cookies.js }}{% raw %}={};expires=0;path=/;'; document.cookie = '{% endverbatim %}{{ config.cookies.js }}{% verbatim %}={};expires=0;path=/;';
} }
if (saved[document.location]) { if (saved[document.location]) {
document.forms.post.body.value = saved[document.location]; document.forms.post.body.value = saved[document.location];
@ -391,13 +391,13 @@ var script_settings = function(script_name) {
function init() { function init() {
init_stylechooser(); init_stylechooser();
{% endraw %} {% endverbatim %}
{% if config.allow_delete %} {% if config.allow_delete %}
if (document.forms.postcontrols) { if (document.forms.postcontrols) {
document.forms.postcontrols.password.value = localStorage.password; document.forms.postcontrols.password.value = localStorage.password;
} }
{% endif %} {% endif %}
{% raw %} {% verbatim %}
if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1)) if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1))
highlightReply(window.location.hash.substring(1)); highlightReply(window.location.hash.substring(1));
@ -418,16 +418,16 @@ function ready() {
} }
} }
{% endraw %} {% endverbatim %}
var post_date = "{{ config.post_date }}"; var post_date = "{{ config.post_date }}";
var max_images = {{ config.max_images }}; var max_images = {{ config.max_images }};
onready(init); onready(init);
{% if config.google_analytics %}{% raw %} {% if config.google_analytics %}{% verbatim %}
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %} var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endverbatim %}{{ config.google_analytics }}{% verbatim %}']);{% endverbatim %}{% if config.google_analytics_domain %}{% verbatim %}_gaq.push(['_setDomainName', '{% endverbatim %}{{ config.google_analytics_domain }}{% verbatim %}']){% endverbatim %}{% endif %}{% if not config.google_analytics_domain %}{% verbatim %}_gaq.push(['_setDomainName', 'none']){% endverbatim %}{% endif %}{% verbatim %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endverbatim %}{% endif %}
{% if config.statcounter_project and config.statcounter_security %} {% if config.statcounter_project and config.statcounter_security %}
var sc = document.createElement('script'); var sc = document.createElement('script');

12
templates/mod/config-editor-php.html

@ -2,15 +2,17 @@
<p> <p>
Any changes you make here will simply be appended to <code>{{ file }}</code>. If you wish to make the most of Tinyboard's customizability, you can instead edit the file directly. This page is intended for making quick changes and for those who don't have a basic understanding of PHP code. Any changes you make here will simply be appended to <code>{{ file }}</code>. If you wish to make the most of Tinyboard's customizability, you can instead edit the file directly. This page is intended for making quick changes and for those who don't have a basic understanding of PHP code.
</p> </p>
{% if boards|count %} {% if boards|length %}
<ul> <ul>
{% if board %} {% if board %}
<li><a href="?/config">Edit site-wide config</a></li> <li><a href="?/config">Edit site-wide config</a></li>
{% endif %} {% endif %}
{% for _board in boards if _board.uri != board %} {% for _board in boards %}
<li> {% if _board.uri != board %}
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a> <li>
</li> <a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}

82
templates/mod/config-editor.html

@ -6,10 +6,12 @@
{% if board %} {% if board %}
<li><a href="?/config">Edit site-wide config</a></li> <li><a href="?/config">Edit site-wide config</a></li>
{% endif %} {% endif %}
{% for _board in boards if _board.uri != board %} {% for _board in boards %}
<li> {% if _board.uri != board %}
<a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a> <li>
</li> <a href="?/config/{{ _board.uri }}">Edit config for {{ config.board_abbreviation|sprintf(_board.uri) }}</a>
</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
@ -38,38 +40,48 @@
{% endif %} {% endif %}
</th> </th>
<td> <tr>
{% if var.type == 'string' %} <th class="minimal">
<input name="{{ name }}" type="text" value="{{ var.value|e }}"> {% if var.name|length == 1 %}
{% elseif var.permissions %} {{ var.name }}
<select name="{{ name }}"> {% else %}
{% for group_value, group_name in config.mod.groups %} {{ var.name|join(' &rarr; ') }}
<option value="{{ group_value }}"{% if var.value == group_value %} selected{% endif %}> {% endif %}
{{ group_name }} </th>
</option>
{% endfor %}
</select>
{% elseif var.type == 'integer' %}
<input name="{{ name }}" type="number" value="{{ var.value|e }}">
{% elseif var.type == 'boolean' %}
<input name="{{ name }}" type="checkbox" {% if var.value %}checked{% endif %}>
{% else %}
?
{% endif %}
{% if var.type == 'integer' or var.type == 'boolean' %} <td>
<small>Default: <code>{{ var.default }}</code></small> {% if var.type == 'string' %}
{% endif %} <input name="{{ name }}" type="text" value="{{ var.value|e }}">
</td> {% elseif var.permissions %}
<select name="{{ name }}">
<td class="minimal"> {% for group_value, group_name in config.mod.groups %}
{{ var.type|e }} <option value="{{ group_value }}"{% if var.value == group_value %} selected{% endif %}>
</td> {{ group_name }}
</option>
<td style="word-wrap:break-word;width:50%"> {% endfor %}
{{ var.comment|join(' ') }} </select>
</td> {% elseif var.type == 'integer' %}
</tr> <input name="{{ name }}" type="number" value="{{ var.value|e }}">
{% elseif var.type == 'boolean' %}
<input name="{{ name }}" type="checkbox" {% if var.value %}checked{% endif %}>
{% else %}
?
{% endif %}
{% if var.type == 'integer' or var.type == 'boolean' %}
<small>Default: <code>{{ var.default }}</code></small>
{% endif %}
</td>
<td class="minimal">
{{ var.type|e }}
</td>
<td style="word-wrap:break-word;width:50%">
{{ var.comment|join(' ') }}
</td>
</tr>
{% endif %}
{% endfor %} {% endfor %}
</table> </table>

2
templates/mod/dashboard.html

@ -68,7 +68,7 @@
{% endif %} {% endif %}
{% if config.mod.dashboard_links|length %} {% if config.mod.dashboard_links and config.mod.dashboard_links|length %}
{% for label,link in config.mod.dashboard_links %} {% for label,link in config.mod.dashboard_links %}
<li><a href="{{ link }}">{{ label }}</a></li> <li><a href="{{ link }}">{{ label }}</a></li>

18
templates/mod/debug/apc.html

@ -6,13 +6,15 @@
<th class="minimal">Expires</th> <th class="minimal">Expires</th>
<th class="minimal">Size</th> <th class="minimal">Size</th>
</tr> </tr>
{% for var in cached_vars if (var.ctime is defined ? var.ctime : var.creation_time) + var.ttl > time() %} {% for var in cached_vars %}
<tr> {% if (var.ctime is defined ? var.ctime : var.creation_time) + var.ttl > time() %}
<td class="minimal">{{ var.key is defined ? var.key : var.info }}</td> <tr>
<td class="minimal">{{ var.nhits is defined ? var.nhits : var.num_hits }}</td> <td class="minimal">{{ var.key is defined ? var.key : var.info }}</td>
<td class="minimal">{{ (var.ctime is defined ? var.ctime : var.creation_time)|ago }} ago</td> <td class="minimal">{{ var.nhits is defined ? var.nhits : var.num_hits }}</td>
<td class="minimal">{{ ((var.ctime is defined ? var.ctime : var.creation_time) + var.ttl)|until }} (ttl: {{ (time() + var.ttl)|until }})</td> <td class="minimal">{{ (var.ctime is defined ? var.ctime : var.creation_time)|ago }} ago</td>
<td class="minimal">{{ var.mem_size }} bytes</td> <td class="minimal">{{ ((var.ctime is defined ? var.ctime : var.creation_time) + var.ttl)|until }} (ttl: {{ (time() + var.ttl)|until }})</td>
</tr> <td class="minimal">{{ var.mem_size }} bytes</td>
</tr>
{% endif %}
{% endfor %} {% endfor %}
</table> </table>

2
templates/mod/debug/recent_posts.html

@ -33,7 +33,7 @@
</table> </table>
<p style="text-align:center"> <p style="text-align:center">
Most recent {{ posts|count }} posts: Most recent {{ posts|length }} posts:
</p> </p>
<table class="modlog" style="word-wrap: break-word;"> <table class="modlog" style="word-wrap: break-word;">
<tr> <tr>

2
templates/mod/inbox.html

@ -1,4 +1,4 @@
{% if not messages %} {% if messages|length == 0 %}
<p style="text-align:center" class="unimportant">({% trans 'No private messages for you.' %})</p> <p style="text-align:center" class="unimportant">({% trans 'No private messages for you.' %})</p>
{% else %} {% else %}
<table class="modlog"> <table class="modlog">

2
templates/mod/log.html

@ -49,7 +49,7 @@
{% endfor %} {% endfor %}
</table> </table>
{% if count > logs|count %} {% if count > logs|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word"> <p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.modlog_page) %} {% for i in range(0, (count - 1) / config.mod.modlog_page) %}
{% if public %} {% if public %}

16
templates/mod/move.html

@ -22,13 +22,15 @@
<th>{% trans 'Target board' %}</th> <th>{% trans 'Target board' %}</th>
<td> <td>
<ul style="list-style:none;padding:0"> <ul style="list-style:none;padding:0">
{% for targetboard in boards if targetboard.uri != board %} {% for targetboard in boards %}
<li> {% if targetboard.uri != board %}
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|count == 2 %}checked{% endif %}> <li>
<label style="display:inline" for="ban-board-{{ targetboard.uri }}"> <input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|length == 2 %}checked{% endif %}>
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }} <label style="display:inline" for="ban-board-{{ targetboard.uri }}">
</label> {{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
</li> </label>
</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
</td> </td>

2
templates/mod/move_reply.html

@ -15,7 +15,7 @@
<ul style="list-style:none;padding:0"> <ul style="list-style:none;padding:0">
{% for targetboard in boards %} {% for targetboard in boards %}
<li> <li>
<input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|count == 2 %}checked{% endif %}> <input type="radio" name="board" value="{{ targetboard.uri }}" id="ban-board-{{ targetboard.uri }}" {% if boards|length == 2 %}checked{% endif %}>
<label style="display:inline" for="ban-board-{{ targetboard.uri }}"> <label style="display:inline" for="ban-board-{{ targetboard.uri }}">
{{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }} {{ config.board_abbreviation|sprintf(targetboard.uri) }} - {{ targetboard.title|e }}
</label> </label>

2
templates/mod/news.html

@ -62,7 +62,7 @@
</div> </div>
{% endfor %} {% endfor %}
{% if count > news|count %} {% if count > news|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word"> <p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.news_page) %} {% for i in range(0, (count - 1) / config.mod.news_page) %}
<a href="?/news/{{ i + 1 }}">[{{ i + 1 }}]</a> <a href="?/news/{{ i + 1 }}">[{{ i + 1 }}]</a>

2
templates/mod/noticeboard.html

@ -57,7 +57,7 @@
</div> </div>
{% endfor %} {% endfor %}
{% if count > noticeboard|count %} {% if count > noticeboard|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word"> <p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (count - 1) / config.mod.noticeboard_page) %} {% for i in range(0, (count - 1) / config.mod.noticeboard_page) %}
<a href="?/noticeboard/{{ i + 1 }}">[{{ i + 1 }}]</a> <a href="?/noticeboard/{{ i + 1 }}">[{{ i + 1 }}]</a>

2
templates/mod/recent_posts.html

@ -1,6 +1,6 @@
<script src="{{ config.additional_javascript_url }}js/mod/recent_posts.js"></script> <script src="{{ config.additional_javascript_url }}js/mod/recent_posts.js"></script>
<script src="{{ config.additional_javascript_url }}js/mod/recent-posts-auto-reload.js"></script> <script src="{{ config.additional_javascript_url }}js/mod/recent-posts-auto-reload.js"></script>
{% if not posts %} {% if not posts|length %}
<p style="text-align:center" class="unimportant">({% trans 'There are no active posts.' %})</p> <p style="text-align:center" class="unimportant">({% trans 'There are no active posts.' %})</p>
{% else %} {% else %}
<h4>Viewing last {{ limit|e }} posts</h4> <h4>Viewing last {{ limit|e }} posts</h4>

2
templates/mod/search_results.html

@ -259,7 +259,7 @@
</table> </table>
{% endif %} {% endif %}
{% if result_count > results|count %} {% if result_count > results|length %}
<p class="unimportant" style="text-align:center;word-wrap:break-word"> <p class="unimportant" style="text-align:center;word-wrap:break-word">
{% for i in range(0, (result_count - 1) / config.mod.search_page) %} {% for i in range(0, (result_count - 1) / config.mod.search_page) %}
<a href="?/search/{{ search_type }}/{{ search_query_escaped }}/{{ i + 1 }}">[{{ i + 1 }}]</a> <a href="?/search/{{ search_type }}/{{ search_query_escaped }}/{{ i + 1 }}">[{{ i + 1 }}]</a>

2
templates/mod/themes.html

@ -1,4 +1,4 @@
{% if not themes %} {% if themes|length == 0 %}
<p style="text-align:center" class="unimportant">({% trans 'There are no themes available.' %})</p> <p style="text-align:center" class="unimportant">({% trans 'There are no themes available.' %})</p>
{% else %} {% else %}
<table class="modlog"> <table class="modlog">

14
templates/mod/user.html

@ -32,11 +32,13 @@
<th>{% trans 'Group' %}</th> <th>{% trans 'Group' %}</th>
<td> <td>
<ul style="padding:5px 8px;list-style:none"> <ul style="padding:5px 8px;list-style:none">
{% for group_value, group_name in config.mod.groups if group_name != 'Disabled' %} {% for group_value, group_name in config.mod.groups %}
<li> {% if group_name != 'Disabled' %}
<input type="radio" name="type" id="group_{{ group_name }}" value="{{ group_value }}"> <li>
<label for="group_{{ group_name }}">{% trans group_name %}</label> <input type="radio" name="type" id="group_{{ group_name }}" value="{{ group_value }}">
</li> <label for="group_{{ group_name }}">{% trans group_name %}</label>
</li>
{% endif %}
{% endfor %} {% endfor %}
</ul> </ul>
</td> </td>
@ -87,7 +89,7 @@
</ul> </ul>
</form> </form>
{% if logs and logslength > 0 %} {% if logs and logs|length > 0 %}
<table class="modlog" style="width:600px"> <table class="modlog" style="width:600px">
<tr> <tr>
<th>{% trans 'IP address' %}</th> <th>{% trans 'IP address' %}</th>

4
templates/mod/view_ip.html

@ -1,8 +1,8 @@
{% if mod|hasPermission(config.mod.view_notes) %} {% if mod|hasPermission(config.mod.view_notes) %}
<fieldset id="notes"> <fieldset id="notes">
<legend> <legend>
{% set notes_on_record = 'note' ~ (notes|count != 1 ? 's' : '') ~ ' on record' %} {% set notes_length = notes|length %}
<legend>{{ notes|count }} {% trans notes_on_record %}</legend> <legend>{{ notes_length }} {% trans %}note on record{% plural notes_length %}notes on record{% endtrans %}</legend>
</legend> </legend>
{% if notes and notes|length > 0 %} {% if notes and notes|length > 0 %}

4
templates/notbanned.html

@ -1,7 +1,7 @@
{% filter remove_whitespace %} {% apply spaceless %}
{# Automatically removes unnecessary whitespace #} {# Automatically removes unnecessary whitespace #}
<div class="ban"> <div class="ban">
<h2>You are not banned!</h2> <h2>You are not banned!</h2>
<p class="reason">Well done on not being terrible!</p> <p class="reason">Well done on not being terrible!</p>
</div> </div>
{% endfilter %} {% endapply %}

4
templates/page.html

@ -35,8 +35,8 @@
</footer> </footer>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

4
templates/post_form.html

@ -220,6 +220,6 @@
{% if 'js/upload-selection.js' in config.additional_javascript %} {% if 'js/upload-selection.js' in config.additional_javascript %}
<script type="text/javascript">if (typeof init_upload_selection !== 'undefined') init_upload_selection();</script> <script type="text/javascript">if (typeof init_upload_selection !== 'undefined') init_upload_selection();</script>
{% endif %} {% endif %}
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
rememberStuff(); rememberStuff();
{% endraw %}</script> {% endverbatim %}</script>

8
templates/post_reply.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
{# tabs and new lines will be ignored #} {# tabs and new lines will be ignored #}
<div class="post reply" id="reply_{{ post.id }}" data-board="{{ board.uri }}"> <div class="post reply" id="reply_{{ post.id }}" data-board="{{ board.uri }}">
<p class="intro"> <p class="intro">
@ -18,7 +18,7 @@
{% include 'post/fileinfo.html' %} {% include 'post/fileinfo.html' %}
{% include 'post/post_controls.html' %} {% include 'post/post_controls.html' %}
<div class="body" {% if post.files|length > 1 %}style="clear:both"{% endif %}> <div class="body" {% if post.files|length > 1 %}style="clear:both"{% endif %}>
{% endfilter %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% filter remove_whitespace %} {% endapply %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% apply spaceless %}
{% if post.modifiers['ban message'] %} {% if post.modifiers['ban message'] %}
{{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }} {{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }}
{% endif %} {% endif %}
@ -27,5 +27,5 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
</br> <br/>
{% endfilter %} {% endapply %}

6
templates/post_thread.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
{# tabs and new lines will be ignored #} {# tabs and new lines will be ignored #}
<div class="thread" id="thread_{{ post.id }}" data-board="{{ board.uri }}"> <div class="thread" id="thread_{{ post.id }}" data-board="{{ board.uri }}">
@ -58,7 +58,7 @@
{% include 'post/post_controls.html' %} {% include 'post/post_controls.html' %}
</p> </p>
<div class="body"> <div class="body">
{% endfilter %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% filter remove_whitespace %} {% endapply %}{% if index %}{{ post.body|truncate_body(post.link) }}{% else %}{{ post.body }}{% endif %}{% apply spaceless %}
{% if post.modifiers['ban message'] %} {% if post.modifiers['ban message'] %}
{{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }} {{ config.mod.ban_message|sprintf(post.modifiers['ban message']) }}
{% endif %} {% endif %}
@ -89,7 +89,7 @@
{% endif %} {% endif %}
{% if not index %} {% if not index %}
{% endif %} {% endif %}
</div>{% endfilter %} </div>{% endapply %}
{% set iparray = [post.ip] %} {% set iparray = [post.ip] %}
{% set hr = post.hr %} {% set hr = post.hr %}
{% for post in post.posts %} {% for post in post.posts %}

4
templates/post_thread_fileboard.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
{# tabs and new lines will be ignored #} {# tabs and new lines will be ignored #}
{# we are intentionally breaking the thread_ID convention: the jses need to handle this case differently #} {# we are intentionally breaking the thread_ID convention: the jses need to handle this case differently #}
@ -39,4 +39,4 @@
<a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post) }}">[{% trans %}Reply{% endtrans %}]</a> <a href="{{ post.root }}{{ board.dir }}{{ config.dir.res }}{{ link_for(post) }}">[{% trans %}Reply{% endtrans %}]</a>
</tr> </tr>
{% endfilter %} {% endapply %}

10
templates/themes/basic/index.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -24,7 +24,7 @@
<img src="static/lain_is_cute_datass_small_teal.png" alt="mascot"/> <img src="static/lain_is_cute_datass_small_teal.png" alt="mascot"/>
</center> </center>
<div class="ban"> <div class="ban">
{% if not news %} {% if news|length == 0 %}
<p style="text-align:center" class="unimportant">(No news to show.)</p> <p style="text-align:center" class="unimportant">(No news to show.)</p>
{% else %} {% else %}
{% for entry in news %} {% for entry in news %}
@ -49,9 +49,9 @@
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p> <br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel</p>
</footer> </footer>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>
{% endfilter %} {% endapply %}

4
templates/themes/calendar/calendar.html

@ -185,8 +185,8 @@
}); });
</script> </script>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

8
templates/themes/catalog/catalog.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -107,9 +107,9 @@
</footer> </footer>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>
{% endfilter %} {% endapply %}

7
templates/themes/categories/news.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<div class="introduction"> <div class="introduction">
<style style="display:none;"> <style style="display:none;">
.home-logo { .home-logo {
@ -26,7 +26,7 @@
</div> </div>
<div class="content"> <div class="content">
<div class="ban"> <div class="ban">
{% if not news %} {% if news|length == 0 %}
<p style="text-align:center" class="unimportant">{% trans %}(No news to show.){% endtrans %}</p> <p style="text-align:center" class="unimportant">{% trans %}(No news to show.){% endtrans %}</p>
{% else %} {% else %}
{% for entry in news %} {% for entry in news %}
@ -107,5 +107,4 @@
<br><b>Leftypol.org is not currently under investigation by any Federal, State, or Local Authorities.</b></p> <br><b>Leftypol.org is not currently under investigation by any Federal, State, or Local Authorities.</b></p>
</footer> </footer>
</div> </div>
{% endfilter %} {% endapply %}

4
templates/themes/categories/sidebar.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<div class="sidebar"> <div class="sidebar">
<fieldset> <fieldset>
<legend>{{ settings.title }}</legend> <legend>{{ settings.title }}</legend>
@ -42,4 +42,4 @@
{% endfor %} {% endfor %}
</div> </div>
{% endfilter %} {% endapply %}

4
templates/themes/donate/donate.html

@ -52,9 +52,9 @@
</div> </div>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

4
templates/themes/faq/index.html

@ -139,9 +139,9 @@
<br>vichan Copyright &copy; 2012-2016 vichan-devel</p> <br>vichan Copyright &copy; 2012-2016 vichan-devel</p>
</footer> </footer>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>
{% endfilter %} {% endfilter %}

6
templates/themes/frameset/news.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -13,7 +13,7 @@
</header> </header>
<div class="ban"> <div class="ban">
{% if not news %} {% if news|length == 0 %}
<p style="text-align:center" class="unimportant">(No news to show.)</p> <p style="text-align:center" class="unimportant">(No news to show.)</p>
{% else %} {% else %}
{% for entry in news %} {% for entry in news %}
@ -38,4 +38,4 @@
</footer> </footer>
</body> </body>
</html> </html>
{% endfilter %} {% endapply %}

4
templates/themes/frameset/sidebar.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -38,4 +38,4 @@
</fieldset> </fieldset>
</body> </body>
</html> </html>
{% endfilter %} {% endapply %}

4
templates/themes/irc/irc.html

@ -27,9 +27,9 @@
<iframe src="https://kiwiirc.com/nextclient/#irc://{{ settings.server }}:+{{ settings.port }}/#{{ settings.channel }}" width="800px" height="100%" scrolling="no"></iframe> <iframe src="https://kiwiirc.com/nextclient/#irc://{{ settings.server }}:+{{ settings.port }}/#{{ settings.channel }}" width="800px" height="100%" scrolling="no"></iframe>
</div> </div>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>
{% endfilter %} {% endfilter %}

4
templates/themes/radio/radio.html

@ -127,8 +127,8 @@ $(document).ready(function(){
<p style="text-align:center;"> To upload a voice-over / bump to radio click <a href="{{ settings.httpprefix ~ 'bump.html'}}" >here </a> </p> <p style="text-align:center;"> To upload a voice-over / bump to radio click <a href="{{ settings.httpprefix ~ 'bump.html'}}" >here </a> </p>
</div> </div>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

4
templates/themes/recent/recent.html

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
@ -98,4 +98,4 @@
</div> </div>
</body> </body>
</html> </html>
{% endfilter %} {% endapply %}

4
templates/themes/rss/rss.xml

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" <rss xmlns:dc="http://purl.org/dc/elements/1.1/"
version="2.0"> version="2.0">
@ -25,4 +25,4 @@
{% endfor %} {% endfor %}
</channel> </channel>
</rss> </rss>
{% endfilter %} {% endapply %}

4
templates/themes/rules/rules.html

@ -26,9 +26,9 @@
{% include 'rules.html' %} {% include 'rules.html' %}
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>
{% endfilter %} {% endfilter %}

4
templates/themes/sitemap/sitemap.xml

@ -1,4 +1,4 @@
{% filter remove_whitespace %} {% apply spaceless %}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
{% for board in boards %} {% for board in boards %}
@ -16,4 +16,4 @@
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
</urlset> </urlset>
{% endfilter %} {% endapply %}

4
templates/themes/staffapplication/staffapplication.html

@ -72,9 +72,9 @@
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p> <br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p>
</footer> </footer>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>
{% endfilter %} {% endfilter %}

4
templates/themes/stream/stream.html

@ -174,8 +174,8 @@ function change_format(e) {
<br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p> <br><a href="https://github.com/lainchan/lainchan">lainchan</a> Copyright &copy; 2014-2017 lainchan Administration</p>
</footer> </footer>
<div class="pages"></div> <div class="pages"></div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
</body> </body>
</html> </html>

4
templates/thread.html

@ -113,9 +113,9 @@
</div> </div>
<div class=pages></div> <div class=pages></div>
</div> </div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
<a href="#" id="bottom"></a> <a href="#" id="bottom"></a>
</body> </body>
</html> </html>

4
templates/thread2_old.html

@ -111,9 +111,9 @@
</div> </div>
<div class=pages></div> <div class=pages></div>
</div> </div>
<script type="text/javascript">{% raw %} <script type="text/javascript">{% verbatim %}
ready(); ready();
{% endraw %}</script> {% endverbatim %}</script>
<a href="#" id="bottom"></a> <a href="#" id="bottom"></a>
</body> </body>
</html> </html>

0
tmp/cache/.gitkeep

2
tools/rebuild.php

@ -42,7 +42,7 @@ if(!$options['quiet'])
echo "Clearing template cache...\n"; echo "Clearing template cache...\n";
load_twig(); load_twig();
$twig->clearCacheFiles(); $twig->getCache()->clear();
if(!$options['quiet']) if(!$options['quiet'])
echo "Regenerating theme files...\n"; echo "Regenerating theme files...\n";

2
tools/rebuild2.php

@ -44,7 +44,7 @@ echo "== Tinyboard + vichan {$config['version']} ==\n";
if ($options['cache']) { if ($options['cache']) {
echo "Clearing template cache...\n"; echo "Clearing template cache...\n";
load_twig(); load_twig();
$twig->clearCacheFiles(); $twig->getCache()->clear();
} }
if($options['themes']) { if($options['themes']) {

Loading…
Cancel
Save