Gossamer Forum
Home : Products : DBMan : Installation :

File upload...

(Page 1 of 3)
> >
Quote Reply
File upload...
Hi JPD,
I'm soon gonna start with the installation of the file-upload mod. I've noticed a while ago, that you had some troubles with it. Is there something changed in the files?? And another important question: How does the 'autodelete-cron/mod' deal with it...

BTW, You have a more than perfect and beautiful Site, my compliments.
Quote Reply
Re: File upload... In reply to
Thank you for the compliment on my site. Smile

I don't know how the file-upload will work with your autodelete stuff. You might look at the code which is added to sub delete_records and see what you need to add to your autodelete routine.

Be sure to pick up the files that are currently on my site. Don't use anything you got before.


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





Quote Reply
Re: File upload... In reply to
Well, I've take a look at the files for a few hours and I think I will be able to install the file_upload mod. Only the cooperation with the autodelete stuff will not come into my mind, where do I have to start?? The rules in the autodelete-mod are much different than the rules to add to the db.cgi, so there's nothing to compare for me...
Quote Reply
Re: File upload... In reply to
I'll have to look at your autodelete mod again. Can you post it in text form on your site for me to look at?


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





Quote Reply
Re: File upload... In reply to
OK, I'll post the whole cleanup.pl at http://www.autorandstad.nl/cleanup_pl.txt, maybe there's a way to put the 'sub autodelete1' and 'sub autodelete2' in one sub...

Thanks in advance.
Greetings,
--------
Mart.
Quote Reply
Re: File upload... In reply to
Looks to me like those two subroutines are identical. What's the difference between them?

To delete the graphic at the same time as you delete the record,

after

