User149 Posted December 31, 2010 Share Posted December 31, 2010 Hi, I have my website located at /home/public_html. I have a folder used by my web managers at /home/public_html/dev. The web managers only have the permissions to access the contents of that dev directory and no other directory on the website. But, is there a way to disable certain dangerous functions like shell_exec() only in /home/public_html/dev ? I know you can disable functions in php.ini, but the problem is that if I put the php.ini file in the /home/public_html/dev directory, it could easily be changed (on my shared host it's not possible to change owner/group permissions). Putting the php.ini file with the disabled functions list in /home/public_html works great in preventing the dev folder from using them since its in an inaccessible location to the web managers, but unfortunately that also prevents me from using the functions in public_html, where they are needed. One possible solution I was thinking could involve writing an .htaccess conditional statement, but I'm not quite such how to accomplish that. Here is what I would need to do in my .htaccess file: IF DIRECTORY == /home/public_html/dev { suPHP_ConfigPath /home/public_html/php.ini # Sets the location of the php.ini file to use. # I know suPHP_ConfigPath works perfectly, just need to know how to do the conditional } I would have the above .htaccess file as well as the php.ini file with the restrictions located in /home/public_html, but it would ideally only use that php.ini file with the restrictions within the dev folder. Does anyone know how to accomplish the above conditional statement, or some other solution which would allow me to disable certain PHP functions for the dev directory without affecting the public_html directory or having the php.ini file directly in the dev directory? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/223072-disable-certain-php-functions-for-a-specific-directory/ Share on other sites More sharing options...
laffin Posted December 31, 2010 Share Posted December 31, 2010 From what I can gather this is only possible with the cgi version of php not the apache module. http://www.askapache.com/php/custom-phpini-tips-and-tricks.html Quote Link to comment https://forums.phpfreaks.com/topic/223072-disable-certain-php-functions-for-a-specific-directory/#findComment-1153310 Share on other sites More sharing options...
laffin Posted December 31, 2010 Share Posted December 31, 2010 Acutally i found this tidbit here Finally, for those using one of the Apache 2 versions, you will need to indicate the location of your PHP ini file. Add the following line to the end of your httpd.conf file. PHPIniDir "c:/php" That with the apache Directory option should get u what u want Quote Link to comment https://forums.phpfreaks.com/topic/223072-disable-certain-php-functions-for-a-specific-directory/#findComment-1153312 Share on other sites More sharing options...
User149 Posted December 31, 2010 Author Share Posted December 31, 2010 Acutally i found this tidbit here Finally, for those using one of the Apache 2 versions, you will need to indicate the location of your PHP ini file. Add the following line to the end of your httpd.conf file. PHPIniDir "c:/php" That with the apache Directory option should get u what u want Thanks so much for the help! Here is what I now have in my .htaccess file located at /home/public_html/.htaccess: <Directory /home/public_html/dev> PHPIniDir "/home/public_html/php.ini" </Directory> Unfortunately I think I made a mistake there as it's now displaying "[an error occurred while processing this directive]" for any pages within that directory, which means there's an error in .htaccess file. It's probably an obvious mistake I made - but would you be able to provide the exact implementation of what you describe? Quote Link to comment https://forums.phpfreaks.com/topic/223072-disable-certain-php-functions-for-a-specific-directory/#findComment-1153313 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.