mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-02 12:57:35 +01:00
Merge pull request #845 from Zankaria/post-body-length
Add min/max body length checks for OP only
This commit is contained in:
commit
7d989e43e6
@ -576,8 +576,14 @@
|
|||||||
|
|
||||||
// Maximum numbers of threads that can be created every hour on a board.
|
// Maximum numbers of threads that can be created every hour on a board.
|
||||||
$config['max_threads_per_hour'] = 30;
|
$config['max_threads_per_hour'] = 30;
|
||||||
|
// Maximum OP body length.
|
||||||
|
$config['max_body_op'] = 1800;
|
||||||
|
// Minimum OP body length. Ignored if force_body_op is set to false.
|
||||||
|
$config['min_body_op'] = 0;
|
||||||
// Maximum post body length.
|
// Maximum post body length.
|
||||||
$config['max_body'] = 1800;
|
$config['max_body'] = 1800;
|
||||||
|
// Minimum post body length.
|
||||||
|
$config['min_body'] = 0;
|
||||||
// Maximum number of lines allowed in a post.
|
// Maximum number of lines allowed in a post.
|
||||||
$config['maximum_lines'] = 100;
|
$config['maximum_lines'] = 100;
|
||||||
// Maximum number of post body lines to show on the index page.
|
// Maximum number of post body lines to show on the index page.
|
||||||
|
30
post.php
30
post.php
@ -955,17 +955,37 @@ if (isset($_POST['delete'])) {
|
|||||||
|
|
||||||
if (!$dropped_post) {
|
if (!$dropped_post) {
|
||||||
// Check string lengths
|
// Check string lengths
|
||||||
if (mb_strlen($post['name']) > 35)
|
if (mb_strlen($post['name']) > 35) {
|
||||||
error(sprintf($config['error']['toolong'], 'name'));
|
error(sprintf($config['error']['toolong'], 'name'));
|
||||||
if (mb_strlen($post['email']) > 40)
|
}
|
||||||
|
if (mb_strlen($post['email']) > 40) {
|
||||||
error(sprintf($config['error']['toolong'], 'email'));
|
error(sprintf($config['error']['toolong'], 'email'));
|
||||||
if (mb_strlen($post['subject']) > 100)
|
}
|
||||||
|
if (mb_strlen($post['subject']) > 100) {
|
||||||
error(sprintf($config['error']['toolong'], 'subject'));
|
error(sprintf($config['error']['toolong'], 'subject'));
|
||||||
if (!$mod && mb_strlen($post['body']) > $config['max_body'])
|
}
|
||||||
|
if (!$mod) {
|
||||||
|
$body_mb_len = mb_strlen($post['body']);
|
||||||
|
$is_op = $post['op'];
|
||||||
|
|
||||||
|
if (($is_op && $config['force_body_op']) || (!$is_op && $config['force_body'])) {
|
||||||
|
$min_body = $is_op ? $config['min_body_op'] : $config['min_body'];
|
||||||
|
|
||||||
|
if ($body_mb_len < $min_body) {
|
||||||
|
error($config['error']['tooshort_body']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$max_body = $is_op ? $config['max_body_op'] : $config['max_body'];
|
||||||
|
if ($body_mb_len > $max_body) {
|
||||||
error($config['error']['toolong_body']);
|
error($config['error']['toolong_body']);
|
||||||
if (!$mod && substr_count($post['body'], "\n") >= $config['maximum_lines'])
|
}
|
||||||
|
|
||||||
|
if (substr_count($post['body'], '\n') >= $config['maximum_lines']) {
|
||||||
error($config['error']['toomanylines']);
|
error($config['error']['toomanylines']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
wordfilters($post['body']);
|
wordfilters($post['body']);
|
||||||
|
|
||||||
$post['body'] = escape_markup_modifiers($post['body']);
|
$post['body'] = escape_markup_modifiers($post['body']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user