Including a remote php file as a resource(包含一个远程 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).
这篇关于包含一个远程 php 文件作为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:包含一个远程 php 文件作为资源


基础教程推荐
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01