diff --git a/inc/config.php b/inc/config.php index 454cae4f..43bd7f69 100644 --- a/inc/config.php +++ b/inc/config.php @@ -576,8 +576,14 @@ // Maximum numbers of threads that can be created every hour on a board. $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. $config['max_body'] = 1800; + // Minimum post body length. + $config['min_body'] = 0; // Maximum number of lines allowed in a post. $config['maximum_lines'] = 100; // Maximum number of post body lines to show on the index page. diff --git a/post.php b/post.php index 62b929d1..6d05594b 100644 --- a/post.php +++ b/post.php @@ -955,16 +955,36 @@ if (isset($_POST['delete'])) { if (!$dropped_post) { // Check string lengths - if (mb_strlen($post['name']) > 35) + if (mb_strlen($post['name']) > 35) { error(sprintf($config['error']['toolong'], 'name')); - if (mb_strlen($post['email']) > 40) + } + if (mb_strlen($post['email']) > 40) { error(sprintf($config['error']['toolong'], 'email')); - if (mb_strlen($post['subject']) > 100) + } + if (mb_strlen($post['subject']) > 100) { error(sprintf($config['error']['toolong'], 'subject')); - if (!$mod && mb_strlen($post['body']) > $config['max_body']) - error($config['error']['toolong_body']); - if (!$mod && substr_count($post['body'], "\n") >= $config['maximum_lines']) - error($config['error']['toomanylines']); + } + 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']); + } + + if (substr_count($post['body'], '\n') >= $config['maximum_lines']) { + error($config['error']['toomanylines']); + } + } } wordfilters($post['body']);