Welcome Guest ( Log In | Register)



2 Pages V  < 1 2  
Reply to this topicStart new topic
> Php And Disabling Html Tags, how can i do this?
Spectre
post 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.
Go to the top of the page
 
+Quote Post
iGuest
post 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

Go to the top of the page
 
+Quote Post

2 Pages V  < 1 2
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Html Frames(7)
  2. Html Font Tags In Php(11)
  3. Executing Scripts Without Include() Function(3)
  4. Best Php/html(2)
  5. Parsing .html Pages(9)
  6. Html Within Php Coding(11)
  7. Php And Asp.net Form(6)
  8. Finding Data In Meta Tags(0)
  9. Adapting Html Code Embed To Work On Phpnuke(7)
  10. Parsing Html As Php(7)
  11. Logging Dowload Files From Your Server Onto A Html File(1)
  12. [help]: Php To Html (static) Converter(3)
  13. A Script To Close All Bbcode Tags In Php(1)
  14. Help With Moving Html Form Results To Shopping Cart?(3)
  15. <?php ?> Marking Up With Php(0)
  1. Script To Translate Into Bbcode From Html Tags(1)
  2. Html Site With Login(2)
  3. Html Code Tester. Online Script(15)
  4. File Checker-how To Check File Whith Html Through Html?(2)
  5. How Do I Get The Result To "stick" And Add Html Tags?(14)
  6. Html Form!(4)
  7. Weird Formatting: Embedding Php Into Html(9)


 



- Lo-Fi Version Time is now: 22nd November 2008 - 03:14 PM