To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Misc Help > Linux/Unix Help

Linux/Unix Help Help with server-side Linux and Unix issues

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-29-2002, 07:26 AM   #1
thoand
Senior Member
 
Join Date: Mar 2002
Posts: 338
Security +web server

Hi,
is it possible to get files(with a browser) from the that are over the www root directory?
eg.


/home/myfolder/doc.pdf
/home/myfolder/www/

I realy need a secure (as it can get) solution for putting sensitive documents on the web for downloading (only authorised users)
without htaccess.

best regards,
Thomas
thoand is offline   Reply With Quote
Old 10-30-2002, 01:56 PM   #2
mikejohnston
Member
 
mikejohnston's Avatar
 
Join Date: Sep 2002
Location: Atlanta, GA USA
Posts: 35
I would recommend placing the documents into a database field. Then you can pull the file from the field and push the file to the user as needed.
__________________
Mike Johnston
CTO, Soholaunch.com, Inc.
http://www.soholaunch.com
mikejohnston is offline   Reply With Quote
Old 11-08-2002, 11:25 AM   #3
davetshave
Linux newbie
 
Join Date: May 2002
Location: Delft, Netherlands
Posts: 36
Wouldn't that be slow?

Wouldn't storing files in a database be an overhead the system could do without?

I am working on a system that does something similar to what Thoand is describing and I stream the files across from an 'inaccessible' directory.

To be honest I have some reservations about the security of my current solution and am keeping an open mind about a better solution.

If you place the files in a directory like:

/home/myfolder/documents/

And you webservers root is:

/home/myfolder/www/

then as far as I can figure it there is no way for a user to access the documents in using their browser. The php-script I use to stream the files across to the users browser is this:

// $filename is the location and filename of the file to stream
// $realfilename is the name which the user is prompted to save
// under

header("Cache-control: private;"); // fix for IE

header("Content-type: multipart/mixed; boundary=\"simple boundary\";"); // fix for IE

header("--simple boundary");
header("Content-Type: Text/plain;");
header("testing");
header("--simple boundary");
header("Content-Type: application/word;");
header("Content-Length: ".filesize($filename).";");
header("Content-Disposition: attachment; filename=".$realfilename.";");

$fp = fopen($filename, 'r');
fpassthru($fp); // ** CORRECT **
fclose($fp);
header("--simple boundary");

Remember that there must be no output to the browser before you send headers, not even whitespace in front of your php script.

Hope this helped. Hope someone shoots my crappy security solution down with something more explicitly safe.


Last edited by davetshave; 11-08-2002 at 11:42 AM.
davetshave is offline   Reply With Quote
Old 11-08-2002, 11:32 AM   #4
mikejohnston
Member
 
mikejohnston's Avatar
 
Join Date: Sep 2002
Location: Atlanta, GA USA
Posts: 35
No. I actually have found it to be faster. When listing filenames, DON'T pull the blob field that contains the binary data just to display the filename, size, etc. else it will be slow.
__________________
Mike Johnston
CTO, Soholaunch.com, Inc.
http://www.soholaunch.com
mikejohnston is offline   Reply With Quote
Old 11-08-2002, 11:51 AM   #5
davetshave
Linux newbie
 
Join Date: May 2002
Location: Delft, Netherlands
Posts: 36
Question does the database solution scale?

Interesting... I am starting to warm to the database idea. Hope you don't mind me shooting at it a bit, just trying to make sure I am aware of any pitfalls.

Okay, so let's say we put the files in a mysql database. Would it be able to manage multiple users trying to access the same file simultaneously? For some reason my instincts say "Files don't belong in a database, that's what file systems are for".

I'm racking my brains for brains for some 'cons' to balance out the databases 'pros', but drawing a blank.



Oh well I suppose someone else might have something to contribute to this so I'll shutup now.
davetshave is offline   Reply With Quote
Old 11-08-2002, 11:58 AM   #6
mikejohnston
Member
 
mikejohnston's Avatar
 
Join Date: Sep 2002
Location: Atlanta, GA USA
Posts: 35
You could "in theory" run into problems with simultanous downloads, but mysql can handle multiple threads. Remember, the actual "download" is "reading" data from the table so problems generally present themselves when "writing" to the record.

I have a database table with about 2000 files in it (images, documents, etc.) and I have not experienced any slow down or resource issues with it "so far".

__________________
Mike Johnston
CTO, Soholaunch.com, Inc.
http://www.soholaunch.com
mikejohnston is offline   Reply With Quote
Old 11-12-2002, 05:45 AM   #7
davetshave
Linux newbie
 
Join Date: May 2002
Location: Delft, Netherlands
Posts: 36
Smile A final comment.

Although I am also using mySQL I was hoping to use my product with more databases than that. Even access. So I suppose that if one can use mySQL then storing files in a DB is not such an issue and is probably the better (more integrated) solution.

I'm not so sure how well access would deal with it though.

Glad we discussed this as now I know for sure which way I should jump.

Greetings,

David.
davetshave is offline   Reply With Quote
Old 11-12-2002, 06:00 AM   #8
thoand
Senior Member
 
Join Date: Mar 2002
Posts: 338
Thanks

Thank you for sharing your thoughts on this subject.
It seems I have no other choise to store them in an inaccessible folder on the server, because the client has this way on their internal system.

best regards Thomas
thoand is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 12:02 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.