code.fastix.org

Dateiansicht:

Datei:Projekte -> PHP:Spam-Erkennung für Mail- und Kontaktformulare -> test.php
md5:4f6760c7cbe4788a4633a275eee66fc3
sha1:55036fd52c6dbf73f165e35b9ecfa38b991a146f
Download-Link:Download
  1. <?php
  2. $startTime = microtime(true);
  3. # Test-Strings:
  4.  
  5. $a[] = 'gtlhmgbtujy, <a href = "http://www.fuclgkbbnh.com">iqjfunnsej</a> , [url = http://www.kvhpydjclx.com]tqgiacfovj[/url], http://www.bsgnbtiyhn.com iqjfunnsej, http://www.bsgnbtiyhn.com iqjfunnsej';
  6. $a[] = 'Kaufen Sie Vi@gr@!';
  7. $a[] = 'http://kkkk  http://gghjgh  http://liliul';
  8. $a[] = '<a href = "http://bigzgzgjzg">bigzgzgjzg</a>';
  9. $a[] = '&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;&#a01;';
  10.  
  11. # Exec!
  12.  
  13. require('./SpamDetector.php');                  #Step 1
  14. $spamdetector = new SpamDetector();      #Step 2
  15. ?><html>
  16. <head>
  17. <style>
  18. .test { padding:.5em; background-color:#f0f0f0;}
  19. .isSpam { padding:.5em; color:red; font-weight:bold;margin-bottom:1em;}
  20. .noSpam { padding:.5em; color:green; font-weight:bold;margin-bottom:1em;}
  21. </style>
  22. </head>
  23. <body>
  24. <?php
  25. foreach ( $a as $str) {
  26.         echo '<div class="test">' . htmlspecialchars( $str ) . '</div>';
  27.     if ( $spamdetector -> detect( $str ) ) {   #Step 3
  28.        echo '<div class="isSpam">Spam detected!</div>';
  29.     } else {
  30.         echo '<div class="noSpam">Spam NOT detected!</div>';
  31.     }
  32. }
  33. echo '<hr><div>(' . round ( ( microtime(true) - $startTime) * 1000, 2 ) . ' Millisekunden auf einem &quot;Scheckkartenrechner&quot; RasperryPi 4)</div>';
  34. ?>
  35. </body>
  36. </html>
  37.