/** * Sanitizes a string, by encoding potentially malicious characters. * @param string, The string value to sanitize. * @param keephtml, Disables the HTML part of the sanitization (not reccomended). **/ public static function Sanitize($string, $flag, $keephtml = false) { if (Value::SetAndNotNull($flag)) { $string = filter_var($string, $flag); } else { if ($keephtml == false) { $string = htmlentities($string); } _string::EnforceProperLineEndings($string); } return $string; }
/** * Object representing a single element in HTML * @param string $tag The tag name of the element * @param HtmlAttributes $attributes The attributes of the element * @param string $content The content of the element * @param HtmlElement $child child (or children) to insert into the element **/ public function __construct($tag = EMPTYSTRING, $attributes = EMPTYSTRING, $content = EMPTYSTRING, $child = null) { if ($tag == 'comment' || $tag == '!--') { $this->_tag = '!--'; $this->_endtag = '--'; } else { $this->_tag = $tag; } if (is_a($attributes, 'HtmlAttributes')) { $this->_attributes = $attributes; } elseif (is_array($attributes)) { $this->_attributes = new HtmlAttributes($attributes); } else { $this->_attributes = new HtmlAttributes(); } $this->_content = _string::EnforceProperLineEndings($content); if ($child !== null) { if (!is_array($child)) { $this->AddChild($child); } else { foreach ($child as $c) { $this->AddChild($c); } } } }