diff --git a/system/pages/forum/edit_post.php b/system/pages/forum/edit_post.php index d9364f65c7..6c00243143 100644 --- a/system/pages/forum/edit_post.php +++ b/system/pages/forum/edit_post.php @@ -36,24 +36,18 @@ $post_topic = stripslashes(trim($_REQUEST['topic'])); $smile = isset($_REQUEST['smile']) ? (int)$_REQUEST['smile'] : 0; $html = isset($_REQUEST['html']) ? (int)$_REQUEST['html'] : 0; - $lenght = 0; - for($i = 0; $i < strlen($post_topic); $i++) - { - if(ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126) - $lenght++; - } - if(($lenght < 1 || strlen($post_topic) > 60) && $thread['id'] == $thread['first_post']) - $errors[] = 'Too short or too long topic (short: '.$lenght.' long: '.strlen($post_topic).' letters). Minimum 1 letter, maximum 60 letters.'; - $lenght = 0; - for($i = 0; $i < strlen($text); $i++) - { - if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126) - $lenght++; - } - if($lenght < 1 || strlen($text) > 15000) - $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.'; + + $length = strlen($post_topic); + if(($length < 1 || $length > 60) && $thread['id'] == $thread['first_post']) + $errors[] = "Too short or too long topic (Length: $length letters). Minimum 1 letter, maximum 60 letters."; + + $length = strlen($text); + if($length < 1 || $length > 15000) + $errors[] = "Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters."; + if($char_id == 0) $errors[] = 'Please select a character.'; + if(empty($post_topic) && $thread['id'] == $thread['first_post']) $errors[] = 'Thread topic can\'t be empty.'; diff --git a/system/pages/forum/new_post.php b/system/pages/forum/new_post.php index 3da3e22b80..7437180b92 100644 --- a/system/pages/forum/new_post.php +++ b/system/pages/forum/new_post.php @@ -41,14 +41,10 @@ } elseif(isset($_REQUEST['save'])) { - $lenght = 0; - for($i = 0; $i < strlen($text); $i++) - { - if(ord($text[$i]) >= 33 && ord($text[$i]) <= 126) - $lenght++; - } - if($lenght < 1 || strlen($text) > 15000) - $errors[] = 'Too short or too long post (short: '.$lenght.' long: '.strlen($text).' letters). Minimum 1 letter, maximum 15000 letters.'; + $length = strlen($text); + if($length < 1 || strlen($text) > 15000) + $errors[] = 'Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters.'; + if($char_id == 0) $errors[] = 'Please select a character.'; diff --git a/system/pages/forum/new_thread.php b/system/pages/forum/new_thread.php index 10dc5c223f..c5e476b170 100644 --- a/system/pages/forum/new_thread.php +++ b/system/pages/forum/new_thread.php @@ -30,20 +30,13 @@ if (isset($_REQUEST['save'])) { $errors = array(); - $lenght = 0; - for ($i = 0; $i < strlen($post_topic); $i++) { - if (ord($post_topic[$i]) >= 33 && ord($post_topic[$i]) <= 126) - $lenght++; - } - if ($lenght < 1 || strlen($post_topic) > 60) - $errors[] = 'Too short or too long topic (short: ' . $lenght . ' long: ' . strlen($post_topic) . ' letters). Minimum 1 letter, maximum 60 letters.'; - $lenght = 0; - for ($i = 0; $i < strlen($text); $i++) { - if (ord($text[$i]) >= 33 && ord($text[$i]) <= 126) - $lenght++; - } - if ($lenght < 1 || strlen($text) > 15000) - $errors[] = 'Too short or too long post (short: ' . $lenght . ' long: ' . strlen($text) . ' letters). Minimum 1 letter, maximum 15000 letters.'; + $length = strlen($post_topic); + if ($length < 1 || $length > 60) + $errors[] = "Too short or too long topic (Length: $length letters). Minimum 1 letter, maximum 60 letters."; + + $length = strlen($text); + if ($length < 1 || $length > 15000) + $errors[] = "Too short or too long post (Length: $length letters). Minimum 1 letter, maximum 15000 letters."; if ($char_id == 0) $errors[] = 'Please select a character.';