How to include file outside document root?

前端 未结 7 500
臣服心动
臣服心动 2020-12-03 01:48

What I want do to is to include \'file1.php\' from \'domain1\' into \'file2.php\' on \'domain2\'. So what I figured I should do is something like this:

file2         


        
7条回答
  •  长情又很酷
    2020-12-03 02:04

    You can include files from anywhere you want, unless your PHP script's permissions, or the safe mode prevent it. Your first approach is perfectly fine. What errors do you get?

    Re the comments, that seem to confirm that there is no access from within PHP to a file that definitely exists. As to what it could be, Suhosin having been ruled out, the only thing I can think of is PHP or Apache being some kind of a a chroot Jail:

    The main benefit of a chroot jail is that the jail will limit the portion of the file system the daemon can see to the root directory of the jail. Additionally, since the jail only needs to support Apache, the programs available in the jail can be extremely limited. Most importantly, there is no need for setuid-root programs, which can be used to gain root access and break out of the jail.

    I have never worked with anything like this so I can't tell you how to spot it (apart from doing a glob() on /var/www/vhosts and see what comes up. But I think this would have to have been set up by an administrator. Who runs your machine?

提交回复
热议问题