Gossamer Forum
Home : Products : DBMan : Customization :

Auto Delete From .Pass when user Deletes one a only record.

Quote Reply
Auto Delete From .Pass when user Deletes one a only record.
Hi all,

I have been searching the forums and faq's looking for a means of deleting a user from the password file when they delete their record from the database. If I might explain I am working on a Jobs database with a Second Dbase as a Job Agent(thanx kellner). Users can register to receive jobs via email that match their chosen criteria. They have one and only one record I have setup the key as the email address so they dont try and reregister having more than one profile for one email. I would simply like to auto delete the user from the .pass file when they remove their profile record.

Any assistance greatly appreciated

JamesSmile
Quote Reply
Re: [jamesamorris] Auto Delete From .Pass when user Deletes one a only record. In reply to
This is taken from the FAQ under the section "Files"

userID and password deleted when record is deleted
===========================================

Only one record per member is allowed, so the add_record routine should only be accessed
during the initial registration, and the delete routines should also delete the member's UserID
and password from the file default.pass (which I have renamed members.pass).

***** cut out rest of thread .... this is to have userID and password deleted when record is deleted. ******

----------------------------------------------------
Response:

Okay. Open up db.cgi and find sub delete records. Look for: code:

$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= $line . "\n"); # otherwise print it.

and replace it with the following: code:

if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
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) {
($passlineline =~ /^$in{'username'}:/) ?
($passfound = 1) :
print PASS $line;
}
close PASS;
}
else {
$output .= $line . "\n";
}

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/