aboutsummaryrefslogtreecommitdiffstats
path: root/lib/htmlpurifier/smoketests/basic.php
blob: 1c361727c9151ebed65402f894d872e9bd59f7b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

require_once 'common.php';

// todo : modularize the HTML in to separate files

$allowed = array(
    'allElements' => true,
    'legacy' => true
);

$page = isset($_GET['p']) ? $_GET['p'] : false;
if (!isset($allowed[$page])) $page = false;

$strict = isset($_GET['d']) ? (bool) $_GET['d'] : false;

echo '<?xml version="1.0" encoding="UTF-8" ?>';
?>
<?php if ($strict) { ?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1- Strict.dtd">
<?php } else { ?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
<?php } ?>
<html>
<head>
    <title>HTML Purifier Basic Smoketest</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php
    if ($page) {
        if (file_exists("basic/$page.css")) {
            ?><link rel="stylesheet" href="basic/<?php echo $page ?>.css" type="text/css" /><?php
        }
    }
?>
</head>
<body>
<?php

if ($page) {
?>
<div style="float:right;"><div><?php echo $strict ? 'Strict' : 'Loose'; ?>:
<a href="?d=<?php echo (int) !$strict; ?>&amp;p=<?php echo $page ?>">Swap</a></div>
<a href="http://validator.w3.org/check?uri=referer"><img
        src="http://www.w3.org/Icons/valid-xhtml10"
        alt="Valid XHTML 1.0 Transitional" height="31" width="88" style="border:0;" /></a>
</div>
<?php
    $config = HTMLPurifier_Config::createDefault();
    $config->set('Attr.EnableID', true);
    $config->set('HTML.Strict', $strict);
    $purifier = new HTMLPurifier($config);
    echo $purifier->purify(file_get_contents("basic/$page.html"));
} else {
    ?>
    <h1>HTML Purifier Basic Smoketest Index</h1>
    <ul>
    <?php
    foreach ($allowed as $val => $b) {
        ?><li><a href="?p=<?php echo $val ?>"><?php echo $val ?></a></li><?php
    }
    ?></ul><?php
}

?>
</body>
</html>
<?php

// vim: et sw=4 sts=4