2006-08-29 19:06:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
header('Content-type:text/html;charset=UTF-8');
|
|
|
|
|
|
|
|
?><!DOCTYPE html
|
2006-08-14 00:27:15 +00:00
|
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>HTMLPurifier Live Demo</title>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1>HTMLPurifier Live Demo</h1>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
set_include_path('../../library' . PATH_SEPARATOR . get_include_path());
|
|
|
|
require_once 'HTMLPurifier.php';
|
|
|
|
|
|
|
|
if (!empty($_POST['html'])) {
|
|
|
|
|
|
|
|
$html = get_magic_quotes_gpc() ? stripslashes($_POST['html']) : $_POST['html'];
|
|
|
|
|
2006-09-24 21:23:54 +00:00
|
|
|
$config = HTMLPurifier_Config::createDefault();
|
|
|
|
$config->set('Core', 'TidyFormat', !empty($_POST['tidy']));
|
|
|
|
$purifier = new HTMLPurifier($config);
|
2006-08-14 00:27:15 +00:00
|
|
|
$pure_html = $purifier->purify($html);
|
|
|
|
|
|
|
|
?>
|
|
|
|
<p>Here is your purified HTML:</p>
|
|
|
|
<div style="border:5px solid #CCC;margin:0 10%;padding:1em;">
|
|
|
|
<?php
|
|
|
|
|
|
|
|
echo $pure_html;
|
|
|
|
|
|
|
|
?>
|
|
|
|
<div style="clear:both;"></div>
|
|
|
|
</div>
|
|
|
|
<p>Here is the source code of the purified HTML:</p>
|
|
|
|
<pre><?php
|
|
|
|
|
2006-08-14 13:08:59 +00:00
|
|
|
echo htmlspecialchars($pure_html, ENT_COMPAT, 'UTF-8');
|
2006-08-14 00:27:15 +00:00
|
|
|
|
|
|
|
?></pre>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
?>
|
|
|
|
<p>Welcome to the live demo. Enter some HTML and see how HTMLPurifier
|
|
|
|
will filter it.</p>
|
|
|
|
<?php
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2006-08-15 15:33:24 +00:00
|
|
|
<form name="filter" action="demo.php<?php
|
|
|
|
if (isset($_GET['profile']) || isset($_GET['XDEBUG_PROFILE'])) {
|
|
|
|
echo '?XDEBUG_PROFILE=1';
|
|
|
|
} ?>" method="post">
|
2006-08-14 00:27:15 +00:00
|
|
|
<fieldset>
|
|
|
|
<legend>HTML</legend>
|
|
|
|
<textarea name="html" cols="60" rows="15"><?php
|
|
|
|
|
2006-08-21 00:48:43 +00:00
|
|
|
if (isset($html)) {
|
|
|
|
echo htmlspecialchars(
|
2006-08-29 19:36:40 +00:00
|
|
|
HTMLPurifier_Encoder::cleanUTF8($html), ENT_COMPAT, 'UTF-8');
|
2006-08-21 00:48:43 +00:00
|
|
|
}
|
2006-08-14 00:27:15 +00:00
|
|
|
?></textarea>
|
2006-09-24 21:23:54 +00:00
|
|
|
<div>Nicely format output with Tidy? <input type="checkbox" value="1"
|
|
|
|
name="tidy"<?php if (!empty($_POST['tidy'])) echo ' checked="checked"'; ?> /></div>
|
2006-08-14 00:27:15 +00:00
|
|
|
<div>
|
|
|
|
<input type="submit" value="Submit" name="submit" class="button" />
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
2006-08-17 01:41:32 +00:00
|
|
|
<p>Return to <a href="http://hp.jpsband.org/">HTMLPurifier's home page</a>.</p>
|
2006-08-14 00:27:15 +00:00
|
|
|
</body>
|
|
|
|
</html>
|