
Originally Posted by
selece28
[...] what if someone doing malicious things like posting 500 lines of random text, or posting one long string of text that makes horizontal scrolling necessary.
Is there any code to limit the lines?
Lines should always be delimited by carriage return, line feed pairs. You can use the substr_count function to count the number of times these pairs occur:
PHP Code:
$lines = substr_count($text, "\r\n") + 1;
You can use the wordwrap function to limit line lengths. If there are word breaks already present, the function will use them but if not it will force a break.
PHP Code:
$wrappedText = wordwrap($text, 80, "<br>\n", 1);
You should only need to take this step when displaying entries. Use the number of lines and the total entry length to determine whether to reject a post.
Read the PHP manual for more information about these functions. They're both listed under String functions.
I've put a limit to my textarea to 500char
If you haven't done so already, make sure you check that server-side.
Mike
Bookmarks