Changeset 25 for trunk/dnsbl/dnsbl.cgi
- Timestamp:
- 09/03/10 15:18:51 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dnsbl/dnsbl.cgi
r24 r25 24 24 print "Content-type: text/html\n\n"; 25 25 26 my $dbh = $dnsbl->connect; 26 # default DB info - all other settings should be loaded from the DB. 27 my $dbhost = "localhost"; 28 my $dbname = "dnsbl"; 29 my $dbuser = "dnsbl"; 30 my $dbpass = "spambgone"; 31 32 # Load a config ref containing DB host, name, user, and pass info based on 33 # from the server name + full script web path. This allows us to host 34 # multiple instances without having to duplicate the code. 35 # This file is a Perl fragment to be processed inline. 36 my $cfgname = $ENV{SERVER_NAME}.$ENV{SCRIPT_NAME}; 37 $cfgname =~ s|[./-]|_|g; 38 $cfgname =~ s|_dnsbl_cgi||; 39 if (-e "/etc/dnsbl/$cfgname.conf") { 40 my $cfg = `cat /etc/dnsbl/$cfgname.conf`; 41 ($cfg) = ($cfg =~ /^(.+)$/s); # avoid warnings, failures, and general nastiness with taint mode 42 eval $cfg; 43 } 44 45 my $dbh = $dnsbl->connect($dbhost, $dbname, $dbuser, $dbpass); 27 46 28 47 my $page; 29 my $templatedir = "templates"; 48 my $templatedir = $ENV{SCRIPT_FILENAME}; 49 $templatedir =~ s/dnsbl\.cgi//; 50 $templatedir .= "templates"; 51 $ENV{HTML_TEMPLATE_ROOT} = $templatedir; 52 53 my %config; 54 my $sth = $dbh->prepare("SELECT key,value FROM misc"); 55 $sth->execute; 56 while (my ($key,$value) = $sth->fetchrow_array) { 57 $config{$key} = $value; 58 } 30 59 31 60 # decide which page to spit out... 32 61 if (!$webvar{page}) { 33 $page = HTML::Template->new(filename => " $templatedir/index.tmpl");62 $page = HTML::Template->new(filename => "index.tmpl"); 34 63 } else { 35 $page = HTML::Template->new(filename => "$templatedir/$webvar{page}.tmpl"); 36 } 64 $page = HTML::Template->new(filename => "$webvar{page}.tmpl"); 65 } 66 67 $page->param(pgtitle => $config{pgtitle}) if defined($config{pgtitle}); 68 $page->param(pgcomment => $config{pgcomment}) if defined($config{pgcomment}); 37 69 38 70 if ($webvar{page} eq 'report') { … … 92 124 $page->param(browsebits => browse($dbh,$webvar{ip})); 93 125 } 126 94 127 print $page->output; 95 128
Note:
See TracChangeset
for help on using the changeset viewer.