/    Sign up×
Community /Pin to ProfileBookmark

Restrict PHP files to one folder.

Hi if I had php files in one folder, and I only wanted them to have access to [B]only[/B] a specific folder and it’s subdirectories, how would I go about doing that?

Also what are some harmful PHP functions I may need to disable, in case of possible exploits?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 06.2011 — The [url=http://www.php.net/manual/en/ini.core.php#ini.open-basedir]open_basedir[/url] setting can be used to control directory access by PHP scripts. (Of course, this does nothing for Perl or shell scripts.) I would also suggest making sure [url=http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include]allow_url_include[/url] is off, and if you don't need it then also turn off [url=http://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen]allow_url_fopen[/url]. If you don't need to use cURL at all, you could disable the curl_init() function, too. Basically this is all to keep scripts from accessing anything via URL, and with the open_basedir restriction you end up only allowing PHP scripts to access local files within the specified directory tree. Of course, some PHP scripts need to access remote content, in which case I recommend using the cURL functions and leaving the allow_url_* settings off if possible, and if not still leave the allow_url_include setting off.
Copy linkTweet thisAlerts:
@GB_001authorMay 07.2011 — Thank you, that helped alot.
×

Success!

Help @GB_001 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...