我收到错误
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文件在这里 - > http://spaceranger2.elitno.net/phpinfo.php
发生错误的行在这里:
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 internal error
的任何建议吗?
答案 0 :(得分:0)
通常fopen
只允许打开运行脚本的用户可以访问的文件。
您已将函数openLink()
设计为实际打开特定网址。您应该注意,使用fopen
时,它实际上表示在磁盘上打开文件。如果您传递/
或/filename.txt
之类的值,它实际上会尝试在该绝对文件系统路径上打开磁盘上的文件。
从您的问题数据中,您要告诉fopen
打开/
。这是服务器文件系统的根。您的用户肯定无法访问它(因此您看到错误)。
如果要打开网站的相对路径,请考虑将网站网址添加到$this->URL
变量前面,然后再将其传递给fopen
,以表明您正在尝试打开网址。
您可以执行以下操作:
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;
}