Jump to content

Recommended Posts

Hi, I was wondering how I would go about stopping PHP files from altering things outside of it's directory.

Say [user X] creates a PHP script that script automatically saves to [user X]'s folder located within Localhost/Users/ where all user folders are located.

But none of [user X's] files can access access any folder above it's own.

 

How would I be able to specify this in PHP or the PHP.ini?

 

Example

 

Things like "$fp=fopen($_SERVER['DOCUMENT_ROOT'] ."/Users");" would be bad.

 

Thankyou,

GB.

Take a look at open_basedir, http://www.php.net/manual/en/ini.core.php#ini.open-basedir

 

You might also want to take a look at safemode.

 

So basically I'd have to do something like:

[PATH=/path/to/Users/]

  open_basedir = /path/to/Users/

 

If so, wouldn't the Users be able to possibly access another User's folder?

Then you don't really have enough control over the configuration. You could set this via a .htaccess, though there would be nothing stopping a user from editing the .htaccess file.

 

How would I be able to do it via .htaccess?

Also users would only be able to edit their PHP files via editor I provide them so I don't think they'd be able to edit the .htaccess.

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.