tags:

views:

70

answers:

4

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.

+2  A: 

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
dusoft
sidenote: $_SERVER['http_referer'] is not always set and can not be trusted.
Philippe Gerber
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.

m.bagattini
A: 

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.

David Dorward
A: 
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.

Richy C.