source: trunk/dnsbl/browse.cgi@ 51

Last change on this file since 51 was 51, checked in by Kris Deugau, 9 years ago

/trunk/dnsbl

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

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 2.4 KB
Line 
1#!/usr/bin/perl
2# quickndirty browse-the-damned-by-web
3##
4# $Id: browse.cgi 51 2014-12-09 22:11:39Z kdeugau $
5# Copyright 2009-2011,2014 Kris Deugau <kdeugau@deepnet.cx>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation, either version 3 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19##
20
21use strict;
22use warnings;
23use DBI;
24use CGI::Carp qw(fatalsToBrowser);
25use HTML::Template;
26
27use DNSBL;
28use DNSBLweb;
29
30my $dnsbl = new DNSBL;
31
32# default DB info - all other settings should be loaded from the DB.
33my $dbhost = "localhost";
34my $dbname = "dnsbl";
35my $dbuser = "dnsbl";
36my $dbpass = "spambgone";
37
38# Load a config ref containing DB host, name, user, and pass info based on
39# from the server name + full script web path. This allows us to host
40# multiple instances without having to duplicate the code.
41# This file is a Perl fragment to be processed inline.
42my $cfgname = $ENV{SERVER_NAME}.$ENV{SCRIPT_NAME};
43$cfgname =~ s|[./-]|_|g;
44$cfgname =~ s|_browse_cgi||;
45if (-e "/etc/dnsbl/$cfgname.conf") {
46 my $cfg = `cat /etc/dnsbl/$cfgname.conf`;
47 ($cfg) = ($cfg =~ /^(.+)$/s); # avoid warnings, failures, and general nastiness with taint mode
48 eval $cfg;
49}
50
51my $dbh = $dnsbl->connect($dbhost, $dbname, $dbuser, $dbpass);
52
53print "Content-Type: text/html\n\n";
54
55my $templatedir = $ENV{SCRIPT_FILENAME};
56$templatedir =~ s/browse\.cgi//;
57$templatedir .= "templates";
58$ENV{HTML_TEMPLATE_ROOT} = $templatedir;
59
60my %config;
61my $sth = $dbh->prepare("SELECT key,value FROM misc");
62$sth->execute;
63while (my ($key,$value) = $sth->fetchrow_array) {
64 $config{$key} = $value;
65}
66
67my $template = HTML::Template->new(filename => "browse.tmpl");
68
69$template->param(pgtitle => $config{pgtitle}) if defined($config{pgtitle});
70$template->param(pgcomment => $config{pgcomment}) if defined($config{pgcomment});
71
72my $out = DNSBLweb::retlvl($dbh, $dnsbl, 0, block => '0/0');
73
74$template->param(enchilada => $out);
75print $template->output;
Note: See TracBrowser for help on using the repository browser.