GB_001 Posted May 8, 2011 Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/ Share on other sites More sharing options...
trq Posted May 8, 2011 Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/#findComment-1212243 Share on other sites More sharing options...
GB_001 Posted May 8, 2011 Author Share Posted May 8, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/#findComment-1212248 Share on other sites More sharing options...
trq Posted May 8, 2011 Share Posted May 8, 2011 You can set this directive on a per virtual host basis. Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/#findComment-1212251 Share on other sites More sharing options...
GB_001 Posted May 8, 2011 Author Share Posted May 8, 2011 That'd work if I were using virtual hosts, but I'm not as I'm just using a different folder per User where their individual PHP files are kept. Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/#findComment-1212254 Share on other sites More sharing options...
trq Posted May 8, 2011 Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/#findComment-1212279 Share on other sites More sharing options...
GB_001 Posted May 8, 2011 Author Share Posted May 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235827-restrict-php-files-to-respective-user-folder/#findComment-1212411 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.