View Single Post
Old 2003-11-15, 10:17 AM   #4
Auke
Aw, Dad, you've done a lot of great things, but you're a very old man, and old people are useless
 
Auke's Avatar
 
Join Date: Nov 2003
Location: Netherlands
Posts: 28
Send a message via ICQ to Auke
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.
__________________
Respect,
Auke

ICQ:325256616
Auke is offline   Reply With Quote