Gossamer Forum
Home : Products : DBMan : Customization :

help with muilty file upload mod.

Quote Reply
help with muilty file upload mod.
Hello I'm have a problem with deleting a record, I'm using "M U L T I P L E F I L E U P L O A D Written: 28 Jun 2000".

Mod based on a script created by Jeff Carnahan jeffc@terminalp.com Adapted for use by DBMan by JPDeni deni@jpdeni.com Integration with DBMan script by Jim Kangosjärvi Jim.Kangosjarvi@Abc.se

If I delete a record that has A photo with it. the mod works fine.
But if I delete a record that dose not have a photo with it I get a error.


I tried a few things to see if it would work, and this what I came up with.


In my "sub delete_records" if I put this --

$delete_list{$data[$db_key_pos]} ? #
($delete_list{$data[$db_key_pos]} = 0) : #
($output .= $line . "\n");

The record would delete, but the photo would stay on the server.


If I replace it with this --

if ($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.
if ($db_upload) {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
}
}
else { $output .= $line . "\n"; }


It will delete a record that has A photo with it.
But if I delete a record that dose not have a photo with it I get a error.

I also tried this fix I found on this site from LoisC

######### changed for file upload mod ###########
if ($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.
if ($db_upload) {
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
unlink "$counter_dir/$data[$db_key_pos]"; #### remove counter file
}
}
}
else { $output .= $line . "\n";
}
########## end multiple file upload lines

But I got a error on it.


I know I did something wrong, but I can't see it.

Thank you for your help.
Ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
What are the error messages that you get?


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] help with muilty file upload mod. In reply to
Hello JP,

dbman has encountered an internal error.

is the error get.


thank you,

Ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
It looks like it should work. You may have a syntax error somewhere in the code, like an extra or missing bracket. If you want to post your db.cgi file, I'll run it through the compiler and see if that's the problem. (First step, look for syntax errors. :) )


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] help with muilty file upload mod. In reply to
Thanks JPD,

I walked through the install again, looking for something I missed but did not see it.

Ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
Okay. Try this one. I know that the syntax is correct. If it still doesn't work, then we'll take a closer look at the logic.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] help with muilty file upload mod. In reply to
As soon as I run the program I get a internal system error.

Ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
JPD, this is the error I got from my error log,

[Mon Dec 11 22:16:30 2006] [error] [client 74.138.113.91] Premature end of script headers: /usr/home/feicke/cgi-bin/lcc/db.cgi


ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
I really don't know what the problem is. That error message usually indicates some sort of sytax error and there isn't one in your db.cgi file. Did you change anything in your .cfg file or html.pl? If you want me to check them for syntax errors, you could attach them as well.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] help with muilty file upload mod. In reply to
Thanks JPD

Here they are.

Ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
I don't see any syntax errors. I was curious about this line from db.cgi:

Code:

unlink "$counter_dir/$data[$db_key_pos]"; #### remove counter file

Which I left in, but I don't know what it's for. There's no definition of a $counter_dir variable in your .cfg file. I doubt that would cause the problems your having, but I'd remove that line. Looks like an artifact from another alteration of the script.

To be sure what's causing the problem, I would make the following changes to db.cgi:

Code:

######### changed for file upload mod ###########
if ($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.
# if ($db_upload) {
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
# }
}
}
else { $output .= $line . "\n"; }
}
########## end multiple file upload lines


That will effectively take out the "fix" that you installed, but it's only temporary. Let's see if you get a syntax error when those lines aren't active. You shouldn't, but then you shouldn't get a syntax error when they are active either. :)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] help with muilty file upload mod. In reply to
No luck, got the "internal system error"

Ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
Try putting the delete records back to the original, then. See if you can put it back to the way it was before you started getting errors.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] help with muilty file upload mod. In reply to
Hello JPD,

I know it's dangers, but I've been thinking.Crazy


My db.cgi "sub delete_records" has this strip of code in it now. With it setup like this I can delete all records with or without images. But the dir with the images in it stay on the server.

***********code**********

$delete_list{$data[$db_key_pos]} ? #
($delete_list{$data[$db_key_pos]} = 0) : #
($output .= $line . "\n");
}

***********end***********



If I put this strip of code in, The program will only delete records with images, and it will remove the images from the server. but if there is no images I get and error.

***********code************
if ($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.
if ($db_upload) {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
}
}
else { $output .= $line . "\n"; }

***************end*********************


Could these two strips of code be ran at the same time? something like:

if no image with record, use code 1
if image is with record, use code 2

????????????
thanks

ed
Quote Reply
Re: [knue] help with muilty file upload mod. In reply to
That's really what the code did that was causing problems. It checked to see if there was a directory with images in it. If there was, it deleted them.

I see that you have the field "Graphic" in your .cfg file, but I don't see that it's written to anywhere. That would be the only way, other than checking for the existence of a directory, to know if there were images connected to the record.


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.