1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-21 21:19:36 +01:00

fileboard/8chan: mod config

This commit is contained in:
czaks 2015-04-23 04:28:23 +02:00
parent e2218ff471
commit fb34878bb1
3 changed files with 105 additions and 14 deletions

View File

@ -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", "<code><pre class=\'prettyprint\' style=\'display:inline-block\'>\$1</pre></code>");' : '';
$katex = isset($_POST['katex']) ? '$config[\'katex\'] = true;$config[\'additional_javascript\'][] = \'js/katex/katex.min.js\'; $config[\'markup\'][] = array("/\[tex\](.+?)\[\/tex\]/ms", "<span class=\'tex\'>\$1</span>"); $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;

View File

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

View File

@ -24,14 +24,18 @@
</table>
<table>
<tr><th>{% trans %}Board type{% endtrans %}</th><td><select name="board_type" id="board_type">
<option value="imgboard" {% if not config.disable_images and not config.file_board %}selected{% endif %}>Image board</option>
<option value="txtboard" {% if config.disable_images %}selected{% endif %}>Text board</option>
<option value="fileboard" {% if config.file_board %}selected{% endif %}>File board</option>
</select></td></tr>
<tr><th>{% trans %}Country flags{% endtrans %}</th><td><input type="checkbox" name="country_flags" {% if config.country_flags %}checked{% endif %}></td></tr>
<tr><th>{% trans %}/pol/-style user flags{% endtrans %}<br><span class="unimportant">Enabling this disables country flags<br>Make sure to actually upload some first!</span></th><td><input type="checkbox" name="user_flags" {% if config.user_flag %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Forced anonymous{% endtrans %}</th><td><input type="checkbox" name="field_disable_name" {% if config.field_disable_name %}checked{% endif %}></td></tr>
<tr><th>{% trans %}YouTube/Voocaroo embedding{% endtrans %}</th><td><input type="checkbox" name="enable_embedding" {% if config.enable_embedding %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Require image for OP{% endtrans %}</th><td><input type="checkbox" name="force_image_op" {% if config.force_image_op %}checked{% endif %}></td></tr>
<tr class='imgboard'><th>{% trans %}Require image for OP{% endtrans %}</th><td><input type="checkbox" name="force_image_op" {% if config.force_image_op %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Require subject for OP{% endtrans %}</th><td><input type="checkbox" name="force_subject_op" {% if config.force_subject_op %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Require user/country flag for all posts{% endtrans %}</th><td><input type="checkbox" name="force_flag" {% if config.force_flag %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Disable images{% endtrans %}</th><td><input type="checkbox" name="disable_images" {% if config.disable_images %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Poster ID's{% endtrans %}</th><td><input type="checkbox" name="poster_ids" {% if config.poster_ids %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Display SAGE! after saged posts{% endtrans %}</th><td><input type="checkbox" name="show_sages" {% if config.show_sages %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Automatically convert ... to …{% endtrans %}</th><td><input type="checkbox" name="auto_unicode" {% if config.auto_unicode %}checked{% endif %}></td></tr>
@ -39,10 +43,10 @@
<tr><th>{% trans %}No index{% endtrans %}<br><span class="unimportant">{% trans %}Hide from boards index<br/>and do not index in search engines{% endtrans %}</span></th><td><input type="checkbox" name="meta_noindex" {% if not board.indexed %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Archive my board on 8archive.moe{% endtrans %}<br><span class="unimportant">{% trans %}This archives your board on 8archive.moe if you opt in{% endtrans %}</span></th><td><input type="checkbox" name="8archive" {% if board['8archive'] %}checked{% endif %}></td></tr>
<tr><th>{% trans %}[code] tags{% endtrans %}</th><td><input type="checkbox" name="code_tags" {% if 'js/code_tags/run_prettify.js' in config.additional_javascript %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Oekaki{% endtrans %}</th><td><input type="checkbox" name="oekaki" {% if config.oekaki %}checked{% endif %}></td></tr>
<tr class='imgboard fileboard'><th>{% trans %}Oekaki{% endtrans %}</th><td><input type="checkbox" name="oekaki" {% if config.oekaki %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Format math between $${% endtrans %}</th><td><input type="checkbox" name="katex" {% if config.katex %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Allow SWF uploading{% endtrans %}</th><td><input type="checkbox" name="allow_flash" {% if 'swf' in config.allowed_ext_files %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Allow PDF uploading{% endtrans %}</th><td><input type="checkbox" name="allow_pdf" {% if 'pdf' in config.allowed_ext_files %}checked{% endif %}></td></tr>
<tr class='imgboard'><th>{% trans %}Allow SWF uploading{% endtrans %}</th><td><input type="checkbox" name="allow_flash" {% if 'swf' in config.allowed_ext_files %}checked{% endif %}></td></tr>
<tr class='imgboard'><th>{% trans %}Allow PDF uploading{% endtrans %}</th><td><input type="checkbox" name="allow_pdf" {% if 'pdf' in config.allowed_ext_files %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Enable dice rolling{% endtrans %}</th><td><input type="checkbox" name="allow_roll" {% if config.allow_roll %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Don't allow users to repost images (whole board){% endtrans %}</th><td><input type="checkbox" name="image_reject_repost" {% if config.image_reject_repost %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Don't allow users to repost images (same thread){% endtrans %}</th><td><input type="checkbox" name="image_reject_repost_in_thread" {% if config.image_reject_repost_in_thread %}checked{% endif %}></td></tr>
@ -53,7 +57,7 @@
<tr><th>{% trans %}Public bans{% endtrans %}<br><span class="unimportant">{% trans %}Displays your bans for the public{% endtrans %}</span></th><td><input type="checkbox" name="public_bans" {% if board.public_bans %}checked{% endif %}></td></tr>
<tr><th>{% trans %}Public action log{% endtrans %}<br><span class="unimportant">{% trans %}Displays all actions to the public{% endtrans %}</span></th><td><select name="public_logs"><option value="0" {% if board.public_logs == 0 %}selected{% endif %}>None</option><option value="1" {% if board.public_logs == 1 %}selected{% endif %}>Full log of all actions</option><option value="2" {% if board.public_logs == 2 %}selected{% endif %}>Full log of all actions, no usernames</option></td></tr>
<tr><th>{% trans %}Max number of newlines per post{% endtrans %}</th><td><select name="max_newlines"><option value="0" {% if config.max_newlines == 0 %}selected{% endif %}>unlimited</option>{% for i in range(20, 300) %}<option value="{{ i }}" {% if config.max_newlines == i %}selected{% endif %}>{{ i }}</option>{% endfor %}</select></td></tr>
<tr><th>{% trans %}Page count{% endtrans %}</th><td><select name="max_pages">{% for i in range(2, 25) %}<option value="{{ i }}" {% if config.max_pages == i %}selected{% endif %}>{{ i }}</option>{% endfor %}</select></td></tr>
<tr><th>{% trans %}Page count{% endtrans %}</th><td><select name="max_pages">{% for i in range(1, 25) %}<option value="{{ i }}" {% if config.max_pages == i %}selected{% endif %}>{{ i }}</option>{% endfor %}</select></td></tr>
<tr><th>{% trans %}Bump limit{% endtrans %}</th><td><select name="reply_limit">{% for i in range(250, 750, 25) %}<option value="{{ i }}" {% if config.reply_limit == i %}selected{% endif %}>{{ i }}</option>{% endfor %}</select></td></tr>
<tr><th>{% trans %}Language{% endtrans %}<br/><span class="unimportant">{% trans %}Read this page for more information about contributing translations:<br><a href="/translation.html">Translation tutorial</a> or use <a href="https://www.transifex.com/projects/p/infinity/">Transifex</a>{% endtrans %}</span></th><td>
<select name="locale">
@ -64,6 +68,14 @@
{% endfor %}
</select>
</td></tr>
<tr class='fileboard'><th>{% trans %}Allowed file types{% endtrans %}</th><td>
{% for type in config.fileboard_allowed_types %}
<label><input type='checkbox' name='allowed_type[]' value='{{ type }}' {% if type in config.allowed_ext_files %}checked{% endif %}>{{ type }}</label>
{% endfor %}
</td></tr>
<tr class='fileboard'><th>{% trans %}Disable OP image upload{% endtrans %}</th><td><input type="checkbox" name="allowed_ext_op" {% if config.allowed_ext_op %}checked{% endif %}></td></tr>
<tr class='fileboard'>
</tr>
<tr><th>{% trans %}Max images per post{% endtrans %}</th><td><select name="max_images">{% for i in 1..5 %}<option value="{{ i }}" {% if config.max_images == i %} selected {% endif %}>{{ i }}</option>{% endfor %}</select></td></tr>
</table>
@ -99,9 +111,25 @@
<tr><td><input name="replace[]"></td><td><input name="with[]"></td></tr>
{% endif %}
</table>
<ul style="padding:0;text-align:center;list-style:none">
<li><input type="button" value="{% trans 'Add another wordfilter' %}" id="wf_add"></li>
</ul>
<table id="tags" class='fileboard'>
<th colspan="2">{% trans %}Tags{% endtrans %}</th>
<tr><th>{% trans %}ID{% endtrans %}</th><th>{% trans %}Description{% endtrans %}</th></tr>
{% if config.allowed_tags %}
{% for tag_id, tag_desc in config.allowed_tags %}
<tr><td><input name="tag_id[]" value="{{ tag_id|e }}"></td><td><input name="tag_desc[]" value="{{ tag_desc|e }}"></td></tr>
{% endfor %}
{% else %}
<tr><td><input name="tag_id[]"></td><td><input name="tag_desc[]"></td></tr>
{% endif %}
</table>
<ul style="padding:0;text-align:center;list-style:none">
<li class='fileboard'><input type="button" value="{% trans 'Add another tag' %}" id="tag_add"></li>
<li><input type="submit" value="{% trans 'Save changes' %}"></li>
{#
{% if mod|hasPermission(config.mod.deleteboard) %}
@ -110,4 +138,19 @@
</ul>
</form>
<script>$('#wf_add').on('click', function(){$('#wf').append('<tr><td><input name="replace[]"></td><td><input name="with[]"></td></tr>')});</script>
<script>
$('#wf_add').on('click', function() {
$('#wf').append('<tr><td><input name="replace[]"></td><td><input name="with[]"></td></tr>');
});
$('#tag_add').on('click', function() {
$('#tags').append('<tr><td><input name="tag_id[]"></td><td><input name="tag_desc[]"></td></tr>');
});
var update_fields;
$('#board_type').on('input', update_fields = function() {
$('.txtboard, .fileboard, .imgboard').hide();
$('.'+$('#board_type').val()).show();
});
update_fields();
</script>