php scripts and file permissions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

php scripts and file permissions

Post by nigma »

I've got a php script that reads data from a text file. I'd like the text file to not be visible to anyone who types in the url, but the php script needs to have access to it. What would the permissions be on such a file?
Last edited by nigma on Thu Mar 17, 2005 10:10 pm, edited 1 time in total.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Re: php scripts and protected files

Post by hongco »

nigma wrote:I've got a php script that reads data from a text file. I'd like the text file to not be visible to anyone who types in the url, but the php script needs to have access to it. What would the permissions be on such a file?
just save your text files outside your webroot; your php script will have direct access to the text files; hence, to view the files by users, they must execute your php script which yields your desired outputs.
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

All i've got access to over ftp is webroot and child folders.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

why not make the text file a php file? You can prepend a comment mark for each line of data, and surround the whole thing in <?php ?> .. so even if someone requests the file, they get bubkes
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

excellent idea feyd, thanks a bunch.
Post Reply