From ba5075ebbd7611a5d539755a6402d825090a6bda Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 22 Feb 2011 11:09:43 +1100 Subject: [PATCH] Reject blank posts? (just whitespace, etc). --- inc/config.php | 4 +++- post.php | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/inc/config.php b/inc/config.php index d5999b0a..5bd8eb97 100644 --- a/inc/config.php +++ b/inc/config.php @@ -67,7 +67,9 @@ $config['flood_time_same'] = 30; // Do you need a body for your non-OP posts? $config['force_body'] = true; - + // Reject blank posts? (just whitespace, etc)? + $config['reject_blank'] = true; + // Max body length $config['max_body'] = 1800; diff --git a/post.php b/post.php index 23196c06..961d6fdc 100644 --- a/post.php +++ b/post.php @@ -209,11 +209,16 @@ $post['password'] = $_POST['password']; $post['filename'] = get_magic_quotes_gpc() ? stripslashes($_FILES['file']['name']) : $_FILES['file']['name']; $post['has_file'] = $OP || !empty($_FILES['file']['tmp_name']); - $post['mod'] = isset($_POST['mod']) && $_POST['mod']; - if(empty($post['body']) && $config['force_body']) + if($config['force_body'] && empty($post['body'])) error($config['error']['tooshort_body']); + if($config['reject_blank'] && !empty($post['body'])) { + $stripped_whitespace = preg_replace('/[\s]/u', '', $post['body']); + if(empty($stripped_whitespace)) + error($config['error']['tooshort_body']); + } + if($post['mod']) { require 'inc/mod.php'; if(!$mod) {