diff --git a/imgboard.php b/imgboard.php index d3d59f5..99bab4f 100644 --- a/imgboard.php +++ b/imgboard.php @@ -230,9 +230,11 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) if (!$loggedin) { checkCAPTCHA(TINYIB_CAPTCHA); checkBanned(); - checkMessageSize(); checkFlood(); } + if (!$rawpost) { + checkMessageSize(); + } $post = newPost(setParent()); $hide_fields = $post['parent'] == TINYIB_NEWTHREAD ? $tinyib_hidefieldsop : $tinyib_hidefields; @@ -250,12 +252,21 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) if ($rawpost || !in_array('name', $hide_fields)) { list($post['name'], $post['tripcode']) = nameAndTripcode($_POST['name']); $post['name'] = cleanString(substr($post['name'], 0, 75)); + if (!$rawpost && TINYIB_MAXNAME > 0) { + $post['name'] = substr($post['name'], 0, TINYIB_MAXNAME); + } } if ($rawpost || !in_array('email', $hide_fields)) { $post['email'] = cleanString(str_replace('"', '"', substr($_POST['email'], 0, 75))); + if (!$rawpost && TINYIB_MAXEMAIL > 0) { + $post['email'] = substr($post['email'], 0, TINYIB_MAXEMAIL); + } } if ($rawpost || !in_array('subject', $hide_fields)) { $post['subject'] = cleanString(substr($_POST['subject'], 0, 75)); + if (!$rawpost && TINYIB_MAXSUBJECT > 0) { + $post['subject'] = substr($post['subject'], 0, TINYIB_MAXSUBJECT); + } } if ($rawpost || !in_array('message', $hide_fields)) { $post['message'] = $_POST['message']; diff --git a/inc/defines.php b/inc/defines.php index 30a29c9..bbe4645 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -19,6 +19,18 @@ if (!defined('TINYIB_INDEX')) { if (!defined('TINYIB_MAXREPLIES')) { define('TINYIB_MAXREPLIES', 0); } +if (!defined('TINYIB_MAXNAME')) { + define('TINYIB_MAXNAME', 75); +} +if (!defined('TINYIB_MAXEMAIL')) { + define('TINYIB_MAXEMAIL', 320); +} +if (!defined('TINYIB_MAXSUBJECT')) { + define('TINYIB_MAXSUBJECT', 75); +} +if (!defined('TINYIB_MAXMESSAGE')) { + define('TINYIB_MAXMESSAGE', 8000); +} if (!defined('TINYIB_MAXWOP')) { define('TINYIB_MAXWOP', TINYIB_MAXW); } diff --git a/inc/functions.php b/inc/functions.php index 185e192..0bb911b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -307,8 +307,8 @@ function checkFlood() { } function checkMessageSize() { - if (strlen($_POST["message"]) > 8000) { - fancyDie(sprintf(__('Please shorten your message, or post it in multiple parts. Your message is %1$d characters long, and the maximum allowed is %2$d.'), strlen($_POST["message"]), 8000)); + if (TINYIB_MAXMESSAGE > 0 && strlen($_POST['message']) > TINYIB_MAXMESSAGE) { + fancyDie(sprintf(__('Please shorten your message, or post it in multiple parts. Your message is %1$d characters long, and the maximum allowed is %2$d.'), strlen($_POST['message']), TINYIB_MAXMESSAGE)); } } diff --git a/inc/html.php b/inc/html.php index f6b71ae..b98ea85 100644 --- a/inc/html.php +++ b/inc/html.php @@ -91,6 +91,23 @@ function buildPostForm($parent, $raw_post = false) { $form_extra = ''; $input_extra = ''; $rules_extra = ''; + + $maxlen_name = -1; + $maxlen_email = -1; + $maxlen_subject = -1; + $maxlen_message = -1; + if (TINYIB_MAXNAME > 0) { + $maxlen_name = TINYIB_MAXNAME; + } + if (TINYIB_MAXEMAIL > 0) { + $maxlen_email = TINYIB_MAXEMAIL; + } + if (TINYIB_MAXSUBJECT > 0) { + $maxlen_subject = TINYIB_MAXSUBJECT; + } + if (TINYIB_MAXMESSAGE > 0) { + $maxlen_message = TINYIB_MAXMESSAGE; + } if ($raw_post) { $txt_reply_to = __('Reply to'); $txt_new_thread = __('0 to start a new thread'); @@ -115,6 +132,11 @@ EOF;