#!/usr/bin/perl # Feed IP or URI data into DNSBL database # 2009/05/26 kdeugau@deepnet.cx use strict; use warnings; use DBI; use DNSBL; my $DSN = "DBI:Pg:host=dbhost;dbname=dnsbl"; my $user = "dnsbl"; my $pass = "spambgone"; die "need input!\n" if !$ARGV[0]; ### want to NOT autocommit everything, it's unlikely we'll step on our own toes but... #my $dbh = DBI->connect($DSN, $user, $pass, { # AutoCommit => 0, # PrintError => 0 # }) # or die "database inaccessible: ".$DBI::errstr; my $dnsbl = new DNSBL; $dnsbl->connect; $dnsbl->report($ARGV[0]); #$dnsbl->dbclose(); exit 0; my $sth; #if ($ARGV[0] =~ /^[\d.]+$/) { # # weesa gonna ASS-U-ME IP addresses are sanely formatted. # $sth = $dbh->prepare("SELECT count FROM iplist WHERE ip=?"); # $sth->execute($ARGV[0]) or die "eep? ".$dbh->errstr."\n"; # my $rows = $sth->rows; # if ($rows == 0) { # $sth = $dbh->prepare("INSERT INTO iplist (ip) VALUES (?)"); # } elsif ($rows == 1) { # my ($cnt) = ($sth->fetchrow_array()); # $sth = $dbh->prepare("UPDATE iplist SET count=count+1 WHERE ip=?"); # } else { # die "die.die.die: db corrupt: found $rows matches on $ARGV[0]\n"; # } # $sth->execute($ARGV[0]); #} else { #} #$dbh->commit; #$dbh->disconnect;