How to include HTMLPurifier on each page?

Ok, now I also included the code below on each page, and every time I change the next piece of code too every time I put it on a new web page. Is there a way that I can include all this code once and affect it on every web page and how the code works?

Here is a piece of code that 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 HTMLPurifier($config);
//End HTML Purifier
+3
source share
1 answer

Prefix $_SERVER['DOCUMENT_ROOT']to the following path:

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

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

0
source

Source: https://habr.com/ru/post/1757531/


All Articles