Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 10 revisions

[url=http://htmlpurifier.org/download]Download[/url] the distribution. Save in Application/helpers directory. Create file and name to htmlpurifier_helper.php

[h4]CREDITS:[/h4] [b]Author: [url=http://pinoytech.org/]Thorpe Obazee[/url] Updated for 2.0.x: Coccodrillo The original HTML Purifier package [url=http://htmlpurifier.org/]http://htmlpurifier.org/[/url][/b]

htmlpurifier_helper.php

[code] <?php if (!defined('BASEPATH')) exit('No direct script access allowed');

function purify($dirty_html) {

 if (is_array($dirty_html))
{
    foreach ($dirty_html as $key => $val)
    {
        $dirty_html[$key] = purify($val);
    }

    return $dirty_html;
}

if (trim($dirty_html) === '')
{
    return $dirty_html;
}

require_once(APPPATH."helpers/library/htmlpurifier/HTMLPurifier.auto.php"); 
require_once(APPPATH."helpers/library/htmlpurifier/HTMLPurifier.func.php");

$config = HTMLPurifier_Config::createDefault();

$config->set('HTML.Doctype', 'XHTML 1.0 Strict');

return HTMLPurifier($dirty_html, $config);

} ?> [/code] From the controller:

[code] <?php public function cleanmyhtml() { $this->load->helper('htmlpurifier'); $dirty_html = 'ds

test
'; $clean_html = purify($dirty_html); echo $clean_html; }

?> [/code]

Clone this wiki locally