Welcome! » Log In » Create A New Profile

Would this be suited for...

Posted by Justin 
Would this be suited for...
December 26, 2009 09:10PM


I have been looking into ways to overcome a problem I have with my website and wondered if I could ask you for some more details.

Basically I am coding a website in which I want to allow members of my site to post html/css so they can decorate their profile backgrounds, pages etc!

However I am aware that you can sanitise user input but am confused as to the allowing html, etc!

So by using this script would this ensure that the user input is made safe?

I would want to allow users to use things like etc but not necessarily tables and stuff. Thanks

Re: Would this be suited for...
December 26, 2009 09:15PM

Yup, HTML Purifier is great for this purpose.

Re: Would this be suited for...
December 31, 2009 05:03AM

Thanks for the reply.

I have tried to use this but cannot seem to get it to work.

I have tried using the basic.php document found on docs/examples.

What I want to do is allow a set of basic HTML tags such as the bold, italic, font, etc.

When I have inserted a HTML string into the $ html string in the basic.php file it prints out the html string exactly as it is. Surely this is meant to actually make the bold tags, etc work so the text shows as bold?

Ive read the documents but cannot seem to make head or tail of it!

Can anyone help me work out how to implement this into my site?

Would really really appreciate it.

Re: Would this be suited for...
December 31, 2009 04:54PM

Try playing with this snippet:

    require_once &#039;/path/to/htmlpurifier/library/HTMLPurifier.auto.php&#039;;

    $purifier = new HTMLPurifier();
    $clean_html = $purifier->purify($dirty_html);

replacing the path as necessary, and filling in some sample data for $dirty_html.

Sorry, you do not have permission to post/reply in this forum.