【问题标题】:How can an embedded website tell who is embedding it?嵌入式网站如何分辨谁在嵌入它?
【发布时间】:2019-03-01 20:56:58
【问题描述】:

我有一个简单的 HTML 网站www.some_website.com。 在index.html 页面上,我从外部源嵌入了一个名为embedded_site.php 的外部php 脚本。

我正在使用<embed>标签将php脚本嵌入到网站中。

<body>
  <div style="width:100%; text-align:center;">  
      <embed type="text/html" src="https://myotherwebsite.com/embedded_site.php">
  </div>
</body>

embedded_site.php 如何检测哪个网站正在嵌入它?

+---------------------------------+
|      www.some_website.com       |
|   +-------------------------+   |
|   | embedded_site.php       |   |
|   | detected: embedded by   |   |
|   | some_website.com!       |   |
|   +-------------------------+   |
|                                 |
+---------------------------------+ 

我在embedded_site.php试过:

<?php echo($_SERVER['REMOTE_ADDR']);?> 

但这给了我客户端的 IP,而不是 嵌入 站点 www.some_website.com

预期目的

如果embedded_site.php 脚本嵌入了错误的站点,它需要能够检测到并自行禁用。

【问题讨论】:

标签: php html embed


【解决方案1】:

这个呢:

$_SERVER['REQUEST_URI'] 

而不是

$_SERVER['REMOTE_ADDR']

【讨论】:

  • 这将返回“/php/embedded_link.php”,但我需要嵌入页面的网站的网址
猜你喜欢
  • 2013-04-12
  • 1970-01-01
  • 2011-01-11
  • 2013-12-09
  • 2015-10-15
  • 2017-07-31
  • 2015-04-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多