-sub Add2Blacklist($$$) {
- # Add2Blacklist will add an entry to the blacklist
- my ($sender, $userid, $comment) = @_;
+# Insternal routines
+sub _cleanTables($$;$) {
+ my ($table, $timestamp, $dryrun) = @_;
+
+ my $condition = "userid = '$userid' and timestamp < '$timestamp'";
+
+ if ($dryrun) {
+ return $db->count($table, $condition);
+ } else {
+ my ($count, $msg) = $db->delete($table, $condition);
+
+ return $count;
+ } # if
+} # _cleanTables
+
+sub _retention2Days($) {
+ my ($retention) = @_;
+
+ # Of the retnetion periods I'm thinking of where they are <n> and then
+ # something like (days|weeks|months|years) none are tricky except for months
+ # because months, unlike (days|weeks|years) are ill-defined. Are there 28, 29
+ # 30 or 31 days in a month? Days are simple <n> days. Weeks are simple <n> * 7
+ # days. Years are simple - just change the year (a little oddity of 365 or
+ # 366) days this year? To keep things simple, we will ignore the oddities of
+ # leap years and just use 30 for number of days in month. We really don't need
+ # to be that accurate here...
+ #
+ # BTW we aren't checking for odd things like 34320 weeks or 5000 years...
+ if ($retention =~ /(\d+)\s+(day|days)/) {
+ return $1;
+ } elsif ($retention =~ /(\d+)\s+(week|weeks)/){
+ return $1 * 7;
+ } elsif ($retention =~ /(\d+)\s+(month|months)/) {
+ return $1 * 30;
+ } elsif ($retention =~ /(\d+)\s+(year|years)/) {
+ return $1 * 365;
+ } # if
+} # _retention2Days
+
+sub _getnext() {
+ return $db->getnext;
+} # _getnext