I was hoping that Lois would see this and tell us if she had a mod in her database like this. I seem to have lost the correct URL for it.
Add a checkbox to
sub html_admin_display would be easy enough to do. Call it "del_user_records" or something. Then, in
sub admin_display (db.cgi), in the
Code:
$in{'delete'} and do {
section, after the username is deleted from the password file, you would add the routine to delete records.
I would change
Code:
$found ?
($message = "User: $in{'username'} deleted.") :
($message = "Unable to find userid: $in{'username'} in password file.");
to
Code:
if ($found)
{
$message = "User: $in{'username'} deleted."
if ($in{'del_user_records'})
{
open (DB, "<$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>;
close DB;
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
($output .= "$line\n" and next LINE) if ($in{'username'} ne $data[$auth_user_field]);
}
open (DB, ">$db_file_name") or &cgierr("error in admin_display. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
}
}
else
{
$message = "Unable to find userid: $in{'username'} in password file.";
}
I haven't tested this at all. I just copied bits of db.cgi. Please make a backup of your database before you try this. I'd hate for you to lose things you don't want to lose because I've made an error some place. It seems like the logical way to do it, but better safe than sorry. :)
JPD
----------------------------------------------------
JPDeni's DBMan-ual How to
ask questions the smart way.