哪个域调用了该脚本?
我有一些确实需要保护的脚本。所以我在想,有没有办法找出哪个域调用了脚本?
I have some scripts that really need to be secured. So I was thinking, is there a way to find out which domain called the script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
查看
$_SERVER
变量,您会发现将看到您需要的所有信息。$_SERVER['SERVER_ADDR']
和$_SERVER['SERVER_NAME']
可能对您有用。Look through the
$_SERVER
variable and you will see all the information you need.$_SERVER['SERVER_ADDR']
and$_SERVER['SERVER_NAME']
may be of use to you.$_SERVER['HTTP_HOST']
将拥有域名。$_SERVER['HTTP_HOST']
will have the domain name.可能有很多方法可以做到这一点..但我会在脚本中设置日志记录并报告
,这里是一个有用的页面以获取更多信息..
http://www.php.net/manual/en/reserved.variables.server.php
There are probably a lot of ways to do this.. But I would setup logging in the script and report back with
And here is a helpful page for more information..
http://www.php.net/manual/en/reserved.variables.server.php
维基百科列出了许多针对跨站点请求伪造攻击的防御措施。
Wikipedia lists a number of defences against cross site request forgery attacks.
$_SERVER['SERVER_NAME']
将包含运行脚本的主机或虚拟主机。$_SERVER['HTTP_HOST']
包含当前请求的 Host: 标头的内容(如果有)。请参阅 Chris Shiflett 的扩展解释,了解详细比较两个。
$_SERVER['SERVER_NAME']
will contain the host or virtual host under which the script is running.$_SERVER['HTTP_HOST']
contains the contents of the Host: header from the current request, if there is one.Please see Chris Shiflett's extended explanation for a detailed comparison of the two.