Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-16-2004, 09:35 PM   #1 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
Securing directories?

Go easy on me if this is a stupid question, but is there a way in which PHP can be used to secure directories, similar to what .htaccess is able to do?

What I'd like to do is to have a hidden directory containing various PDF and MS Word files and I'll build a PHP script that allows authorized people to retrieve those files. I'm okay on that part.

But if somebody knew the directory name and one of the file names, they would be able to bypass my PHP script and access the file directly. I need to prevent this, but if at all possible I'd like to avoid using .htaccess and secure the directory using only PHP. Is this possible?
Epsilon is offline   Reply With Quote
Old 08-17-2004, 12:12 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,711
redhead is on a distinguished road
You could have placed the files in a directory outside the reachable parts for the web.
Then use the suggested download function to retrieve the file, in that way nobody will be able to fetch it, only knowing the filename, since the folder is outside the "webscope"
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 08-17-2004, 08:59 AM   #3 (permalink)
Epsilon
Regular Contributor
 
Epsilon's Avatar
 
Join Date: Mar 2003
Location: Las Vegas, NV
Posts: 127
Epsilon is on a distinguished road
Thanks. That's actually a pretty good idea, but will require a little server mod. I'm running Red Hat 9 with the Plesk Server Management software, which basically roots all scripts into the public web directory. If you use a script to try to access files outside the web root you get an error like "open_base_dir restriction".

I know this can be over-ridden in httpd.conf, but I'd have to look into the implications of doing so. I appreciate the suggestion.
__________________
--Epsilon--
Epsilon is offline   Reply With Quote
Old 08-17-2004, 09:04 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,489
sde is on a distinguished road
well how worried about it are you really? why don't you make a directory in your web root and name it something like: tt9933sdfasdf333ddfa

then use that download function. it will hide where it is coming from. you could also put some verification for HTTP_REFERER stuff so people don't link directly to your download file.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
securing SUID0 programs? anon Standard C, C++ 4 02-22-2003 09:29 PM


All times are GMT -8. The time now is 09:53 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting