Changeset 51 for trunk/dnsbl/browse.cgi


Ignore:
Timestamp:
12/09/14 17:11:39 (10 years ago)
Author:
Kris Deugau
Message:

/trunk/dnsbl

Update browse.cgi and dnsbl.cgi to display extended depth entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dnsbl/browse.cgi

    r40 r51  
    33##
    44# $Id$
    5 # Copyright 2009-2011 Kris Deugau <kdeugau@deepnet.cx>
     5# Copyright 2009-2011,2014 Kris Deugau <kdeugau@deepnet.cx>
    66#
    77#    This program is free software: you can redistribute it and/or modify
     
    2626
    2727use DNSBL;
     28use DNSBLweb;
    2829
    2930my $dnsbl = new DNSBL;
     
    6970$template->param(pgcomment => $config{pgcomment}) if defined($config{pgcomment});
    7071
    71 my $basesql = "SELECT b.block,o.orgname,b.listme,o.listme,b.comments,o.comments ".
    72         "FROM blocks b INNER JOIN orgs o ON b.orgid=o.orgid ".
    73         "WHERE b.parent = ";
    74 my $sth0 = $dbh->prepare($basesql."'0/0' AND b.level=0 ORDER BY block");
    75 #my $sth0 = $dbh->prepare($basesql."'64/8' AND b.level=0 ORDER BY block");
    76 my $sth1 = $dbh->prepare($basesql."? AND b.level=1 ORDER BY block");
    77 my $sth2 = $dbh->prepare($basesql."? AND b.level=2 ORDER BY block");
    78 my $sthiplist = $dbh->prepare("select * from iplist where parent = ? order by ip");
     72my $out = DNSBLweb::retlvl($dbh, $dnsbl, 0, block => '0/0');
    7973
    80 my %ipseen;
    81 
    82 my $out = '';
    83 
    84 $sth0->execute;
    85 while (my ($block0,$org0,$listmeb0,$listmeo0,$bcomments0,$ocomments0) = $sth0->fetchrow_array) {
    86   my $tmpl0 = new HTML::Template(filename => "browse-block.tmpl");
    87   $tmpl0->param(lvlclass => 'lvl0'.($dnsbl->autolist_block($block0) ? ' auto0' : ''));
    88   $tmpl0->param(netclass => ($listmeb0 ? 'b0list' : ''));
    89   $tmpl0->param(net => $block0);
    90   $tmpl0->param(orgclass => ($listmeo0 ? 'b0org' : ''));
    91   $tmpl0->param(org => $org0);
    92   $tmpl0->param(bcomment => $bcomments0) if $bcomments0;
    93   $tmpl0->param(ocomment => $ocomments0) if $ocomments0;
    94   $sth1->execute($block0);
    95   my $lvl1out = '';
    96   if ($sth1->rows > 0) {
    97     while (my ($block1,$org1,$listmeb1,$listmeo1,$bcomments1,$ocomments1) = $sth1->fetchrow_array) {
    98       my $tmpl1 = new HTML::Template(filename => "browse-block.tmpl");
    99       $tmpl1->param(lvlclass => 'lvl1'.($dnsbl->autolist_block($block1) ? ' auto1' : ''));
    100       $tmpl1->param(netclass => ($listmeb1 ? 'b1list' : ''));
    101       $tmpl1->param(net => $block1);
    102       $tmpl1->param(orgclass => ($listmeo1 ? 'b1org' : ''));
    103       $tmpl1->param(org => $org1);
    104       $tmpl1->param(bcomment => $bcomments1) if $bcomments1;
    105       $tmpl1->param(ocomment => $ocomments1) if $ocomments1;
    106       $tmpl1->param(indent => '  ');
    107       my $lvl2out = '';
    108       $sth2->execute($block1);
    109       if ($sth2->rows > 0) {
    110         while (my ($block2,$org2,$listmeb2,$listmeo2,$bcomments2,$ocomments2) = $sth2->fetchrow_array) {
    111           my $tmpl2 = new HTML::Template(filename => "browse-block.tmpl");
    112           $tmpl2->param(lvlclass => 'lvl2'.($dnsbl->autolist_block($block2) ? ' auto2' : ''));
    113           $tmpl2->param(netclass => ($listmeb2 ? 'b2list' : ''));
    114           $tmpl2->param(net => $block2);
    115           $tmpl2->param(orgclass => ($listmeo2 ? 'b2org' : ''));
    116           $tmpl2->param(org => $org2);
    117           $tmpl2->param(bcomment => $bcomments2) if $bcomments2;
    118           $tmpl2->param(ocomment => $ocomments2) if $ocomments2;
    119           $tmpl2->param(indent => '    ');
    120           $sthiplist->execute($block2);
    121           my @iprows;
    122           while (my @data4 = $sthiplist->fetchrow_array) {
    123             my %iprow;
    124             $iprow{ip} = $data4[0];
    125             $iprow{ipcount} = $data4[1];
    126             $iprow{indent} = '    ';
    127 #       ip        | count | s4list |             added
    128             push @iprows, \%iprow;
    129             $ipseen{$data4[0]} = 1;
    130           }
    131           $tmpl2->param(iplist => \@iprows);
    132           $lvl2out .= $tmpl2->output;
    133         }
    134       }
    135 
    136       $sthiplist->execute($block1);
    137       my @iprows;
    138       while (my @data4 = $sthiplist->fetchrow_array) {
    139         next if $ipseen{$data4[0]};
    140         my %iprow;
    141         $iprow{ip} = $data4[0];
    142         $iprow{ipcount} = $data4[1];
    143         $iprow{indent} = '  ';
    144 #       ip        | count | s4list |             added
    145         push @iprows, \%iprow;
    146         $ipseen{$data4[0]} = 1;
    147       }
    148       $tmpl1->param(iplist => \@iprows);
    149       $tmpl1->param(subs => $lvl2out);
    150       $lvl1out .= $tmpl1->output;
    151     }
    152   } # sth1->rows
    153   $sthiplist->execute($block0);
    154   my @iprows;
    155   while (my @data4 = $sthiplist->fetchrow_array) {
    156     next if $ipseen{$data4[0]};
    157     my %iprow;
    158     $iprow{ip} = $data4[0];
    159     $iprow{ipcount} = $data4[1];
    160     $iprow{indent} = '';
    161 #       ip        | count | s4list |             added
    162     push @iprows, \%iprow;
    163     $ipseen{$data4[0]} = 1;
    164   }
    165   $tmpl0->param(iplist => \@iprows);
    166   $tmpl0->param(subs => $lvl1out);
    167   $out .= $tmpl0->output;
    168 }
    169 
    170 # probably more efficient ways to do this somewhere...
    17174$template->param(enchilada => $out);
    17275print $template->output;
Note: See TracChangeset for help on using the changeset viewer.