Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SpammerChk.pl 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #! /usr/bin/perl
  2. # This was taken from http://www.stopforumspam.com/forum/viewtopic.php?id=210
  3. #
  4. # ----------------------------------------------------------------------
  5. #
  6. # SpammerChk -- A PERL module for querying the StopForumSpam API
  7. # KEG -- 21 August 2008 -- Version 1.0.0
  8. #
  9. # Usage:
  10. # use SpammerChk;
  11. # $result = isSpammerIP(<IP address>);
  12. # $result = isSpammerEmail(<email address>);
  13. # $result = isSpammerUser(<username>);
  14. #
  15. # $result is either true or false
  16. #
  17. # Purpose:
  18. # This was written to allow dynamic checking of attempted YABB
  19. # Bulletin Board registrations against spammer reports in the
  20. # StopForumSpam database. The YABB software includes separate
  21. # sections for checking against the local ban lists for IP, email,
  22. # and username. This module was written to allow a final remote
  23. # check against reported spammers for each section.
  24. #
  25. # ----------------------------------------------------------------------
  26. package SpammerChk;
  27. require Exporter;
  28. @ISA = qw(Exporter);
  29. @EXPORT = qw(isSpammerIP isSpammerEmail isSpammerUser);
  30. use strict;
  31. use LWP::UserAgent;
  32. use XML::Simple;
  33. my $url = 'http://www.stopforumspam.com/api';
  34. sub isSpammerIP {
  35. my $ip = shift;
  36. return querySpammer($url . '?ip=' . $ip);
  37. }
  38. sub isSpammerUser {
  39. my $user = shift;
  40. return querySpammer($url . '?username=' . $user);
  41. }
  42. sub isSpammerEmail {
  43. my $address = shift;
  44. return querySpammer($url . '?email=' . $address);
  45. }
  46. sub querySpammer {
  47. my $reqURL = shift;
  48. my $response;
  49. my $ua = LWP::UserAgent->new;
  50. $ua->agent("SpammerChk/1.0.0");
  51. $ua->from('webmaster@fsfe.org');
  52. $ua->max_size(8192);
  53. $response = $ua->get($reqURL);
  54. if ($response->is_success) {
  55. my $xml = new XML::Simple;
  56. my $data = $xml->XMLin($response->content);
  57. return $data->{'appears'} eq 'yes';
  58. } else { return ""; }
  59. }
  60. 1; # ??