Code:
if ($today > (&date_to_unix($values[$dateadded_field]) + (86400 * $values[$removeby_field]) {

delete

Code:
next;

and add

Code:
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
foreach $extension (@extensions) {
(-e "$SAVE_DIRECTORY/$data[$db_key_pos].$extension") && (unlink "$SAVE_DIRECTORY/$data[$db_key_pos].$extension")
}

You will have to define variables for $SAVE_DIRECTORY and $ALLOWED_EXT at the beginning of your script. Also $db_key_pos which is the number of your key field.

Seems like it would work.


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





Quote Reply
Re: File upload... In reply to
Well, thank you, I will try that and let you knows, if its working.
Quote:
Looks to me like those two subroutines are identical. What's the difference between them?
The only difference is that either of them calls another database (default.db and voorkeur.db). I've tried a 'foreach' subroutine, but I think, I've looked something over, this was the simplest solution, but there seems to be a more proffesional...
Quote Reply
Re: File upload... In reply to
I see.

You might try changing:

Code:
$db_file_name1 = $db_script_path . "/default.db";
$db_file_name2 = $db_script_path . "/voorkeur.db";

to

Code:
$db_file_name[0] = $db_script_path . "/default.db";
$db_file_name[1] = $db_script_path . "/voorkeur.db";

And then doing a foreach loop:

Code:
foreach $file (@db_file_name) {
open (DB, "$file") or die;
the rest of your code
close DB;
}

I don't know that it would work, but it's worth a shot.


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





Quote Reply
Re: File upload... In reply to
Now I'm really confused. Aren't we talking about a separate script that you are running through cron? Is there a reason that you are loading the db.cgi script?


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





Quote Reply
Re: File upload... In reply to
No, this is far beyond the cron, its after I install the file-upload modification. Make sence??
Quote Reply
Re: File upload... In reply to
Got a problem, it load some vaiable double, the following message I get:
Code:
CGI ERROR
==========================================
Error Message : Error loading required libraries.
Check that they exist, permissions are set correctly and that they compile.
Reason: Invalid config file name: default~~default at db.cgi line 50.

Script Location : db.cgi
Perl Version : 5.00502
Setup File : default~~default.cfg
Session ID : mart2.93515570159183~~mart2.93515570159183

Form Variables
-------------------------------------------
ALLOWED_EXT : \.gif$|\.jpg$
MAXIMUM_UPLOAD : 50000
SAVE_DIRECTORY : /opt/guide/www.automart.nl/HTML/foto
auth_allow_default : 1
auth_dir : ./auth
auth_no_authentication: 0
auth_pw_file : ./default.pass
db : default~~default
db_key : ID
db_script_url : http://www.autorandstad.nl/cgi-bin/dbman/db.cgi
default_permissions :
file-to-upload-01 :
newfilename : 143
uid : mart2.93515570159183~~mart2.93515570159183

Environment Variables
-------------------------------------------
DOCUMENT_ROOT : /opt/guide/www.autorandstad.nl/HTML
GATEWAY_INTERFACE : CGI/1.1
HTTP_ACCEPT : application/msword, application/vnd.ms-excel, image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
HTTP_ACCEPT_ENCODING: gzip, deflate
HTTP_ACCEPT_LANGUAGE: nl
HTTP_CONNECTION : Keep-Alive
HTTP_HOST : www.autorandstad.nl
HTTP_REFERER : http://www.autorandstad.nl/cgi-bin/dbman/db.cgi
HTTP_USER_AGENT : Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt)
PATH : /usr/local/bin:/usr/bin:/bin
QUERY_STRING : db=default&uid=mart2.93515570159183&db=default&uid=mart2.93515570159183&newfilename=143&SAVE_DIRECTORY=%2Fopt%2Fguide%2Fwww.automart.nl%2FHT ML%2Ffoto&MAXIMUM_UPLOAD=50000&ALLOWED_EXT=%5C.gif%24%7C%5C.jpg%24&db_key=ID&auth_no_authentication=0&default_permissions=&auth_allow_defaul t=1&db_script_url=http%3A%2F%2Fwww.autorandstad.nl%2Fcgi-bin%2Fdbman%2Fdb.cgi&auth_dir=.%2Fauth&auth_pw_file=.%2Fdefault.pass&file-to-upload -01=
REMOTE_ADDR : 195.121.227.39
REMOTE_HOST : rt0807-2.dial.wxs.nl
REMOTE_PORT : 1165
REQUEST_METHOD : GET
REQUEST_URI : /cgi-bin/dbman/db.cgi?db=default&uid=mart2.93515570159183&db=default&uid=mart2.93515570159183&newfilename=143&SAVE_DIRECTORY=%2Fopt%2Fguide% 2Fwww.automart.nl%2FHTML%2Ffoto&MAXIMUM_UPLOAD=50000&ALLOWED_EXT=%5C.gif%24%7C%5C.jpg%24&db_key=ID&auth_no_authentication=0&default_permissi ons=&auth_allow_default=1&db_script_url=http%3A%2F%2Fwww.autorandstad.nl%2Fcgi-bin%2Fdbman%2Fdb.cgi&auth_dir=.%2Fauth&auth_pw_file=.%2Fdefau lt.pass&file-to-upload-01=
SCRIPT_FILENAME : /opt/guide/www.autorandstad.nl/cgi-bin/dbman/db.cgi
SCRIPT_NAME : /cgi-bin/dbman/db.cgi
SERVER_ADMIN : webmaster@autorandstad.nl
SERVER_NAME : www.autorandstad.nl
SERVER_PORT : 80
SERVER_PROTOCOL : HTTP/1.1
SERVER_SOFTWARE : Apache/1.3.6 (Unix) PHP/3.0.7 mod_frontpage/3.0.4.3
UNIQUE_ID : N71bm9TMyAEAAD-5Ix8
I don't realy know, where to search...
Quote Reply
Re: File upload... In reply to
Oh, okay. Just please tell me when you're "changing gears." I have enough trouble with following one subject! Smile

Sounds like you have two hidden fields in your form --

<input type=hidden name="db" value="$db_setup">

The file upload form needs to be a separate form from any other form that you have on your page. Is this happening when you are modifying a record or after you've added one?


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





Quote Reply
Re: File upload... In reply to
Its happening by both, modifying and adding.
Quote Reply
Re: File upload... In reply to
I'll need to look at your html.pl file, then.

I'm really unclear as to why you would have the problem when you add. There isn't a form on that page. But maybe you have something else going on that I don't know about.


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





Quote Reply
Re: File upload... In reply to
ok, its on http://www.autorandstad.nl/html+upl_pl.txt

BTW, its not when I will add, the adding and modifying form will appear, but the next action will faile, so pressing the 'upload file' button, even without a file specified, gives the failure. And before the adding of the file-upload mod, it works good.

[This message has been edited by mart (edited August 20, 1999).]
Quote Reply
Re: File upload... In reply to
Are you using the most recent version of the file-upload mod? There is no way that any of the form fields for the file-upload mod should be going to db.cgi. It uses a completely different script.

Have you made any changes to the file-upload.cgi file?

Wait a minute. You said

Quote:
pressing the 'upload file' button, even without a file specified, gives the failure

What happens when you use it correctly, with a file specified?

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





Quote Reply
Re: File upload... In reply to
Yes, I took it two days ago from your (great) site. And when I fill in a file, it gave the same failure. No difference.

[This message has been edited by mart (edited August 20, 1999).]
Quote Reply
Re: File upload... In reply to
I don't know what to tell you, then. It doesn't make any sense to me.


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





Quote Reply
Re: File upload... In reply to
When I am in the modify record display and press 'modify record' it happens also.
Quote Reply
Re: File upload... In reply to
One step further, I forgot to copy a '</form> tag in the 'modify_record_form' sub, but then another error-message came: "The directory you specified isn't really a directory.
Make sure that this is indeed a directory and not a file", I am pretty sure, that I've made a directory right under my HTML-dir, chmod it 777 and specified the '$SAVE_DIRECTORY' as '"/opt/guide/www.automart.nl/HTML/foto"', so what now could be wrong???, I feel that I'm pretty close to the happy end of this...(Now going to sleep...)

[This message has been edited by mart (edited August 20, 1999).]
Quote Reply
Re: File upload... In reply to
Well, not ending the previous form would definitely cause the problem you were having. I didn't notice it, but then it's hard to look at someone else's code. Also, I didn't look at html_modify_form_record because you said you were having the same problem with the form on html_add_success.

You can try commenting out

Code:
if (!(-d $SAVE_DIRECTORY)) {
$message = "The directory you specified isn't really a directory.\nMake sure that this is indeed a directory and not a file.";
}

in file-upload.cgi and see what happens.





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





Quote Reply
Re: File upload... In reply to
This is wrong:

$db_key_pos = [0];

This is what it should be

$db_key_pos = 0;

Quote:
must there an ';' at the end of '(unlink "$SAVE_DIRECTORY/$data[$db_key_pos].$extension")'??

No. That's not the end of the line.

The other problem you may be having is if you are trying to delete files from another server than you're running the script on.


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





Quote Reply
Re: File upload... In reply to
I've tried this '$db_key_pos = 0;' already, without result. The script is installed on the same server, otherwise it won't work. So, when I installed the code you gave me, also the records aren't deleted and when I deleted the rules, it deleted the older records correctly. I'll post the installed code, maybe there is something wrong.
Code:
sub auto_delete1 {
# ------------------------------------------
# Automatically removes entries older than
# a predetermined date
#

my (@lines, @values);
$today = &date_to_unix(&get_date);

open (DB, "$db_file_name1") or die;
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name1") or die;
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
if ($today > (&date_to_unix($values[$dateadded_field]) + (86400 * $values[$removeby_field]))) {
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
foreach $extension (@extensions) {
(-e "$SAVE_DIRECTORY/$data[$db_key_pos].$extension") && (unlink "$SAVE_DIRECTORY/$data[$db_key_pos].$extension")
}
}
print DB $_, "\n";
}
close DB;
}
Quote Reply
Re: File upload... In reply to
What happened to the else?

It should look something like

Code:
else {
print DB $_, "\n";
}

That's why your records aren't being deleted.

I don't know about your files not being deleted.

You might try, instead of

Code:
$ALLOWED_EXT =~ s/\\.//g;
$ALLOWED_EXT =~ s/\$//g;
@extensions = split (/\Q|\E/o,$ALLOWED_EXT);
foreach $extension (@extensions) {
(-e "$SAVE_DIRECTORY/$data[$db_key_pos].$extension") && (unlink "$SAVE_DIRECTORY/$data[$db_key_pos].$extension")
}

just

Code:
unlink "$SAVE_DIRECTORY/$data[$db_key_pos].gif";
unlink "$SAVE_DIRECTORY/$data[$db_key_pos].jpg";




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





Quote Reply
Re: File upload... In reply to
OK, that does it, just wondering: Why can't I put the pictures (files) on a whole other Site? Thats the thing, what went wrong I think.
> >