Changeset 7 for trunk/dnsbl/dnsbl.cgi


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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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()
Note: See TracChangeset for help on using the changeset viewer.