PHP Code:
//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.