在 php 文件中包含一个网站
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3224648/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
include a website in php file
提问by Scorpion King
Hi i am trying to include a webpage link from another website into my website. how can i do this?
嗨,我正在尝试将来自另一个网站的网页链接包含到我的网站中。我怎样才能做到这一点?
i tried
我试过
<?php web_include ('http://website.com/website.html') ; ?>but all the commands are not loading after this statement. I want to include another webpage into my homepage directly. my homepage is completely designed in php, but the other one is html or php.
<?php web_include ('http://website.com/website.html') ; ?>但是在此语句之后所有命令都没有加载。我想直接在我的主页中包含另一个网页。我的主页完全是用 php 设计的,但另一个是 html 或 php。
i also tried <?php include("http://www.othersite.com/filename.html"); ?>but this html is not at all loading.
我也试过,<?php include("http://www.othersite.com/filename.html"); ?>但这个 html 根本没有加载。
Possible Solution:ok this is what i am using
可能的解决方案:好的,这就是我正在使用的
<iframe name="FRAMENAME" src="http://website.com/dropdown.html" width="1000" style="z-index:10000" height="40" frameborder="0" scrolling="no" allowautotransparency=true></iframe>
<iframe name="FRAMENAME" src="http://website.com/dropdown.html" width="1000" style="z-index:10000" height="40" frameborder="0" scrolling="no" allowautotransparency=true></iframe>
I am just including a dropdown menu for my index page. The CMS of the my site is restricting me from viewing the dorpdown in IE. When i view the dropdown.html page, i can see the dropdown, so I am trying to use iframe. Now using the iframe i can see the dropdown in IE as well, but the dropdown is not showing on the top. It is showing behind the other images on the site. How do i get it on top of the other images. z-index is not working for this.
我只是为我的索引页面添加了一个下拉菜单。我网站的 CMS 限制我在 IE 中查看 dorpdown。当我查看 dropdown.html 页面时,我可以看到下拉列表,所以我正在尝试使用 iframe。现在使用 iframe 我也可以在 IE 中看到下拉列表,但是下拉列表没有显示在顶部。它显示在网站上的其他图像后面。我如何将它放在其他图像之上。z-index 对此不起作用。
回答by rook
This code requires allow_url_include=Onin your php.ini, which is disabled by default because it's REMOTE CODE EXECUTION, one of the worst you can have in PHP. This is called the Remote File Include (RFI)vulnerability. If there is PHP code on this site it will be executed on your server.
此代码需要allow_url_include=On在您的 php.ini 中,默认情况下是禁用的,因为它是REMOTE CODE EXECUTION,这是您在 PHP 中可以拥有的最糟糕的代码之一。这称为远程文件包含 (RFI)漏洞。如果此站点上有 PHP 代码,它将在您的服务器上执行。
Extremely insecure:
极度不安全:
<?php include("http://www.othersite.com/filename.html"); ?>
What you probably want is:
你可能想要的是:
<?php print file_get_contents("http://www.othersite.com/filename.html"); ?>
However, this is technically an XSS vulnerability. So, if you trust the website there isn't a problem. But you probably want to run Html Puriferbefore printing it out.
然而,这在技术上是一个 XSS 漏洞。因此,如果您信任该网站,则没有问题。但是您可能想在打印出来之前运行Html Purifer。
回答by Kzqai
Just a basic recommendation, but it sounds like you're trying to debug complex functionality within a complex environment, which will only make it harder.
只是一个基本的建议,但听起来您正在尝试在复杂的环境中调试复杂的功能,这只会让它变得更加困难。
Debugging is easier if you break it down into component steps. In this case, I recommend:
如果将其分解为组件步骤,则调试会更容易。在这种情况下,我建议:
Display the iframe on a blank html page. Make sure everything works in that simple case.
在空白的 html 页面上显示 iframe。确保在这个简单的情况下一切正常。
Display on the more complex page.
显示在更复杂的页面上。
If it's still not working, comment out the javascript on the complex page to determine if that is causing the adverse interaction with the iframe page's javascript.
如果它仍然不起作用,请注释掉复杂页面上的 javascript,以确定这是否会导致与 iframe 页面的 javascript 发生不利交互。
Going through the debuggging stepwise like that should simplify the process.
像这样逐步调试应该可以简化这个过程。

