#!/usr/local/bin/perl
#
# Hunnypot: Copyright 2004 Jeremy Kister
# Released under Perl's Artistic License.
# Function: delete records from the honey pot older than 48 hours
# Author: Jeremy Kister (hunnypot-devel @t jeremykister.com) 
#

use strict;
use DBI;

my $dbun = 'dbun';
my $dbpw = 'dbpw';
my $driver = 'mysql';
my $dsn = "DBI:${driver}:";
my $dbserver = 'mysql.example.net';
my $dbname = 'dbname';

if($driver =~ /Sybase/){
   $dsn .= "server=$dbserver";
}else{
   $dsn .= "host=${dbserver};database=${dbname}";
}

my $old = ($^T - 172800);
my $dbh = DBI->connect($dsn, $dbun, $dbpw, {RaiseError => 1});
my $sql = 'DELETE FROM hunnypot WHERE timestamp < ' . $old;
my $sth = $dbh->prepare($sql);
$sth->execute;
$sth->finish;
$dbh->disconnect;
