...

View Full Version : how to stop "nl2br abuse"



abcdefGARY
02-27-2008, 05:33 AM
I love the nl2br thingy for PHP on my site, which is a community site, for new lines. But is there any way to stop the abuse of using new lines?

for example:


hello



















goodbye

instead of


hello

goodbye

I've had a user go all the way to almost 3 pages of white space until I had to ban him myself... the only solution I've been able to think of is using a JS maxlength to limit the number of characters.

any more suggestions?

thanks

kbluhm
02-27-2008, 07:04 AM
Give this function a shot... use it in place of nl2br():


function nl2br_safe( $string )
{
$string = str_replace( array( "\r\n", "\r" ), "\n", $string );
$string = preg_replace( '/\n{3,}/', "\n\n", $string );
return nl2br( $string );
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum