Unstoppable Domains

Referer check for click validation

Spaceship Spaceship
Watch

jido

VIP Member
Impact
61
Hi

I have the following snippet in my script as a simple fraud prevention device, to avoid counting clicks that do not originate from the same website. What are your comments on it?

PHP:
function check_referer()
{
	$ref = $_SERVER['HTTP_REFERER'];
	$domain = $_SERVER['SERVER_NAME'];
	return (preg_match("/^http:\/\/$domain/", $ref) == 1);
}

I suspect that some browsers do not provide the HTTP_REFERER header, which causes clicks to be ignored when they could be counted. On the other hand quite a few of the clicks seem to come from same domain IPs, so the device may fulfill its function well enough.

Do you use anything similar on your site?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
What about this ? Add an "i" in preg_match.:
PHP:
function check_referer() {
    $ref = $_SERVER['HTTP_REFERER'];
    $domain = $_SERVER['SERVER_NAME'];
    return (preg_match("/^http:\/\/$domain/i", $ref) == 1);
}

Btw, what kind of website it is? :)
 
0
•••
Thanks, I added your suggestion.

Nothing exciting it is a site listing for online estimates: http://nestimates.com
Good experimental ground for some of my ideas though :)
 
0
•••
Other method you can use is creating a link with unique id.

Preparing the functions...
PHP:
function is_valid_click() {
   if (!isset($_GET['stamp'])) {
      return(false);
   }
   if (!isset($_GET['hash'])) {
      return(false);
   }
   $stamp = $_GET['stamp'];// time stamp
   $hash = $_GET['hash'];// hashed time stamp
   if ($stamp < time() - 3600) {// old link
      return(false);
   }
   return( ($hash == mycrypt($stamp)) );// check hash
}

function mycrypt($s) {
  return(md5('unique' . $s . 'id'));
}

Generate the link
PHP:
$now = time();
$hashed = mycrypt($now);
$link = '?redirect=http://google.com&stamp=' . $now . '&hash='. $hashed;

echo("<a href=\"$link\" > click </a>");


Checking the clicks
PHP:
if (! is_valid_click()) {
   echo('Do not click this link from any website but nestimates.com');
} else {
   // redirect here
}
 
0
•••
Appraise.net

We're social

Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back