Changeset 7


Ignore:
Timestamp:
09/22/09 14:49:44 (15 years ago)
Author:
Kris Deugau
Message:

/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
Location:
trunk/dnsbl
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/browse.cgi

    r3 r7  
    1919my $template = HTML::Template->new(filename => 'templates/browse.tmpl');
    2020
    21 my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments ".
     21my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments,o.comments ".
    2222        "FROM blocks b INNER JOIN orgs o ON b.orgid=o.orgid ".
    2323        "WHERE b.block <<= ";
     
    3333
    3434$sth0->execute;
    35 while (my ($block0,$org0,$listmeb0,$listmeo0,$comments0) = $sth0->fetchrow_array) {
     35while (my ($block0,$org0,$listmeb0,$listmeo0,$bcomments0,$ocomments0) = $sth0->fetchrow_array) {
    3636  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";
    3941  $sth1->execute($block0);
    4042  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) {
    4244# lvl 1 div open
    4345      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";
    4650      $sth2->execute($block1);
    4751      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) {
    4953# lvl 2 div open
    5054          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";
    5359          $sthiplist->execute($block2);
    5460          print "      <div class=iplist>\n";
  • trunk/dnsbl/dnsbl.cgi

    r5 r7  
    2121my $dnsbl = new DNSBL;
    2222
    23 $dnsbl->connect;
     23my $dbh = $dnsbl->connect;
    2424
    2525print "Content-type: text/html\n\n";
     
    3939  my $count = $dnsbl->ipexists($webvar{ip});
    4040  $page->param(nreports => $count) if $count;
     41  $page->param(browsebits => browse($dbh,$webvar{ip}));
    4142  for (my $i=0; $i<3; $i++) {
    4243    my ($block,$org) = $dnsbl->getcontainer($webvar{ip},$i);
     
    8485}
    8586print $page->output;
     87
     88exit 0;
     89
     90
     91
     92## extra subs.  should probably put this in a module somehow to share with browse.cgi
     93
     94sub 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  
    3030##fixme - mode should pick actual output, not just export mode
    3131if ($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
    3237  # more or less raw CIDR block-and-IP info.  rbldnsd format for convenience.
    3338  foreach (sort ipcmp keys %iplist) {
  • trunk/dnsbl/templates/browse.tmpl

    r2 r7  
    11<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" />
    823</head>
    834<body>
  • trunk/dnsbl/templates/report.tmpl

    r5 r7  
    22<head>
    33<title>adding <TMPL_VAR NAME=ip></title>
     4<link rel="stylesheet" type="text/css" href="templates/dnsbl.css" />
    45</head>
    56<body>
     7<table><tr><td valign=top>
    68<table border=1><tr><td>
    79<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>
     
    4446</form>
    4547</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
    4656</body>
    4757</html>
Note: See TracChangeset for help on using the changeset viewer.