|
|
|
|
![]() ![]() |
Jun 3 2006, 05:53 AM
Post
#11
|
|
|
Privileged Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 873 Joined: 30-July 04 Member No.: 246 |
I don't think he wants to remove HTML, as such, just make it so that it is displayed as plaintext rather than as HTML. As has already been mentioned, htmlentities() will do this for you by converting certain characters into their HTML entities (&[htmlentity]; which can either be a number of predefined entity titles, or the ASCII value of the character) - however, it's not a 100% surefire way to prevent injection. I don't know exactly how IPB sanitizes posts, but it is quite an extensive process.
Anyway, that's going off topic; back to the original problem. You could try something like: CODE $post = htmlentities($post); $post = str_replace("\r\n","\n",$post); $post = preg_replace('#([\n]+)#e', 'strlen("$1")>1?"<p />\n":"<br />\n";', $post); What that should do (it's untested and only theoretical) is replace all single instances of '\n' (new line character) with a '<br>' (line break), and all multiple instances with a '<p>' (paragraph). Strictly speaking, <p> tags should be closed, but it will result in the desired visual affect. Hope that helps. |
|
|
|
Oct 28 2008, 08:58 PM
Post
#12
|
|
|
Hail Caesar! ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 5,876 Joined: 21-September 07 Member No.: 50,369 |
Disabling HTML
Php And Disabling Html Tags What will be interesting is to make a php code which will pick the HTML from a bunch of codes I know how to pick a string, like here Http://www.Zortin.Com/scripts/show/?id=41 However, picking HTML from a bunch of text and disabling it is hard for me |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 22nd November 2008 - 03:14 PM |