Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php open_basedir限制生效。htaccess_Php - Fatal编程技术网

Php open_basedir限制生效。htaccess

Php open_basedir限制生效。htaccess,php,Php,我发现了错误 Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (VIRTUAL_DOCUMENT_ROOT:/tmp/) in /www/elitno.net/s/p/anger2/home/site/classWebPage.php on line 83 我的phpinfo文件在这里-> 发生错误的行位于此处: f

我发现了错误

Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (VIRTUAL_DOCUMENT_ROOT:/tmp/) in /www/elitno.net/s/p/anger2/home/site/classWebPage.php on line 83
我的phpinfo文件在这里->

发生错误的行位于此处:

function openLink(){
    $this->fp = fopen($this->URL, "rb");
    array_shift($http_response_header);
    $this->headers = $http_response_header;
}
我只能访问.htaccess,但不能访问php.ini文件;我试过用这个

open_basedir = "VIRTUAL_DOCUMENT_ROOT:/tmp/:/www/elitno.net/s/p/ranger2/home/site/"
但是这会产生500个内部错误,有什么建议吗?

通常,fopen只允许打开运行脚本的用户有权访问的文件

您已经设计了函数openLink来实际打开特定的URL。您应该注意,当使用fopen时,它实际上表示打开磁盘上的文件。如果您传递像/或/filename.txt这样的值,它实际上将尝试以该绝对文件系统路径打开磁盘上的文件

根据您的问题数据,您告诉fopen打开/。这是服务器文件系统的根。您的用户肯定无法访问它,因此您会看到错误

如果你想打开你的网站的相对路径,考虑将站点URL预先预置到$->URL变量,然后将其传递给FOpenT,以指示你正在尝试打开URL。

您可以在以下行中执行某些操作:

function openLink(){
    $siteURL = "http://www.example.com";
    $urlToOpen = $siteURL . $this->URL;
    $this->fp = fopen($urlToOpen, "rb");
    array_shift($http_response_header);
    $this->headers = $http_response_header;
}

当发生错误时,您能否共享$this->URL的值?最有用的值是var_dump$this->URL的输出。您还应该检查一下。结果是string1/解决方案对您有效吗?如果是,考虑把它标记为答案和投票。