/** * Purify it. Create an instance of HTMLPurifier if it does not exists. * * @param $text string the dirty HTML. * @returns string as the clean HTML. */ public static function Purify($text) { if (!self::$instance) { require_once __DIR__ . '/htmlpurifier-4.6.0-standalone/HTMLPurifier.standalone.php'; $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); self::$instance = new HTMLPurifier($config); } return self::$instance->purify($text); }
/** * Filter content according to a filter. * * @param $data string of text to filter and format according its filter settings. * @returns string with the filtered data. */ public static function Filter($data, $filter) { switch ($filter) { /* case 'php': $data = nl2br(makeClickable(eval('?>'.$data))); break; case 'html': $data = nl2br(makeClickable($data)); break;*/ case 'htmlpurify': $data = nl2br(CHTMLPurifier::Purify($data)); break; case 'bbcode': $data = nl2br(bbcode2html(htmlEnt($data))); break; case 'plain': default: $data = nl2br(makeClickable(htmlEnt($data))); break; } return $data; }