[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 02-12-2008, 04:09 AM   #1 (permalink)
Senior Member
 
Join Date: Aug 2007
Posts: 2,167
457.00 NP$ (Donate)

jido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond repute


Referer check for click validation

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 Code:
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?
__________________
______________________________________
Time After Leisure & Events discussions
eBay auction aqnu, pzpy, vqqr.com 16 llll.com start $.95
_______________ f o r . s a l e ______________
jido is offline  
Old 02-12-2008, 04:55 AM   #2 (permalink)
i love automation
 
xrvel's Avatar
 
Join Date: Nov 2007
Posts: 1,409
987.78 NP$ (Donate)

xrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud of


What about this ? Add an "i" in preg_match.:
PHP Code:
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?
xrvel is offline  
Old 02-12-2008, 05:02 AM   #3 (permalink)
Senior Member
 
Join Date: Aug 2007
Posts: 2,167
457.00 NP$ (Donate)

jido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond reputejido has a reputation beyond repute


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
__________________
______________________________________
Time After Leisure & Events discussions
eBay auction aqnu, pzpy, vqqr.com 16 llll.com start $.95
_______________ f o r . s a l e ______________
jido is offline  
Old 02-12-2008, 05:25 AM   #4 (permalink)
i love automation
 
xrvel's Avatar
 
Join Date: Nov 2007
Posts: 1,409
987.78 NP$ (Donate)

xrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud ofxrvel has much to be proud of


Other method you can use is creating a link with unique id.

Preparing the functions...
PHP Code:
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 Code:
$now = time();
$hashed = mycrypt($now);
$link = '?redirect=http://google.com&amp;stamp=' . $now . '&amp;hash='. $hashed;

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

Checking the clicks
PHP Code:
if (! is_valid_click()) {
   echo(
'Do not click this link from any website but nestimates.com');
} else {
   
// redirect here
}
xrvel is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 08:59 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85