allConfigForm.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. require_once 'common.php'; // load library
  3. require_once 'HTMLPurifier/Printer/ConfigForm.php';
  4. $config = HTMLPurifier_Config::loadArrayFromForm($_POST, 'config');
  5. // you can do custom configuration!
  6. if (file_exists('allConfigForm.settings.php')) {
  7. include 'allConfigForm.settings.php';
  8. }
  9. $gen_config = HTMLPurifier_Config::createDefault();
  10. $printer_config_form = new HTMLPurifier_Printer_ConfigForm(
  11. 'config',
  12. 'http://htmlpurifier.org/live/configdoc/plain.html#%s'
  13. );
  14. $purifier = new HTMLPurifier($config);
  15. $html = isset($_POST['html']) ? $_POST['html'] : "";
  16. $purified = $purifier->purify($html);
  17. echo '<?xml version="1.0" encoding="UTF-8" ?>';
  18. ?>
  19. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  20. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  21. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  22. <head>
  23. <title>HTML Purifier All Config Form smoketest</title>
  24. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  25. <style type="text/css">
  26. .hp-config {margin-left:auto; margin-right:auto;}
  27. .HTMLPurifier_Printer table {border-collapse:collapse;
  28. border:1px solid #000; width:600px;
  29. margin:1em auto;font-family:sans-serif;font-size:75%;}
  30. .HTMLPurifier_Printer td, .HTMLPurifier_Printer th {padding:3px;
  31. border:1px solid #000;background:#CCC; vertical-align: baseline;}
  32. .HTMLPurifier_Printer th {text-align:left;background:#CCF;width:20%;}
  33. .HTMLPurifier_Printer caption {font-size:1.5em; font-weight:bold;}
  34. .HTMLPurifier_Printer .heavy {background:#99C;text-align:center;}
  35. .HTMLPurifier_Printer .unsafe {background:#C99;}
  36. dt {font-weight:bold;}
  37. </style>
  38. <link rel="stylesheet" href="../library/HTMLPurifier/Printer/ConfigForm.css" type="text/css" />
  39. <script defer="defer" type="text/javascript" src="../library/HTMLPurifier/Printer/ConfigForm.js"></script>
  40. </head>
  41. <body>
  42. <h1>HTML Purifier All Config Form Smoketest</h1>
  43. <p>This prints config form for everything we support.</p>
  44. <form method="post" action="" name="hp-configform">
  45. <table style="width:100%">
  46. <tr><th>Input</th><th>Output</th>
  47. <tr><td style="width:50%">
  48. <textarea name="html" style="width:100%" rows="15"><?php echo htmlspecialchars($html) ?></textarea>
  49. </td><td style="width:50%">
  50. <textarea name="result" style="width:100%" rows="15"><?php echo htmlspecialchars($purified) ?></textarea>
  51. </td></tr>
  52. </table>
  53. <input type="submit" />
  54. <?php
  55. echo $printer_config_form->render($config);
  56. ?>
  57. </form>
  58. <pre><?php
  59. echo htmlspecialchars(var_export($config->getAll(), true));
  60. ?></pre>
  61. <?php
  62. // vim: et sw=4 sts=4