包括远程php文件作为资源 [英] Including a remote php file as a resource

查看:112
本文介绍了包括远程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

我也收到一条消息说:


无法打开流:没有找到合适的包装器,等等等等。

failed to open stream: no suitable wrapper could be found in blah blah blah

我试图获得相同结果的seconed方式是使用fopen但我只是获取文件的内容,这不是我需要的东西我需要我的本地脚本来查看远程脚本作为executabel rescource。

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;

我必须做错事吗?我知道回应varbel $ 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中的 allow_url_include 设置.ini设置为关闭。启用该选项将允许您进行远程文件包含,但要非常小心,因为一旦其他站点遭到入侵(黑客可以轻松地将自己的远程代码注入您的站点),这是一个相当大的安全风险。

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).

这篇关于包括远程php文件作为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