开发者

How to include HTMLPurifier on every page?

开发者 https://www.devze.com 2023-01-09 14:00 出处:网络
Okay right now I have too include the code below on every single page and every time I have too change the following piece of code every time I place it in a new web page. Is there a way I can include

Okay right now I have too include the code below on every single page and every time I have too change the following piece of code every time I place it in a new web page. Is there a way I can include all this code one time and have it affect every web page and have the code work like it should?

Here is the piece of code I have to change all the time.

require './htmlpurifier/library/HTMLPurifier.auto.php';

require '../htmlpurifier/library/HTMLPurifier.auto.php';

require '../../htmlpurifier/library/HTMLPurifier.auto.php';

require '../../../htmlpurifier/library/HTMLPurifier.auto.php';

Here is the code.

//HTML Purifier  
require './htmlpurifier/library/HTMLPurifier.auto.php';

$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
$config->set('HTML.Doctype', 'XHTML 1.0 Strict'); // replace with your doctype
$config->set('HTML.TidyLevel', 'heavy');
$config->set('HTML.SafeObject', true);
$config->set('HTML.SafeEmbed', true);
$purifier = new HTMLPurifi开发者_JAVA技巧er($config);
//End HTML Purifier


Prefix $_SERVER['DOCUMENT_ROOT'] to the path like this:

require $_SERVER['DOCUMENT_ROOT'] . 'htmlpurifier/library/HTMLPurifier.auto.php';

And you can use the same path from any page of your site.

0

精彩评论

暂无评论...
验证码 换一张
取 消