Author Topic: How to limit # of characters in comments?  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Offline Deven316

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
How to limit # of characters in comments?
« 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:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: How to limit # of characters in comments?
« Reply #1 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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)