XML_SaxFilters
[ class tree: XML_SaxFilters ] [ index: XML_SaxFilters ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. require_once('FormFilters.php');
  3. ?>
  4. <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
  5. <html>
  6. <head>
  7. <title> Form Filter Example </title>
  8. </head>
  9. <body>
  10. <h1>Form Filter Example</h1>
  11. <p>This example demonstrates how PEAR::XML_SaxFilters <i>might</i> be used with PEAR::XML_HTMLSax to filter form posts which are allowed to contain a limited subset of HTML. Note that this example is not checking the HTML submitted for well formedness but rather limiting the allowed tags to a limited subset and preventing the use of attributes for XSS.</p>
  12. <hr>
  13. <table>
  14. <tr valign="top">
  15. <td>
  16. Enter something below<br />
  17. <form action="<?php echo ($_SERVER['PHP_SELF'])?>" method="post">
  18. <textarea name="message" cols="40" rows="5"></textarea><br />
  19. <input type="submit" name="submit" value=" Post "><br />
  20. </form>
  21. </td>
  22. <td>
  23. <b>Allowed Tags</b>
  24. <ul>
  25. <li>&lt;a href="http://www.php.net"&gt;PHP&lt;/a&gt;</li>
  26. <li>&lt;b /&gt;, &lt;strong /&gt; = &lt;strong /&gt;</li>
  27. <li>&lt;i /&gt;, &lt;em /&gt; = &lt;em /&gt;</li>
  28. <li>&lt;br /&gt;</li>
  29. <li>&lt;p /&gt;</li>
  30. <li>&lt;code /&gt;</li>
  31. <li>&lt;blockquote /&gt;</li>
  32. <li>&lt;ul /&gt; &lt;ol /&gt;, &lt;li /&gt;</li>
  33. </ul>
  34. </td>
  35. </tr>
  36. </table>
  37. <hr>
  38. <h2>Output</h2>
  39. <?php
  40. if isset($_POST['submit']) ) {
  41.     $filteredText filterForm($_POST['message']);
  42. ?>
  43. <table width="450">
  44. <tr>
  45. <td>
  46. <?php echo $filteredText )?>
  47. </td>
  48. </tr>
  49. </table>
  50. <hr>
  51. <h2>Raw Output</h2>
  52. <code>
  53. <?php echo htmlspecialchars($filteredText) )?>
  54. </code>
  55. <?php
  56. }
  57. ?>
  58. </body>
  59. </html>

Documentation generated on Mon, 11 Mar 2019 10:15:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.