Search code examples
phpincluderequire-once

how to block access to include(x_file) from a file in a certain folder?


I have a folder that contains many different files:

folder1:

somthing.php
somthingelse.php
blah.php
ect ect....

Now, I don't want the files in that folder to access (include) files outside the folder. So it's okay to include('blah.php') but not okay to include('../blah.php')..

Any ideas on how I'd go about doing this?


Solution

  • This is only possible on the CLI and in a Unix environment. You would have to use chroot to hide other folders.

    http://php.net/manual/en/function.chroot.php