Author: dom Date: 2011-06-03 12:33:14 +0100 (Fri, 03 Jun 2011) New Revision: 1293
Added: sites/cambridge.openguides.org/ sites/cambridge.openguides.org/lib/ sites/cambridge.openguides.org/lib/OpenGuides/ sites/cambridge.openguides.org/lib/OpenGuides/Local/ sites/cambridge.openguides.org/lib/OpenGuides/Local/CamGuideSpam.pm Log: import current cambridge spam catcher
Added: sites/cambridge.openguides.org/lib/OpenGuides/Local/CamGuideSpam.pm =================================================================== --- sites/cambridge.openguides.org/lib/OpenGuides/Local/CamGuideSpam.pm (rev 0) +++ sites/cambridge.openguides.org/lib/OpenGuides/Local/CamGuideSpam.pm 2011-06-03 11:33:14 UTC (rev 1293) @@ -0,0 +1,65 @@ +package OpenGuides::Local::CamGuideSpam; + +use strict; + +use Data::Dumper; +use MIME::Lite; + +sub looks_like_spam { + my ( $class, %args ) = @_; + + my $name = $args{node}; + my $content = $args{content}; + my $host = $args{host}; + my @cats = @{ $args{metadata}{category} || [] }; + my @locs = @{ $args{metadata}{locale} || [] }; + + if ( $name eq "Category Board Games" + && $content =~ m'http://.*http://.*http://%27is ) { + $class->notify_admins( %args, + reason => "Edit to board games page with more than two URLs in." ); + return 1; + } + + if ( $name eq "Station Tandoori" && $host eq "82.6.101.64" ) { + $class->notify_admins( %args, + reason => "82.6.101.64 editing Station Tandoori." ); + return 1; + } + + if ( $content =~ /\b(viagra|cialis|supermeganah|tramadol|vicodin|phentermine|zoloft|lolita)\b/is ) { + # $class->notify_admins( %args, reason => "Matches $1" ); + return 1; + } + + foreach my $cat ( @cats ) { + if ( $cat =~ m'http://%27i ) { + $class->notify_admins( %args, reason => "URL in category field" ); + return 1; + } + } + + foreach my $loc ( @locs ) { + if ( $loc =~ m'http://%27i ) { + $class->notify_admins( %args, reason => "URL in locales field" ); + return 1; + } + } +} + +sub notify_admins { + my ( $class, %args ) = @_; + my $reason = delete $args{reason}; + my $message = MIME::Lite->new( + From => 'kake@earth.li', + To => 'kake@earth.li', + Subject => "Attempted spam edit on OGCam", + Data => "Someone just tried to edit OGCam, and I said no because " + . "it looked like spam.\n\nReason: $reason\n\n" + . "Here's a dump of the details:\n" + . Dumper( %args ), + ); + $message->send; +} + +1;
openguides-commits@lists.openguides.org