如果某人是从特定域引用的,如何显示特殊代码

发布于 2024-07-29 04:50:29 字数 265 浏览 4 评论 0原文

有人欺骗了我的网站(使用 .org 并放入流产胎儿的图片),而我无法将其删除。 但是这个白痴将所有链接保留在首页上,因此只要有人点击链接,他们就会从该网站转到我的网站。

我想向从该欺骗域引用的人显示一些代码,上面写着“注意:您来自我们网站的欺骗版本”。

最好的方法是什么? Google Analytics 已经能够检测到该 .org 的引用站点,但我不知道如何实现代码...

我的站点使用的是 WordPress 2.8,而且我对 PHP 相当了解。

Someone has spoofed my site (taking the .org and putting in pitures of aborted fetuses), and I'm unable to get it down. But the idiot kept all the links on the front page, so as soon as someone clicks a link, they're taken from that site to mine.

I want to display some code that says "NOTICE: YOU HAVE COME FROM A SPOOFED VERSION OF OUR SITE" to people who are referred from that spoofed domain.

What's the best way to do that? Google Analytics has been able to detect the referring site as that .org, but I don't know how to implement the code...

My site is on WordPress 2.8, and I'm fairly PHP knowledgable.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

甜扑 2024-08-05 04:50:29

您需要在您正在服务的页面中添加这些行

$referer=$_SERVER["HTTP_REFERER"];
if ($referer=='http://www.spoofed.org') echo 'spoofed!' // do something

you need to add these lines in the page you are serving

$referer=$_SERVER["HTTP_REFERER"];
if ($referer=='http://www.spoofed.org') echo 'spoofed!' // do something
花心好男孩 2024-08-05 04:50:29

引用者信息可通过 $_SERVER 获取 超全局。

一个简单的测试看看是否提到了域名您只需要一个 if 语句即可。

The referer information is available though the $_SERVER superglobal.

A simple test to see if the domain is mentioned wrapped in an if statement should be all you need.

少女的英雄梦 2024-08-05 04:50:29
if (isset($_SERVER['HTTP_REFERER'])) {
 if (preg_match('/^http(s)?:\/\/(www\.)?example.org/',$_SERVER['HTTP_REFERER'])) {
  print 'YOU HAVE ARRIVED FROM A KNOWN SPOOF SITE';
 }
}

此代码检查是否设置了引荐来源网址(如果访问者直接访问您的网站,则可能不会设置),然后检查引荐来源网址的开头是否与欺骗网站的 URL 匹配(允许欺骗网站)使用 http 或 https 以及使用或不使用 www。)。 仅检查引荐来源网址的开头意味着他们可以向其网站添加其他页面,但仍会检查欺骗行为。

if (isset($_SERVER['HTTP_REFERER'])) {
 if (preg_match('/^http(s)?:\/\/(www\.)?example.org/',$_SERVER['HTTP_REFERER'])) {
  print 'YOU HAVE ARRIVED FROM A KNOWN SPOOF SITE';
 }
}

This code checks to see if the referer is set (if the visitor is coming directly to your site, it may not be set) and then it checks if the start of the referer matches the URL of the spoof site (allowing for the spoof site to use http or https and to use or not use www.). Checking just the start of the referer means that they can add additional pages to their site, but it will still check for spoofing.

慵挽 2024-08-05 04:50:29

您可以查看 HTTP_REFERER 变量的内部 http://en.wikipedia.org/wiki/HTTP_referrer< /a>

请注意,某些反恶意软件会隐藏此变量以避免用户跟踪。

You can take a look inside the HTTP_REFERER variable, http://en.wikipedia.org/wiki/HTTP_referrer

Be warned, some antimalware software hides this variable to avoid user tracking.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文