4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: Deven316 on December 26, 2005, 04:14:04 PM

Title: How to limit # of characters in comments?
Post by: Deven316 on December 26, 2005, 04:14:04 PM
How can I limit the # of characters for comments? Also is there anyway I can make it where if someone presses the enter key 50 times, there is a huge gap in their comments? It's very annoying and some people are so immature, especially on my website :roll:
Title: Re: How to limit # of characters in comments?
Post by: V@no on December 26, 2005, 08:06:15 PM
for the characters limit in details.php find:
Code: [Select]
    if ($comment_text == "")  {
      $msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
      $error = 1;
    }

insert below:
Code: [Select]
    if (strlen($comment_text) > 255)
    {
      $lang['comment_too_long'] = "Comment is too long";
      $msg .= (($msg != "") ? "<br />" : "").$lang['comment_too_long'];
      $error = 1;
    }
Replace 255 with the number you want. (you can move $lang['comment_too_long'] = "Comment is too long"; into lang/<your language>/main.php )

For the white spaces issue, you can try insert above the code I've mentioned this line:
Code: [Select]
    $comment_text = preg_replace("#(\s){5,}#m", "\\1", $comment_text);it will replace any repeated 5 times white spaces (space, newlines) with one white space.