diff --git a/inc/8chan-mod-pages.php b/inc/8chan-mod-pages.php index b46feeb7..3eb7de07 100644 --- a/inc/8chan-mod-pages.php +++ b/inc/8chan-mod-pages.php @@ -544,6 +544,17 @@ FLAGS; $reply_limit = 250; } + if (isset($_POST['max_newlines'])) { + $mn = (int)$_POST['max_newlines']; + if ($mn < 20 || $mn > 300) { + $max_newlines = 0; + } else { + $max_newlines = $mn; + } + } else { + $max_newlines = $mn; + } + if (!(strlen($title) < 40)) error('Invalid title'); if (!(strlen($subtitle) < 200)) @@ -587,6 +598,7 @@ FLAGS; \$config['hour_max_threads'] = $hour_max_threads; \$config['reply_limit'] = $reply_limit; \$config['max_pages'] = $max_pages; +\$config['max_newlines'] = $max_newlines; \$config['oekaki'] = $oekaki; $code_tags $katex $replace $multiimage $allow_flash $allow_pdf $user_flags if (\$config['disable_images']) diff --git a/inc/config.php b/inc/config.php index f08ce7bf..b8e7617d 100644 --- a/inc/config.php +++ b/inc/config.php @@ -473,6 +473,8 @@ // Maximum post body length. $config['max_body'] = 1800; + // Maximum number of newlines. (0 for unlimited) + $config['max_newlines'] = 0; // Maximum number of post body lines to show on the index page. $config['body_truncate'] = 15; // Maximum number of characters to show on the index page. diff --git a/post.php b/post.php index a1e04a91..0589e193 100644 --- a/post.php +++ b/post.php @@ -584,6 +584,14 @@ elseif (isset($_POST['post'])) { error(sprintf($config['error']['toolong'], 'password')); wordfilters($post['body']); + + if ($config['max_newlines'] > 0) { + preg_match_all("/\n/", $post['body'], $nlmatches); + + if (isset($nlmatches[0]) && sizeof($nlmatches[0]) > $config['max_newlines']) + error(sprintf(_('Your post contains too many lines. This board only allows %d maximum.'), $config['max_newlines'])); + } + $post['body'] = escape_markup_modifiers($post['body']); diff --git a/templates/mod/settings.html b/templates/mod/settings.html index 803d6971..04f6a7cd 100644 --- a/templates/mod/settings.html +++ b/templates/mod/settings.html @@ -52,6 +52,7 @@ {% trans %}Enable CAPTCHA for thread creation only{% endtrans %}
Users must solve a CAPTCHA in order to create new threads,
but do not have to solve a CAPTCHA in order to post replies.
{% 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 %}{% for i in range(20, 300) %}{% endfor %} {% 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 %}