Author: Technocrat
(2011/08/26 16:25) 9 months ago
HTML support
12
13
class HTML extends interfaces\Type_Plugin {
14
/**
15
* Default setting for HTMLPurifier
16
*
17
* @var string
18
*/
19
private $_default = array(
20
'HTML' => array('TidyLevel' => 'heavy', 'Doctype' => 'XHTML 1.0 Transitional'),
21
'Core' => array('EscapeNonASCIICharacters' => true),
22
);
23
24
* Holds the HTML Purifier instance
25
26
* @var class
...
37
28
38
* Constructor
29
39
30
40
final protected function __construct() { }
31
final protected function __construct() {
32
if (($location = \piv\core\Config_Factory::getInstance()->htmlpurifier_location->get()) !== false) {
33
require $location.'HTMLPurifier.auto.php';
34
$purifier_config = \HTMLPurifier_Config::createDefault();
35
$config = \piv\core\Config_Factory::getInstance()->htmlpurifier_config->get();
36
foreach ($config as $category => $setting_array) {
foreach ($config[$category] as $setting => $value) {
$purifier_config->set($category.'.'.$setting, $value);
}
41
$this->_purifier = new \HTMLPurifier($purifier_config);
42
} else {
43
trigger_error('Could not load HTMLPurifier', E_USER_ERROR);
44
45
46
47
* Retrieves the singleton instance of this class.
48
57
62
58
63
59
public function convert($data) {
64
60
if (!($this->_purifier instanceof \HTMLPurifier)) {
61
$this->_purifier = new \HTMLPurifier($this->_default);
//If the data is an array
65
if (is_array($data)) {
66
//Purify it
67
1
<?php
2
$class = 'hidden';
3
$type = '';
4
if (!empty($_POST)) {
5
$time_start = microtime(true);
6
require dirname(dirname(__FILE__)).'/lib/phpInputValidator.php';
7
$value = $getvar->string(array('variable' => 'input_text', 'location' => 'POST', 'multibyte' => true));
$value = htmlentities($value, ENT_NOQUOTES, 'UTF-8');
$class = 'result';
} else if ($type == 'html') {
$getvar->config->htmlpurifier_location(dirname(dirname(__FILE__)).'/htmlpurifier');
$getvar->config->htmlpurifier_config(array(
));
$value = $getvar->html(array('variable' => 'input_textarea', 'location' => 'POST', 'multibyte' => true));
27
$value = $getvar->{$type}(array('variable' => 'input_text', 'location' => 'POST'));
77
<option value="ipv4">IP Address (IP v4)</option>
86
78
<option value="ipv6">IP Address (IP v6)</option>
87
79
<option value="hostname">Hostname</option>
88
89
<?php if (file_exists(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'type'.DIRECTORY_SEPARATOR.'html.php')) { ?>
90
<option value="html">String (html)</option>
91
<?php }?>
80
<option value="string">String (no html)</option>
92
81
<option value="hex">Hex</option>
93
82
<option value="hex_color">Hex Color</option>
94
class HTML extends interfaces\Type_Plugin {class HTML extends interfaces\Type_Plugin {* Default setting for HTMLPurifier** @var string*/private $_default = array('HTML' => array('TidyLevel' => 'heavy', 'Doctype' => 'XHTML 1.0 Transitional'),'Core' => array('EscapeNonASCIICharacters' => true),);/**final protected function __construct() { }final protected function __construct() {if (($location = \piv\core\Config_Factory::getInstance()->htmlpurifier_location->get()) !== false) {require $location.'HTMLPurifier.auto.php';$purifier_config = \HTMLPurifier_Config::createDefault();$config = \piv\core\Config_Factory::getInstance()->htmlpurifier_config->get();foreach ($config as $category => $setting_array) {foreach ($config[$category] as $setting => $value) {$purifier_config->set($category.'.'.$setting, $value);}}$this->_purifier = new \HTMLPurifier($purifier_config);} else {trigger_error('Could not load HTMLPurifier', E_USER_ERROR);}}public function convert($data) {public function convert($data) {if (!($this->_purifier instanceof \HTMLPurifier)) {$this->_purifier = new \HTMLPurifier($this->_default);}if (is_array($data)) {if (is_array($data)) {if (!empty($_POST)) {if (!empty($_POST)) {$value = $getvar->string(array('variable' => 'input_text', 'location' => 'POST', 'multibyte' => true));$value = $getvar->string(array('variable' => 'input_text', 'location' => 'POST', 'multibyte' => true));} else if ($type == 'html') {'HTML' => array('TidyLevel' => 'heavy', 'Doctype' => 'XHTML 1.0 Transitional'),'Core' => array('EscapeNonASCIICharacters' => true),$value = $getvar->html(array('variable' => 'input_textarea', 'location' => 'POST', 'multibyte' => true));} else {} else {$value = $getvar->{$type}(array('variable' => 'input_text', 'location' => 'POST'));$value = $getvar->{$type}(array('variable' => 'input_text', 'location' => 'POST'));<?php if (file_exists(dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.'type'.DIRECTORY_SEPARATOR.'html.php')) { ?>