source: trunk/uribl/export-uridb@ 27

Last change on this file since 27 was 27, checked in by Kris Deugau, 14 years ago

/trunk/uribl

Add URI blacklist database interface code

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author Id
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2# Export URI blacklist data
3
4use strict;
5use warnings;
6use DBI;
7
8use URIdb;
9
10my $uridb = new URIdb;
11
12# default DB info - all other settings should be loaded from the DB.
13my $dbhost = "localhost";
14my $dbname = "uridb";
15my $dbuser = "uridb";
16my $dbpass = "spambgone";
17
18warn "Need DNS data type argument\n" if !$ARGV[0];
19my $mode = shift @ARGV || 'rbldnsd';
20
21# Load a config ref containing DB host, name, user, and pass info based on
22# from the server name + full script web path. This allows us to host
23# multiple instances without having to duplicate the code.
24# This file is a Perl fragment to be processed inline.
25if (-e "/etc/uridb/uridb.conf") {
26 my $cfg = `cat /etc/uridb/uridb.conf`;
27 ($cfg) = ($cfg =~ /^(.+)$/s); # avoid warnings, failures, and general nastiness with taint mode
28 eval $cfg;
29}
30
31my $dbh = $uridb->connect($dbhost, $dbname, $dbuser, $dbpass);
32
33my %config;
34my $sth = $dbh->prepare("SELECT key,value FROM misc");
35$sth->execute;
36while (my ($key,$value) = $sth->fetchrow_array) {
37 $config{$key} = $value;
38}
39
40print "\$SOA 900 ".($config{blzone} ? $config{blzone} : 'uri').".dnsbl systems.company.com 0 1200 600 600 900\n".
41 "\$NS 3600 127.0.0.1\n".
42 "\$TTL 900\n";
43
44$uridb->export($mode,*STDOUT);
Note: See TracBrowser for help on using the repository browser.