PDA

View Full Version : Top Referrers Script


spacemanspiff
10-24-2003, 12:23 PM
I'm looking for a good way to add a "top referrers" section to a page. I'd don't want to have to use referrer codes, I would like to be able to exclude url's like search engines and such, and no sign up necessity would be great. ie. "just send hits to bla-bla.com and you'll be ranked in the top referrers section." If it could reset every 24 hours, without me having to get into anything dangerous like cron, that would be awesome

Thanks
SS

MrMaryLou
10-24-2003, 12:28 PM
This one Kicks Ass :) http://www.cgiman.com/autorefs.shtml

BNS
11-03-2003, 05:42 PM
does anyone know if there is any free script similar to autorefs?
i need it for something relatively small to spend $300 on it.
|peace|

Auke
11-15-2003, 10:17 AM
//check if it is the first of the month.
//if so reset counter
$datum = date("Y-m-d H:i:s");
$lastmonth = date("m")-1;
$thisyear = date("Y");

$getsites = mysql_query("SELECT * FROM pages WHERE hitsin > '0' AND lasthit LIKE '$thisyear-0$lastmonth-%' LIMIT 1")or die(mysql_error());
$count_site = mysql_num_rows($getsites);
if($count_site == 1){//count
$allsites = mysql_query("SELECT * FROM pages")or die(mysql_error());
while($rowall = mysql_fetch_array($allsites)){//while
mysql_query("UPDATE pages SET hitsin = '0', lasthit WHERE accepted = 'y'")or die(mysql_error());
}//while
}//count

//register referer and ip adres
$refip = getenv ("REMOTE_ADDR");
$referer = getenv("HTTP_REFERER");
$c_url = mysql_query("SELECT hitsin, lastip, lasthit FROM pages WHERE url = '$referer%'")or die("er is iets mis: ".mysql_error());
$tell = mysql_num_rows($c_url);
if($tell == 1){
$row = mysql_fetch_array($c_url);
$lastip = $row['lastip'];
$hitsnu = $row['hitsin'];
if($lastip == $refip){
$histnew = $hitsnu;
}else{
$hitsnew = $hitsnu + 1;
}
$update_site = mysql_query("UPDATE pages SET hitsin = '$hitsnew', lastip = '$refip', lasthit = '$datum' WHERE url = '$referer%' ")or die("er is iets mis: ".mysql_error());
}


This is a peace of a script i wrote and use to registrer referers.
If you can do a little of php scripting you can ajust it to your needs.

BNS
11-15-2003, 01:52 PM
Hi,

thanx for script:)

if i am not asking too much, can you please give some example how exactly to use it? i see it has mysql queries, but where does it connect to db and for instance how does the output html look like?

tia,
BNS