Gossamer Forum
Home : Products : DBMan : Customization :

registration

Quote Reply
registration
I plan on using this script on another site. Will the $100 fee be in effect again? This is a commercial site.

Another question. Is it possible (loooong shot) to delete a record's image along with the record itself?
Quote Reply
Re: registration In reply to
Can't answer the question about registration. That's up to Alex.

Yes, you could set up your db.cgi file to delete an image at the same time it deletes a record. A lot would depend on how things are set up. Are all the image files of the same type (.gif, .jpg, whatever)? Are all of the image files in the same directory? Is the name of the image file within the record, or is it connected to the record another way? For example, you could have images that have the name of the $db_key -- if your $db_key for a given record is "123," then the graphic is named "123.gif". That would be the easiest way to delete the files.

We can go into some of the procedure after you answer the questions above.

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





Quote Reply
Re: registration In reply to
Sorry I wasn't a little more vague!

My pictures are all .gifs, they are all in the same directory(images), and the name of the image is the same as the database key.
Example: key: $rec{'Itemno'} = ac-64-23-98
Image: http://www.racedaze.com/images/$rec{'Itemno'}.gif
The script uses the Itemno field to produce the image and the item number.

What would be a good routine to delete the pic when the record is deleted? You sound like this is possible!
Quote Reply
Re: registration In reply to
 
Code:
$delete_list{$data[$db_key_pos]} ?
($delete_list{$data[$db_key_pos]} = 0) :
($output .= $line . "\n");

Change them to

Code:
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
unlink ("path/to/images/dir/$data[$db_key_pos].gif");
}
else {
$output .= $line . "\n"
}

I haven't tried this, so test it out with some files you have backups on first. As a matter of fact, until you are sure it works, you probably should keep a backup of your entire images directory.

Be sure to use the path to your images directory and not the URL.


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





Quote Reply
Re: registration In reply to
Hi Chris,

Error checking should handle this one. Do:

unlink ("/home/racedaze/racedaze-www/images/$data[$db_key_pos].gif") or &cgierr ("Can't remove image: /home/racedaze/racedaze-www/images/$data[$db_key_pos].gif. Reason: $!");

and see what the error message says.

I'll email you shortly about the licensing question.

Cheers,

Alex
Quote Reply
Re: registration In reply to
I would try

"../../images/$data[$db_key_pos].gif"

as the path. Of course, Alex always comes up with the smart thing to do. Smile When in doubt, ask the server what the problem is!


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





Quote Reply
Re: registration In reply to
It works! It was a permission problem. The "images" directory's permissions were not set. Duhhhhh!
That means that JPDeni was right on the money! I truly never doubted you JP, I wrote Alex concerning the registration and asked him to look at this forum.
I chmoded the dir to 777. Is this safe?

Thanks again for your help JP!
Chris
Quote Reply
Re: registration In reply to
It doesn,t seem to work JPD.

I think it might have something to do with unlink ("/home/racedaze/racedaze-www/images/$data[$db_key_pos].gif");
Does the $db_key_pos need to be there? I tried it without it and it still doesn't work. It still deletes the record, but the picture remains.
Quote Reply
Re: registration In reply to
Hmmmmm. It should. (Famous last words! Smile )

At that point in sub delete_records, your record is in an array called @data. You access the individual fields with the variable $data[position]. The variable $db_key_pos denotes which field to look for.

I just tested the perl code on my home computer and it works for me.

Possibly you need to change the path to be relative to the directory where your db.cgi script is. For example, my db.cgi script is in /home/cgi-bin/dbman/. I have some text files I use in one of my databases which are in /home/public_html/invsum/writing. So the path I use is ../../public_html/invsum/writing. (It took me quite a bit of trial and error to figure this one out! Smile )


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





Quote Reply
Re: registration In reply to
Sorry to bother you so much, but I am trying to open tommorrow. I've tried everything, and I can't seem to get the right path. Could it be permissions?
Here are my paths:
db.cgi= /home/racedaze/racedaze-www/cgi-bin/racedaze/db.cgi

image= /home/racedaze/racedaze-www/images/image.gif

Thank you for all your help!
Chris
Quote Reply
Re: registration In reply to
Whew! I can stop dreaming about deleting files now!!! Smile

Technically, I suppose chmoding to 777 isn't really safe. But who would know that the directory is set up that way? I'd be really surprised if you had any problems.

I'm so glad it worked for you. Which way worked? The full path or the relative one?

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





Quote Reply
Re: registration In reply to
The full path worked, but I'm sure the relative path worked fine, the images dir just needed chmoding.

Thank you for eliminating a nagging step for the "normal" people that will be maintaining this page.

Sorry to give you nightmares,I'm sure you've had worse!

Thanks JP & Alex!
Chris