#! /usr/bin/perl -w
#
#   Copyright 1997 Webwork Solutions Inc.
#
#   Written by G. E. Terry
#


sub BEGIN {
    unshift @INC, '..';
  }

use Mysql;

# Variables

$host = "YourDomain.Com";
$database = "YourAuthDataBase";
$table = "YourAuthTable";

$timestampfield = "datestamp";

# Get current time and split it into it's parts.

        my $time = time;
        my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime ($time);

            if ($sec < 10){
                    $sec = "0$sec",
            }
            if ($min < 10){
                $min = "0$min"
            }
            if ($hour < 10){
                    $hour = "0$hour"
            }
            if ($mon < 10){
                    $mon = "0$mon"
            }
            if ($mday < 10){
                    $mday = "0$mday"
            }


# Connect to database

my $dbh = Mysql->Connect($host);
die "connect failed" unless $dbh;

# Select the authentication database

my $rv = $dbh->SelectDB ($database);
die "SelectDB failed" unless $rv;

my $sh =  $dbh->query ("delete from $table where $timestampfield <= 19$year$mon$mday$hour$min$sec");
die "query failed: ", $dbh->errmsg unless $sh;
undef $sh;

