Gossamer Forum
Home : Products : DBMan : Customization :

Deleting images does not change validate field

Quote Reply
Deleting images does not change validate field
I have had the multi upload mod up and running for a long time without any problems, but I just noticed that members were able to delete their pictures and the database would not change the validate field back to no. I have it set up so that a picture is required, but when they delete all their pictures, it just takes them to the "Graphic Field cannot be blank" error when they click on the Modify Record button. This is fine if they are going to re-add pictures, but if they don't, then they have a way around the required picture rule.

The system deletes the pictures as it should, but then the record is still visible to everyone and we don't know they deleted all their pictures since it doesn't show up on the Validate Records page.

Is there a way to fix this? I have a feeling this bug is going to get out and people will take advantage of that and post their profiles and remove their pictures once their profile has been validated.
Thanks in advance!


DBMan SQL Version 1 mods available at:
http://dbmansqlmods.rainbowroomies.com
(Mods based on JPDeni's original mods.)
Quote Reply
Re: [shann123] Deleting images does not change validate field In reply to
So you are saying it allows them to modify the record without entering a new photo?

What you could do is setup the script to re-validate records after a modification is made.. then you will be notified. Check the instructions for sub modify_record in the validate mod instructions.

Also check out the thread called "file upload validation problem" by lanerj jul 4,2000

This thread includes some code to force minimum upload file size. Perhaps this will force them to have to add a photo to be able to modify their record?

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Deleting images does not change validate field In reply to
Hi Lois,
Thanks for getting back with me. The database is set up to revalidate records after modifications, but if they don't do anything other than delete their pictures, then it doesn't go back for re validation.
The file upload validation problem doesn't seem like it would help with this problem.
I don't know if maybe I missed something in the sub modify routine or not. Here's the sub:

sub modify_record {
# --------------------------------------------------------
# This routine does the actual modification of a record. It expects
# to find in %in a record that is already in the database, and will
# rewrite the database with the new entry. First it checks to make
# sure that the modified record is ok with validate record.
# It then goes through the database looking for the right record to
# modify, if found, it prints out the modified record, and returns
# the user to a success page. Otherwise the user is returned to an error
# page with a reason why.

my ($status, $line, @lines, @data, $output, $found, %rec, $key, $num_files, @files, $file);

if ($auth_modify_own and !$per_admin) {
%rec = &get_record($in{$db_key});
unless ($rec{$db_cols[$auth_user_field]} eq $db_userid) {
&html_modify_failure("You are not authorized to modify this record");
return;
}
}
foreach $key (keys %in) {
if ($in{$key} eq 'delete') {
unlink "$SAVE_DIRECTORY/$in{$db_key}/$key";
}
}
$num_files=0;
if (-e "$SAVE_DIRECTORY/$in{$db_key}") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$in{$db_key}") or &cgierr("unable to open directory: $SAVE_DIRECTORY/$rec{$db_key}. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
next if ($file =~ /^\./); # Skip "." and ".." entries..
next if ($file =~ /^index/); # Skip index.htm type files..
++$num_files;
}
}

if ($num_files or $in{'file-to-upload-1'}) { $in{'Graphic'} = 'Yes'; }
else { $in{'Graphic'} = ''; }

(!$per_admin) and ($in{$db_validated_field} = "No");

$status = &validate_record; # Check to make sure the modifications are ok!
if (($status eq "ok") && ($in{'file-to-upload-1'})) { $status = &validate_upload; } #Validate Pictures

if ($status eq "ok") {
open (DB, "<$db_file_name") or &cgierr("error in modify_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
@lines = <DB>; # Slurp the database into @lines..
close DB;

$found = 0; # Make sure the record is in here!
LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; } # Skip and Remove blank lines
if ($line =~ /^#/) { $output .= $line; next LINE; } # Comment Line
chomp ($line);
@data = &split_decode($line);

if ($data[$db_key_pos] eq $in{$db_key}) {
# If we have userid's and this is not an admin, then we force the record to keep it's own
# userid.
if ($auth_user_field >= 0 and (!$per_admin or !$in{$db_cols[$auth_user_field]})) {
$in{$db_cols[$auth_user_field]} = $data[$auth_user_field];
}
$output .= &join_encode(%in);
$found = 1;
}
else {
$output .= $line . "\n"; # else print regular line.
}
}
if ($found) {
open (DB, ">$db_file_name") or &cgierr("error in modify_records. 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

&auth_logging("modified record: $in{$db_key}") if ($auth_logging);
&html_modify_success;
}
else {
&html_modify_failure("$in{$db_key} (can't find requested record)");
}
}
else {
&html_modify_failure($status); # Validation Error
}
}


Thanks again!


DBMan SQL Version 1 mods available at:
http://dbmansqlmods.rainbowroomies.com
(Mods based on JPDeni's original mods.)
Quote Reply
Re: [shann123] Deleting images does not change validate field In reply to
Did you by any chance check out this thread I mentioned above to see if it would help:

Also check out the thread called "file upload validation problem" by lanerj jul 4,2000

This thread includes some code to force minimum upload file size. Perhaps this will force them to have to
add a photo to be able to modify their record?

I know for the single upload mod there was a line which would verify a file was uploaded but I'm not sure how that would be modified to work with the multiple file upload mod.

Unoffical DBMan FAQ

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