Gossamer Forum
Home : Products : DBMan : Customization :

Re: uid password and image deletes

Quote Reply
Re: uid password and image deletes In reply to
I think I've got it. Be *sure* to backup all your files before you try this, though. Smile

In db.cgi, sub delete_records, change

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.

to

Code:
if ($delete_list{$data[$db_key_pos]}) {
$path = "/path/to/directory";
$delete_list{$data[$db_key_pos]} = 0;
%rec = &array_to_hash(0,@data);
$directory = "$path/$rec{'Agency'}/$rec{'Town'}/$data[$auth_user_field]/$rec{'Category'}";
opendir (DIRECTORY, "$directory")
or &cgierr("unable to open directory in delete_records: $directory. Reason: $!");
@files = readdir(DIRECTORY);
close DIRECTORY;

foreach $file (@files) {
if ($file =~ /^$rec{'ID'}/) {
unlink ("$directory/$file")
}
}
}
else {
$output .= $line . "\n";
}

Be sure you set the $path variable to the full path to the main directory where your image files are. No trailing slash!!

It is set up so that an admin can delete the files, too, since it uses the userid from the record.


------------------
JPD







[This message has been edited by JPDeni (edited September 29, 1999).]
Subject Author Views Date
Thread uid password and image deletes handmade 4094 Sep 28, 1999, 9:28 AM
Post Re: uid password and image deletes
JPDeni 3971 Sep 28, 1999, 6:26 AM
Post Re: uid password and image deletes
handmade 3983 Sep 28, 1999, 8:16 AM
Post Re: uid password and image deletes
JPDeni 3964 Sep 28, 1999, 11:23 AM
Post Re: uid password and image deletes
handmade 3973 Sep 28, 1999, 6:58 PM
Post Re: uid password and image deletes
JPDeni 3978 Sep 29, 1999, 5:24 AM
Post Re: uid password and image deletes
handmade 3943 Sep 29, 1999, 6:02 AM
Post Re: uid password and image deletes
JPDeni 3978 Sep 29, 1999, 6:09 AM
Post Re: uid password and image deletes
JPDeni 3973 Sep 29, 1999, 8:11 AM
Post Re: uid password and image deletes
handmade 3959 Sep 29, 1999, 6:28 PM
Post Re: uid password and image deletes
handmade 3962 Sep 30, 1999, 9:55 PM
Post Re: uid password and image deletes
handmade 3955 Oct 1, 1999, 8:21 AM
Post Re: uid password and image deletes
JPDeni 4021 Oct 1, 1999, 8:41 AM
Post Re: uid password and image deletes
JPDeni 3969 Oct 1, 1999, 10:56 AM
Post Re: uid password and image deletes
handmade 3957 Oct 3, 1999, 3:04 AM
Post Re: uid password and image deletes
handmade 3945 Oct 17, 1999, 9:45 PM
Post Re: uid password and image deletes
JPDeni 3986 Oct 18, 1999, 11:59 AM
Post Re: uid password and image deletes
handmade 3972 Oct 18, 1999, 3:46 PM
Post Re: uid password and image deletes
JPDeni 3971 Oct 19, 1999, 6:29 AM
Post Re: uid password and image deletes
handmade 3988 Nov 1, 1999, 9:42 AM