require() denial

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
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

require() denial

Post by EricS »

I have a configuration file I use with all my applications. This configuration file has things like physical paths but it also has things like Database usernames and passwords in it.

Now some of the hosting companies my clients use will not allow me to store files outside the document root. So I obviously want to protect that file from being included by mischievious coders.

How can I keep outside scripts from calling this file.

Thanks for everything.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Get it to check which server it's being called from - you'll probably find a number of things in $_SERVER which you could use. There's also the storing the file in a strangely named directory approach (i.e. not putting it in an includes directory) and giving the file itself an unobvious name.

Mac
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Post by EricS »

Thanks Twig,

I had a feeling there probably wasn't any guaranteed way to do it. But I appreciate the advice.
Post Reply