包含一个远程 php 文件作为资源
我正在尝试将远程 php 文件作为资源包含在内,但我遇到了一些麻烦.我进入 php.ini
文件并将 allow_url_fopen
设置为 ON
.我还查找了设置 allow_url_include
但它不在文件中,我将其添加到 php.ini 文件并将其设置为 on.
I am trying to include remote php files as a resource but I am having a bit of trouble. I went into the php.ini
files and set allow_url_fopen
to ON
. I also looked for the setting allow_url_include
but it was not in the file, I added it to the php.ini file and also set that to on.
如果我尝试包含使用
include ('http://somewebsite.com/lib/somescript.php');
服务器/php 吐出一条消息说:
The server / php spits out a message saying:
在服务器配置中禁用 URL 文件访问
URL file-access is disabled in the server configuration
我还收到一条消息:
打开流失败:在 blah blah blah 中找不到合适的包装器
failed to open stream: no suitable wrapper could be found in blah blah blah
我尝试实现相同结果的第二种方法是使用 fopen,但我只是获取文件的内容,这不是我需要的,我需要本地脚本才能将远程脚本视为可执行文件资源.
The seconed way I am trying to acomplish the same result is using fopen but I am just getting the content of the file, thats not what I need I need my local script to see the remote script as an executabel rescource.
$myscript = fopen("http://someotherwebsite/lib/my_script.php", "r");
$incmyscript= fread($myscript , 9999);
fclose($myscript);
// include in the contents of my_script.php
echo $incmyscript;
我一定是做错了什么?我知道回显变量 $incmyscript 是错误的,但我想不出一种方法来放置代码.我不确定 fopen 是否是获得我想要的东西的最佳方式.
I have to be doing something wrong? I know echoing out the variabel $incmyscript is wrong, but I can't think of a way to place in the code. I am not sure if fopen is the best best way to get what I want.
有什么想法吗?
推荐答案
你得到的消息:
URL file-access is disabled in the server configuration
表示您的 php.ini 中的 allow_url_include
设置设置为 Off.启用该选项将允许您执行远程文件包含,但要非常小心,因为一旦其他站点受到威胁(黑客可以轻松地将他们自己的远程代码注入您的站点),这将带来相当大的安全风险.
Indicates that the allow_url_include
setting in your php.ini is set to Off. Enabling that option will allow you to do remote file inclusion, but be very careful with this as it's a pretty big security risk once the other site would be compromised (A hacker could easily inject their own remote code to your site).
相关文章