Jump to content

Disable Certain PHP Functions For a Specific Directory?


User149

Recommended Posts

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! :)

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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? :)

 

Link to comment
Share on other sites

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.