With the AutoDelete Mod there is an option #4:
Autodelete those users with the "Guest" status.
Perhaps this can be adapted to work for what you need.
--------------------
AUTODELETE RECORDS
Autodelete those users with the "Guest" status.
This mod will allow you to autodelete records in your database. The script doesn't exactly delete records automatically, but if you put a line in the auth.pl file, sub auth_check_password, it will delete them whenever someone logs into the database.
The mod originated by SwanSong is setup to be used as follows:
1. Only delete a user's database record who has expired after a set amount of days, (30 days), BUT ONLY if the member_option (data field #2) equals "Guest".
2. If the the member_option field = "Guest" and their account has past the expiration days, then also delete there password line from the password file.
3. I have a creation_date field (data field #5) of when a user's account has been created. I am using the US date formation so this field contains a date that is formated like this: mm-dd-yyyy.
--------------------------------
DB.CFG - HTML.PL
Add the appropriate fields in both your .cfg file and within your sub html_record_form.
Example fields being used:
member_option => [2,'alpha',0,9,1,'',''],
creation_date => [5,'date',4,5,1,&get_date,''],
# RemoveAd => [26, 'numer', 4, 5, 1, '', ''],
# DateAdded => [1, 'date', 4, 5, 1, &get_date, ''],
--------------------------------
AUTH.PL
In sub auth_check_password {
After code:
open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file: $auth_dir/$uid. Reason: $!\n");
print AUTH "$uid: $ENV{'REMOTE_HOST'}\n";
close AUTH;
add code:
&auto_delete; #### added for autodelete mod
------------------------------------
DB.CGI:
In sub main {
Add: elsif ($in{'auto_delete'}) { if ($per_admin) { &auto_delete; } else { &html_unauth; } } ### autodelete
Add the following new sub:
sub auto_delete {
# ------------------------------------------
# Automatically removes entries older then $remove # days old.
#
my $remove = 30; # Number of days old.
my $date_field = 5; # Position of date field.
my $today = &date_to_unix(&get_date);
my $removeby = $today - ($remove * 86400);
my (@lines, @values);
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach $line (@lines) {
if ($line =~ /^#/) { next; }
if ($line =~ /^\s*$/) { next; }
chomp $line;
@values = &split_decode ($line);
if (($removeby > &date_to_unix($values[$date_field])) && ($values[2] eq 'Guest')) {
&auth_logging("System Auto-Deleted Expired Guest: $values[3],$values[2]");
open (PASS, "<$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) { flock(PASS, 1) }
@passlines = <PASS>;
close PASS;
open (PASS, ">$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
foreach $passline (@passlines) {
($passline =~ /^$values[$auth_user_field]:/) ?
($found = 1) :
print PASS $passline;
}
close PASS;
}
else {
print DB $line, "\n";
}
}
close DB;
}
Unoffical DBMan FAQ
http://redundantcartridge.com/dbman/