Automate the Snipplr spambot protection


/ Published in: PHP
Save to your folder(s)

Honestly, this is supposed to be a programming site. What person who would be creating a bot for this site wouldn't be able to crack the spambot protection?

Here's my very ugly method of doing so.


Copy this code and paste it in your HTML
  1. <?
  2.  
  3. $q = "What does seven * eight equal?";
  4.  
  5.  
  6. $word_numbers = array("one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen");
  7. $numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
  8.  
  9. $q = str_ireplace($word_numbers, $numbers, $q);
  10.  
  11. $word_signs = array("plus", "minus", "times", "x", "divided");
  12. $signs = array("+", "-", "*", "*", "/");
  13.  
  14. $q = str_ireplace($word_signs, $signs, $q);
  15.  
  16. preg_match("!(\d{1,3}) ([^~]*?) (\d{1,3})!", $q, $out);
  17.  
  18. $first_number = $out[1];
  19. $second_number = $out[3];
  20.  
  21. switch($out[2]) {
  22. case '+' :
  23. $answer = $first_number+$second_number;
  24. break;
  25.  
  26. case '-' :
  27. $answer = $first_number-$second_number;
  28. break;
  29.  
  30. case '*' :
  31. $answer = $first_number*$second_number;
  32. break;
  33.  
  34. case '/' :
  35. $answer = $first_number/$second_number;
  36. break;
  37.  
  38. default :
  39. $answer = "Failed";
  40. break;
  41. }
  42.  
  43. echo $answer;
  44.  
  45. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.