]> git.donarmstrong.com Git - debbugs.git/blob - examples/debian/misc/bugspam.cgi
0e9416554fcceea9c766fe3430b600baa3b1f608
[debbugs.git] / examples / debian / misc / bugspam.cgi
1 #!/usr/bin/perl -wT
2
3 use strict;
4 use CGI qw(param remote_host);
5
6 sub quitcgi($) {
7     my $msg = shift;
8     print "Content-Type: text/html\n\n";
9     print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
10     print "An error occurred. Dammit.\n";
11     print "Error was: $msg.\n";
12     print "</BODY></HTML>\n";
13     exit 0;
14 }
15
16 my $bug = param('bug') or quitcgi('No bug specfied');
17 quitcgi('No valid bug number') unless $bug =~ /^\d{3,6}$/;
18 my $remote_host = remote_host or quitcgi("No remote host");
19 my $ok = param('ok');
20 if (not defined $ok) {
21    print "Content-Type: text/html\n\n";
22    print "<HTML><HEAD><TITLE>Verify submission</TITLE></HEAD><BODY>\n";
23    print "<H2>Verify report for bug $bug</H2>\n";
24    print qq(<A HREF="bugspam.cgi?bug=$bug;ok=ok">Yes, report that bug $bug has spam</A>\n);
25    print "</BODY></HTML>\n";
26    exit 0;
27 }
28 my $time = time();
29
30 if ($remote_host =~ /^(?:222\.145\.167\.130|222\.148\.27\.140|61\.192\.213\.69|59\.124\.205\.94|221\.191\.105\.116|87\.69\.80\.58|201\.215\.217\.26|201\.215\.217\.32|66\.63\.250\.28|124\.29\.15\.132|61\.192\.200\.111|58\.81\.190\.204|220\.150\.239\.110|59\.106\.128\.138|216\.170\.223\.41|87\.165\.200\.176|62\.4\.19\.137|122\.16\.111\.96|121\.94\.6\.159|190\.42\.8\.125|61\.192\.200\.130|82\.135\.92\.154|221\.115\.95\.197|222\.239\.79\.10(?:7|8)|210\.91\.8\.51|61\.192\.206\.109|61\.192\.203\.55|140\.123\.100\.(?:15|13)|193\.203\.240\.134)$/) {
31     print "Content-Type: text/html\n\n";
32     print "<HTML><HEAD><TITLE>Go Away</TITLE></HEAD><BODY>\n";
33     print "<h2>Report rejeted</h2>\n";
34     print "You have been abusing the BTS.  Please go away.  Contact owner\@bugs.debian.org if you can explain why you should be allowed to use the BTS.\n";
35     print "</BODY></HTML>\n";
36     exit 0;
37 }
38
39 open SPAMEDBUGS, '>>', '/org/bugs.debian.org/spammed/spammedbugs'
40     or quitcgi("opening spammedbugs: $!");
41 print SPAMEDBUGS "$bug\t$remote_host\t$time\n"
42     or quitcgi("writing spammedbugs: $!");
43 close SPAMEDBUGS;
44
45 print "Content-Type: text/html\n\n";
46 print "<HTML><HEAD><TITLE>Thanks</TITLE></HEAD><BODY>\n";
47 print "<h2>Report accepted</h2>\n";
48 print "Thank you for reporting that this bug log contains spam.  These reports\n";
49 print "are reviewed regularly and used to clean the bug logs and train the spam filters.\n";
50 print "</BODY></HTML>\n";
51 exit 0;