source: trunk/dnsbl/dnsbl.cgi@ 2

Last change on this file since 2 was 2, checked in by Kris Deugau, 15 years ago

/trunk/dnsbl

Import work to date

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 2.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use CGI::Carp qw (fatalsToBrowser);
6use CGI::Simple;
7use HTML::Template;
8use DNSBL;
9
10# Set up the CGI object...
11my $q = new CGI::Simple;
12# ... and get query-string params as well as POST params if necessary
13$q->parse_query_string;
14
15my %webvar;
16# This is probably excessive fiddling, but it puts the parameters somewhere my fingers know about...
17foreach ($q->param()) {
18 $webvar{$_} = $q->param($_);
19}
20
21my $dnsbl = new DNSBL;
22
23$dnsbl->connect;
24
25print "Content-type: text/html\n\n";
26
27my $page;
28my $templatedir = "templates";
29
30# decide which page to spit out...
31if (!$webvar{page}) {
32 $page = HTML::Template->new(filename => "$templatedir/index.tmpl");
33} else {
34 $page = HTML::Template->new(filename => "$templatedir/$webvar{page}.tmpl");
35}
36
37if ($webvar{page} eq 'report') {
38 $page->param(ip => $webvar{ip});
39 for (my $i=0; $i<3; $i++) {
40 my ($block,$org) = $dnsbl->getcontainer($webvar{ip},$i);
41 if ($block) {
42 $page->param("block$i" => $block);
43 $page->param("org$i" => $org);
44 }
45 }
46} elsif ($webvar{page} eq 'dbreport') {
47 my $count = $dnsbl->report($webvar{ip});
48 my $org0id = $dnsbl->orgexists($webvar{org0});
49 if (!$org0id) {
50 $org0id = $dnsbl->addorg($webvar{org0});
51 $page->param(org0 => $webvar{org0});
52 }
53 if (!$dnsbl->blockexists($webvar{block0})) {
54 $dnsbl->addblock($webvar{block0}, $org0id, 0);
55 $page->param(block0 => $webvar{block0});
56 }
57# yes, this is grotty. PTHBTT!
58 if ($webvar{block1}) {
59 my $org1id = $dnsbl->orgexists($webvar{org1});
60 if (!$org1id) {
61 $org1id = $dnsbl->addorg($webvar{org1});
62 $page->param(org1 => $webvar{org1});
63 }
64 if (!$dnsbl->blockexists($webvar{block1})) {
65 $dnsbl->addblock($webvar{block1}, $org1id, 1);
66 $page->param(block1 => $webvar{block1});
67 }
68 if ($webvar{block2}) {
69 my $org2id = $dnsbl->orgexists($webvar{org2});
70 if (!$org2id) {
71 $org2id = $dnsbl->addorg($webvar{org2});
72 $page->param(org2 => $webvar{org2});
73 }
74 if (!$dnsbl->blockexists($webvar{block2})) {
75 $dnsbl->addblock($webvar{block2}, $org2id, 2);
76 $page->param(block2 => $webvar{block2});
77 }
78 }
79 }
80
81 $page->param(ip => $webvar{ip});
82}
83print $page->output;
Note: See TracBrowser for help on using the repository browser.