source: trunk/dnsbl/browse.cgi@ 7

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

/trunk/dnsbl

export-dnsbl

  • Spit out SOA and NS records for rbldns/cidr output, Just In Case

browse.cgi:

  • Show comments for listme(block) and listme(org) ratings

dnsbl.cgi

  • Show registrar-parent browse detail on IPs submitted for listing. Copied most of browse.cgi code into dnsbl.cgi - this should really be split out

templates/report.tmpl

  • Added space for browse list data, added reference to CSS for browse listings

templates/browse.tmpl

  • Split out CSS for browse formatting into separate file instead of inline <style> header tag

templates/dnsbl.css

  • CSS for browse data
  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 4.0 KB
Line 
1#!/usr/bin/perl
2# quickndirty browse-the-damned-by-web
3
4use strict;
5use warnings;
6use DBI;
7use CGI::Carp qw(fatalsToBrowser);
8use HTML::Template;
9
10use DNSBL;
11
12my $dnsbl = new DNSBL;
13
14my $dbh = $dnsbl->connect;
15
16print "Content-Type: text/html\n\n";
17
18my @lvl0 = ("foo", "bar", "bax");
19my $template = HTML::Template->new(filename => 'templates/browse.tmpl');
20
21my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments,o.comments ".
22 "FROM blocks b INNER JOIN orgs o ON b.orgid=o.orgid ".
23 "WHERE b.block <<= ";
24my $sth0 = $dbh->prepare($basesql."'0/0' AND b.level=0 ORDER BY block");
25#my $sth0 = $dbh->prepare($basesql."'76.73.0.0/17' AND b.level=0 ORDER BY block");
26my $sth1 = $dbh->prepare($basesql."? AND b.level=1 ORDER BY block");
27my $sth2 = $dbh->prepare($basesql."? AND b.level=2 ORDER BY block");
28my $sthiplist = $dbh->prepare("select * from iplist where ip <<= ? order by ip");
29
30print $template->output;
31
32my %ipseen;
33
34$sth0->execute;
35while (my ($block0,$org0,$listmeb0,$listmeo0,$bcomments0,$ocomments0) = $sth0->fetchrow_array) {
36 print "<div class=\"lvl0".($dnsbl->autolist_block($block0) ? ' auto0"' : '"').
37 "><span".($listmeb0 ? ' class=b0list' : '').">$block0".
38 ($listmeb0 ? " ($bcomments0)" : '')."</span> ".
39 "<span".($listmeo0 ? ' class=b0org' : '').">$org0".
40 ($listmeo0 ? " ($ocomments0)" : '')."</span>\n";
41 $sth1->execute($block0);
42 if ($sth1->rows > 0) {
43 while (my ($block1,$org1,$listmeb1,$listmeo1,$bcomments1,$ocomments1) = $sth1->fetchrow_array) {
44# lvl 1 div open
45 print " <div class=\"lvl1".($dnsbl->autolist_block($block1) ? ' auto1"' : '"').
46 "><span".($listmeb1 ? ' class=b1list' : '').">$block1".
47 ($listmeb1 ? " ($bcomments1)" : '')."</span> ".
48 "<span".($listmeo1 ? ' class=b1org' : '').">$org1".
49 ($listmeo1 ? " ($ocomments1)" : '')."</span>\n";
50 $sth2->execute($block1);
51 if ($sth2->rows > 0) {
52 while (my ($block2,$org2,$listmeb2,$listmeo2,$bcomments2,$ocomments2) = $sth2->fetchrow_array) {
53# lvl 2 div open
54 print " <div class=\"lvl2".($dnsbl->autolist_block($block2) ? ' auto2"' : '"').
55 "><span".($listmeb2 ? ' class=b2list' : '').">$block2".
56 ($listmeb2 ? " ($bcomments2)" : '')."</span> ".
57 "<span".($listmeo2 ? ' class=b2org' : '').">$org2".
58 ($listmeo2 ? " ($ocomments2)" : '')."</span>\n";
59 $sthiplist->execute($block2);
60 print " <div class=iplist>\n";
61 while (my @data4 = $sthiplist->fetchrow_array) {
62 print " $data4[0]<br>\n";
63 $ipseen{$data4[0]} = 1;
64 }
65 print " </div>\n";
66# lvl2 div close
67 print " </div>\n";
68 }
69 } else {
70 $sthiplist->execute($block1);
71 print " <div class=iplist>\n";
72 while (my @data4 = $sthiplist->fetchrow_array) {
73 print " $data4[0]<br>\n";
74 $ipseen{$data4[0]} = 1;
75 }
76 print " </div>\n";
77 }
78
79 my $sqlalt = "select ip from iplist where ip << ?";
80 my $sthalt = $dbh->prepare($sqlalt);
81 $sthalt->execute($block1);
82 my @newips;
83 while (my @data4 = $sthalt->fetchrow_array) {
84 push @newips, $data4[0] if !$ipseen{$data4[0]};
85 $ipseen{$data4[0]} = 1;
86 }
87 if ($#newips > -1) {
88 print " <div class=iplist>\n";
89 foreach (@newips) {
90 print " $_<br>\n";
91 }
92 print " </div>\n";
93 }
94# lvl 1 div close
95 print " </div>\n";
96 }
97 } else {
98 $sthiplist->execute($block0);
99 print " <div class=iplist>\n";
100 while (my @data4 = $sthiplist->fetchrow_array) {
101 print " $data4[0]<br>\n";
102 $ipseen{$data4[0]} = 1;
103 }
104 print " </div>\n";
105 }
106
107 my $sqlalt = "select ip from iplist where ip << ?";
108 my $sthalt = $dbh->prepare($sqlalt);
109 $sthalt->execute($block0);
110 my @newips;
111 while (my @data4 = $sthalt->fetchrow_array) {
112 push @newips, $data4[0] if (!$ipseen{$data4[0]});
113 }
114 if ($#newips > -1) {
115 print " <div class=iplist>\n";
116 foreach (@newips) {
117 print " $_<br>\n";
118 }
119 print " </div>\n";
120 }
121
122 print "</div>\n";
123}
Note: See TracBrowser for help on using the repository browser.