From fb34878bb15562368071cef539a42ce5df8d7a22 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 23 Apr 2015 04:28:23 +0200 Subject: [PATCH] fileboard/8chan: mod config --- inc/8chan-mod-pages.php | 57 +++++++++++++++++++++++++++++++---- inc/config.php | 3 ++ templates/mod/settings.html | 59 ++++++++++++++++++++++++++++++++----- 3 files changed, 105 insertions(+), 14 deletions(-) diff --git a/inc/8chan-mod-pages.php b/inc/8chan-mod-pages.php index a8e44311..f0c2bd58 100644 --- a/inc/8chan-mod-pages.php +++ b/inc/8chan-mod-pages.php @@ -384,13 +384,18 @@ FLAGS; $possible_languages = array_diff(scandir('inc/locale/'), array('..', '.', '.tx', 'README.md')); if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $board_type = $_POST['board_type']; + $imgboard = $board_type == 'imgboard'; + $txtboard = $board_type == 'txtboard'; + $fileboard = $board_type == 'fileboard'; + $title = $_POST['title']; $subtitle = $_POST['subtitle']; $country_flags = isset($_POST['country_flags']) ? 'true' : 'false'; $field_disable_name = isset($_POST['field_disable_name']) ? 'true' : 'false'; $enable_embedding = isset($_POST['enable_embedding']) ? 'true' : 'false'; - $force_image_op = isset($_POST['force_image_op']) ? 'true' : 'false'; - $disable_images = isset($_POST['disable_images']) ? 'true' : 'false'; + $force_image_op = $imgboard && isset($_POST['force_image_op']) ? 'true' : 'false'; + $disable_images = $txtboard ? 'true' : 'false'; $poster_ids = isset($_POST['poster_ids']) ? 'true' : 'false'; $show_sages = isset($_POST['show_sages']) ? 'true' : 'false'; $auto_unicode = isset($_POST['auto_unicode']) ? 'true' : 'false'; @@ -400,8 +405,8 @@ FLAGS; $image_reject_repost_in_thread = isset($_POST['image_reject_repost_in_thread']) ? 'true' : 'false'; $early_404 = isset($_POST['early_404']) ? 'true' : 'false'; $allow_delete = isset($_POST['allow_delete']) ? 'true' : 'false'; - $allow_flash = isset($_POST['allow_flash']) ? '$config[\'allowed_ext_files\'][] = \'swf\';' : ''; - $allow_pdf = isset($_POST['allow_pdf']) ? '$config[\'allowed_ext_files\'][] = \'pdf\';' : ''; + $allow_flash = $imgboard && isset($_POST['allow_flash']) ? '$config[\'allowed_ext_files\'][] = \'swf\';' : ''; + $allow_pdf = $imgboard && isset($_POST['allow_pdf']) ? '$config[\'allowed_ext_files\'][] = \'pdf\';' : ''; $code_tags = isset($_POST['code_tags']) ? '$config[\'additional_javascript\'][] = \'js/code_tags/run_prettify.js\';$config[\'markup\'][] = array("/\[code\](.+?)\[\/code\]/ms", "
\$1
");' : ''; $katex = isset($_POST['katex']) ? '$config[\'katex\'] = true;$config[\'additional_javascript\'][] = \'js/katex/katex.min.js\'; $config[\'markup\'][] = array("/\[tex\](.+?)\[\/tex\]/ms", "\$1"); $config[\'additional_javascript\'][] = \'js/katex-enable.js\';' : ''; $user_flags = isset($_POST['user_flags']) ? "if (file_exists('$b/flags.php')) { include 'flags.php'; }\n" : ''; @@ -410,7 +415,7 @@ FLAGS; $force_flag = isset($_POST['force_flag']) ? 'true' : 'false'; $tor_posting = isset($_POST['tor_posting']) ? 'true' : 'false'; $new_thread_capt = isset($_POST['new_thread_capt']) ? 'true' : 'false'; - $oekaki = isset($_POST['oekaki']) ? 'true' : 'false'; + $oekaki = ($imgboard || $fileboard) && isset($_POST['oekaki']) ? 'true' : 'false'; if ($_POST['locale'] !== 'en' && in_array($_POST['locale'], $possible_languages)) { $locale = "\$config['locale'] = '{$_POST['locale']}.UTF-8';"; @@ -426,6 +431,45 @@ FLAGS; $multiimage = ''; } + $file_board = ''; + if ($fileboard) { + $force_image_op = true; + + $file_board = "\$config['threads_per_page'] = 30; + \$config['file_board'] = true; + \$config['threads_preview'] = 0; + \$config['threads_preview_sticky'] = 0; + \$config['allowed_ext_files'] = array();\n"; + + + if (isset ($_POST['allowed_type'])) { + foreach ($_POST['allowed_type'] as $val) { + if (in_array ($val, $config['fileboard_allowed_types'])) { + $file_board .= "\$config['allowed_ext_files'][] = '$val';\n"; + } + } + } + + if (isset ($_POST['allowed_ext_op'])) { + $file_board .= "\$config['allowed_ext_op'] = \$config['allowed_ext_files'];\n"; + } + + if (isset ($_POST['tag_id'])) { + $file_board .= "\$config['allowed_tags'] = array();\n"; + foreach ($_POST['tag_id'] as $id => $v) { + $file_board .= "\$config['allowed_tags']["; + $file_board .= 'base64_decode("'; + $file_board .= base64_encode($_POST['tag_id'][$id]); + $file_board .= '")'; + $file_board .= "] = "; + $file_board .= 'base64_decode("'; + $file_board .= base64_encode($_POST['tag_desc'][$id]); + $file_board .= '")'; + $file_board .= ";\n"; + } + } + } + $anonymous = base64_encode($_POST['anonymous']); $blotter = base64_encode(purify_html(html_entity_decode($_POST['blotter']))); $add_to_config = @file_get_contents($b.'/extra_config.php'); @@ -461,7 +505,7 @@ FLAGS; if (isset($_POST['max_pages'])) { $mp = (int)$_POST['max_pages']; - if ($mp > 25 || $mp < 2) { + if ($mp > 25 || $mp < 1) { $max_pages = 15; } else { $max_pages = $mp; @@ -542,6 +586,7 @@ if (\$config['disable_images']) \$config['max_pages'] = 10000; $locale +$file_board $add_to_config EOT; diff --git a/inc/config.php b/inc/config.php index 7e683bb2..cdc0eeaf 100644 --- a/inc/config.php +++ b/inc/config.php @@ -794,6 +794,9 @@ // Details: https://github.com/savetheinternet/Tinyboard/issues/20 $config['ie_mime_type_detection'] = '/<(?:body|head|html|img|plaintext|pre|script|table|title|a href|channel|scriptlet)/i'; + // Config panel, fileboard: allowed upload extensions + $config['fileboard_allowed_types'] = array('zip', '7z', 'tar', 'gz', 'bz2', 'xz', 'swf', 'txt', 'torrent'); + // Allowed image file extensions. $config['allowed_ext'][] = 'jpg'; $config['allowed_ext'][] = 'jpeg'; diff --git a/templates/mod/settings.html b/templates/mod/settings.html index 04f6a7cd..eb2673bf 100644 --- a/templates/mod/settings.html +++ b/templates/mod/settings.html @@ -24,14 +24,18 @@ + - + - @@ -39,10 +43,10 @@ - + - - + + @@ -53,7 +57,7 @@ - + + + + +
{% trans %}Board type{% endtrans %}
{% trans %}Country flags{% endtrans %}
{% trans %}/pol/-style user flags{% endtrans %}
Enabling this disables country flags
Make sure to actually upload some first!
{% trans %}Forced anonymous{% endtrans %}
{% trans %}YouTube/Voocaroo embedding{% endtrans %}
{% trans %}Require image for OP{% endtrans %}
{% trans %}Require image for OP{% endtrans %}
{% trans %}Require subject for OP{% endtrans %}
{% trans %}Require user/country flag for all posts{% endtrans %}
{% trans %}Disable images{% endtrans %}
{% trans %}Poster ID's{% endtrans %}
{% trans %}Display SAGE! after saged posts{% endtrans %}
{% trans %}Automatically convert ... to …{% endtrans %}
{% trans %}No index{% endtrans %}
{% trans %}Hide from boards index
and do not index in search engines{% endtrans %}
{% trans %}Archive my board on 8archive.moe{% endtrans %}
{% trans %}This archives your board on 8archive.moe if you opt in{% endtrans %}
{% trans %}[code] tags{% endtrans %}
{% trans %}Oekaki{% endtrans %}
{% trans %}Oekaki{% endtrans %}
{% trans %}Format math between $${% endtrans %}
{% trans %}Allow SWF uploading{% endtrans %}
{% trans %}Allow PDF uploading{% endtrans %}
{% trans %}Allow SWF uploading{% endtrans %}
{% trans %}Allow PDF uploading{% endtrans %}
{% trans %}Enable dice rolling{% endtrans %}
{% trans %}Don't allow users to repost images (whole board){% endtrans %}
{% trans %}Don't allow users to repost images (same thread){% endtrans %}
{% trans %}Public bans{% endtrans %}
{% trans %}Displays your bans for the public{% endtrans %}
{% trans %}Public action log{% endtrans %}
{% trans %}Displays all actions to the public{% endtrans %}
{% trans %}Max number of newlines per post{% endtrans %}
{% trans %}Page count{% endtrans %}
{% trans %}Page count{% endtrans %}
{% trans %}Bump limit{% endtrans %}
{% trans %}Language{% endtrans %}
{% trans %}Read this page for more information about contributing translations:
Translation tutorial or use Transifex{% endtrans %}
{% trans %}Allowed file types{% endtrans %} + {% for type in config.fileboard_allowed_types %} + + {% endfor %} +
{% trans %}Disable OP image upload{% endtrans %}
{% trans %}Max images per post{% endtrans %}
@@ -99,9 +111,25 @@ {% endif %} - + + + + + + {% if config.allowed_tags %} + {% for tag_id, tag_desc in config.allowed_tags %} + + {% endfor %} + {% else %} + + {% endif %} +
{% trans %}Tags{% endtrans %}
{% trans %}ID{% endtrans %}{% trans %}Description{% endtrans %}
+ + - +