Changeset 7
- Timestamp:
- 09/22/09 14:49:44 (15 years ago)
- Location:
- trunk/dnsbl
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dnsbl/browse.cgi
r3 r7 19 19 my $template = HTML::Template->new(filename => 'templates/browse.tmpl'); 20 20 21 my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments ".21 my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments,o.comments ". 22 22 "FROM blocks b INNER JOIN orgs o ON b.orgid=o.orgid ". 23 23 "WHERE b.block <<= "; … … 33 33 34 34 $sth0->execute; 35 while (my ($block0,$org0,$listmeb0,$listmeo0,$ comments0) = $sth0->fetchrow_array) {35 while (my ($block0,$org0,$listmeb0,$listmeo0,$bcomments0,$ocomments0) = $sth0->fetchrow_array) { 36 36 print "<div class=\"lvl0".($dnsbl->autolist_block($block0) ? ' auto0"' : '"'). 37 "><span".($listmeb0 ? ' class=b0list' : '').">$block0</span> ". 38 "<span".($listmeo0 ? ' class=b0org' : '').">$org0</span>\n"; 37 "><span".($listmeb0 ? ' class=b0list' : '').">$block0". 38 ($listmeb0 ? " ($bcomments0)" : '')."</span> ". 39 "<span".($listmeo0 ? ' class=b0org' : '').">$org0". 40 ($listmeo0 ? " ($ocomments0)" : '')."</span>\n"; 39 41 $sth1->execute($block0); 40 42 if ($sth1->rows > 0) { 41 while (my ($block1,$org1,$listmeb1,$listmeo1,$ comments1) = $sth1->fetchrow_array) {43 while (my ($block1,$org1,$listmeb1,$listmeo1,$bcomments1,$ocomments1) = $sth1->fetchrow_array) { 42 44 # lvl 1 div open 43 45 print " <div class=\"lvl1".($dnsbl->autolist_block($block1) ? ' auto1"' : '"'). 44 "><span".($listmeb1 ? ' class=b1list' : '').">$block1</span> ". 45 "<span".($listmeo1 ? ' class=b1org' : '').">$org1</span>\n"; 46 "><span".($listmeb1 ? ' class=b1list' : '').">$block1". 47 ($listmeb1 ? " ($bcomments1)" : '')."</span> ". 48 "<span".($listmeo1 ? ' class=b1org' : '').">$org1". 49 ($listmeo1 ? " ($ocomments1)" : '')."</span>\n"; 46 50 $sth2->execute($block1); 47 51 if ($sth2->rows > 0) { 48 while (my ($block2,$org2,$listmeb2,$listmeo2,$ comments2) = $sth2->fetchrow_array) {52 while (my ($block2,$org2,$listmeb2,$listmeo2,$bcomments2,$ocomments2) = $sth2->fetchrow_array) { 49 53 # lvl 2 div open 50 54 print " <div class=\"lvl2".($dnsbl->autolist_block($block2) ? ' auto2"' : '"'). 51 "><span".($listmeb2 ? ' class=b2list' : '').">$block2</span> ". 52 "<span".($listmeo2 ? ' class=b2org' : '').">$org2</span>\n"; 55 "><span".($listmeb2 ? ' class=b2list' : '').">$block2". 56 ($listmeb2 ? " ($bcomments2)" : '')."</span> ". 57 "<span".($listmeo2 ? ' class=b2org' : '').">$org2". 58 ($listmeo2 ? " ($ocomments2)" : '')."</span>\n"; 53 59 $sthiplist->execute($block2); 54 60 print " <div class=iplist>\n"; -
trunk/dnsbl/dnsbl.cgi
r5 r7 21 21 my $dnsbl = new DNSBL; 22 22 23 $dnsbl->connect;23 my $dbh = $dnsbl->connect; 24 24 25 25 print "Content-type: text/html\n\n"; … … 39 39 my $count = $dnsbl->ipexists($webvar{ip}); 40 40 $page->param(nreports => $count) if $count; 41 $page->param(browsebits => browse($dbh,$webvar{ip})); 41 42 for (my $i=0; $i<3; $i++) { 42 43 my ($block,$org) = $dnsbl->getcontainer($webvar{ip},$i); … … 84 85 } 85 86 print $page->output; 87 88 exit 0; 89 90 91 92 ## extra subs. should probably put this in a module somehow to share with browse.cgi 93 94 sub browse { 95 my $dbh = shift; 96 my $ip = shift; 97 98 my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments,o.comments ". 99 "FROM blocks b INNER JOIN orgs o ON b.orgid=o.orgid ". 100 "WHERE b.block "; 101 102 my $sth0 = $dbh->prepare($basesql." >> ? AND b.level=0 ORDER BY block"); 103 my $sth1 = $dbh->prepare($basesql." <<= ? AND b.level=1 ORDER BY block"); 104 my $sth2 = $dbh->prepare($basesql." <<= ? AND b.level=2 ORDER BY block"); 105 my $sthiplist = $dbh->prepare("select * from iplist where ip <<= ? order by ip"); 106 107 my %ipseen; 108 my $out = ''; 109 110 $sth0->execute($ip); 111 while (my ($block0,$org0,$listmeb0,$listmeo0,$bcomments0,$ocomments0) = $sth0->fetchrow_array) { 112 $out .= "<div class=\"lvl0".($dnsbl->autolist_block($block0) ? ' auto0"' : '"'). 113 "><span".($listmeb0 ? ' class=b0list' : '').">$block0". 114 ($listmeb0 ? " ($bcomments0)" : '')."</span> ". 115 "<span".($listmeo0 ? ' class=b0org' : '').">$org0". 116 ($listmeo0 ? " ($ocomments0)" : '')."</span>\n"; 117 $sth1->execute($block0); 118 if ($sth1->rows > 0) { 119 while (my ($block1,$org1,$listmeb1,$listmeo1,$bcomments1,$ocomments1) = $sth1->fetchrow_array) { 120 # lvl 1 div open 121 $out .= " <div class=\"lvl1".($dnsbl->autolist_block($block1) ? ' auto1"' : '"'). 122 "><span".($listmeb1 ? ' class=b1list' : '').">$block1". 123 ($listmeb1 ? " ($bcomments1)" : '')."</span> ". 124 "<span".($listmeo1 ? ' class=b1org' : '').">$org1". 125 ($listmeo1 ? " ($ocomments1)" : '')."</span>\n"; 126 $sth2->execute($block1); 127 if ($sth2->rows > 0) { 128 while (my ($block2,$org2,$listmeb2,$listmeo2,$bcomments2,$ocomments2) = $sth2->fetchrow_array) { 129 # lvl 2 div open 130 $out .= " <div class=\"lvl2".($dnsbl->autolist_block($block2) ? ' auto2"' : '"'). 131 "><span".($listmeb2 ? ' class=b2list' : '').">$block2". 132 ($listmeb2 ? " ($bcomments2)" : '')."</span> ". 133 "<span".($listmeo2 ? ' class=b2org' : '').">$org2". 134 ($listmeo2 ? " ($ocomments2)" : '')."</span>\n"; 135 $sthiplist->execute($block2); 136 $out .= " <div class=iplist>\n"; 137 while (my @data4 = $sthiplist->fetchrow_array) { 138 $out .= " $data4[0]<br>\n"; 139 $ipseen{$data4[0]} = 1; 140 } 141 $out .= " </div>\n"; 142 # lvl2 div close 143 $out .= " </div>\n"; 144 } 145 } else { 146 $sthiplist->execute($block1); 147 $out .= " <div class=iplist>\n"; 148 while (my @data4 = $sthiplist->fetchrow_array) { 149 $out .= " $data4[0]<br>\n"; 150 $ipseen{$data4[0]} = 1; 151 } 152 $out .= " </div>\n"; 153 } 154 155 my $sqlalt = "select ip from iplist where ip << ?"; 156 my $sthalt = $dbh->prepare($sqlalt); 157 $sthalt->execute($block1); 158 my @newips; 159 while (my @data4 = $sthalt->fetchrow_array) { 160 push @newips, $data4[0] if !$ipseen{$data4[0]}; 161 $ipseen{$data4[0]} = 1; 162 } 163 if ($#newips > -1) { 164 $out .= " <div class=iplist>\n"; 165 foreach (@newips) { 166 $out .= " $_<br>\n"; 167 } 168 $out .= " </div>\n"; 169 } 170 # lvl 1 div close 171 $out .= " </div>\n"; 172 } 173 } else { 174 $sthiplist->execute($block0); 175 $out .= " <div class=iplist>\n"; 176 while (my @data4 = $sthiplist->fetchrow_array) { 177 $out .= " $data4[0]<br>\n"; 178 $ipseen{$data4[0]} = 1; 179 } 180 $out .= " </div>\n"; 181 } 182 183 my $sqlalt = "select ip from iplist where ip << ?"; 184 my $sthalt = $dbh->prepare($sqlalt); 185 $sthalt->execute($block0); 186 my @newips; 187 while (my @data4 = $sthalt->fetchrow_array) { 188 push @newips, $data4[0] if (!$ipseen{$data4[0]}); 189 } 190 if ($#newips > -1) { 191 $out .= " <div class=iplist>\n"; 192 foreach (@newips) { 193 $out .= " $_<br>\n"; 194 } 195 $out .= " </div>\n"; 196 } 197 198 $out .= "</div>\n"; 199 } 200 201 return $out; 202 } # end browse() -
trunk/dnsbl/export-dnsbl
r6 r7 30 30 ##fixme - mode should pick actual output, not just export mode 31 31 if ($mode eq 'cidr') { 32 # SOA, NS records. Maybe dnscache needs them? 33 print "\$SOA 900 company.dnsbl systems.company.com 0 1200 600 600 900\n". 34 "\$NS 3600 127.0.0.1\n". 35 "\$TTL 900\n"; 36 32 37 # more or less raw CIDR block-and-IP info. rbldnsd format for convenience. 33 38 foreach (sort ipcmp keys %iplist) { -
trunk/dnsbl/templates/browse.tmpl
r2 r7 1 1 <html><head><title>show all IPs and listing status</title> 2 <style> 3 <!-- 4 .lvl0 { 5 background: #99ff99; 6 border: 1px solid #000000; 7 margin: 2px; 8 padding: 2px; 9 width: 600px; 10 } 11 .auto0 { 12 background: #ffffcc; 13 } 14 .b0list { 15 background: #ffcc99; 16 border: 1px solid #000000; 17 margin: 1px; 18 } 19 .b0org { 20 background: #ffcccc; 21 border: 1px solid #000000; 22 margin: 1px; 23 } 24 .lvl1 { 25 background: #33ff33; 26 border: 1px solid #000000; 27 margin: 2px; 28 padding: 2px; 29 position: relative; 30 left: 150px; 31 top: 0px; 32 width: 450px; 33 } 34 .auto1 { 35 background: #ffff00; 36 } 37 .b1list { 38 background: #ff9900; 39 border: 1px solid #000000; 40 margin: 1px; 41 } 42 .b1org { 43 background: #ff0000; 44 border: 1px solid #000000; 45 margin: 1px; 46 } 47 .lvl2 { 48 background: #009900; 49 border: 1px solid #000000; 50 margin: 2px; 51 padding: 2px; 52 position: relative; 53 left: 150px; 54 top: 0px; 55 width: 300px; 56 } 57 .auto2 { 58 background: #999900; 59 } 60 .b2list { 61 background: #cc6600; 62 border: 1px solid #000000; 63 margin: 1px; 64 } 65 .b2org { 66 background: #990000; 67 border: 1px solid #000000; 68 margin: 1px; 69 } 70 .iplist { 71 background: #00ffff; 72 border: 1px solid #000000; 73 margin: 2px; 74 padding: 2px; 75 position: relative; 76 left: 150px; 77 top: 0px; 78 width: 150px; 79 } 80 --> 81 </style> 2 <link rel="stylesheet" type="text/css" href="templates/dnsbl.css" /> 82 3 </head> 83 4 <body> -
trunk/dnsbl/templates/report.tmpl
r5 r7 2 2 <head> 3 3 <title>adding <TMPL_VAR NAME=ip></title> 4 <link rel="stylesheet" type="text/css" href="templates/dnsbl.css" /> 4 5 </head> 5 6 <body> 7 <table><tr><td valign=top> 6 8 <table border=1><tr><td> 7 9 <TMPL_VAR NAME=ip><TMPL_IF NAME=nreports></td><td>(reported <TMPL_VAR NAME=nreports> time(s)) <a href="/">Back</a></TMPL_IF></td></tr> … … 44 46 </form> 45 47 </table> 48 </td> 49 <TMPL_IF NAME=browsebits> 50 <td valign=top> 51 <TMPL_VAR NAME=browsebits> 52 </td> 53 </TMPL_IF> 54 </tr></table> 55 46 56 </body> 47 57 </html>
Note:
See TracChangeset
for help on using the changeset viewer.