views:

32

answers:

1

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 HTMLPurifier($config);
//End HTML Purifier
A: 

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.

Sarfraz