<?php
 $hostname = gethostbyaddr( $_SERVER['REMOTE_ADDR']); if (isset($_SERVER['HTTP_REFERER'])) $referer= $_SERVER['HTTP_REFERER']; else 	$referer='';  $robotName=""; $i=0; $tab_robots = array ("googlebot","webcrawler","dir.com","MSNBOT","crawler","ASPseek","DeepIndex","ultraseek","Lycos_Spider","scooter","VoilaBot","SurferF3","linkwalker");  $strRobot=$_SERVER['HTTP_USER_AGENT'].$hostname; while( $i < sizeof($tab_robots)) { if (eregi($tab_robots[$i], $strRobot)) { $robot=1; $robotName=$tab_robots[$i]; break; } $i++;  } if (isset($robot)) {	$loginStat='robot';   $ip=get_IP(); $agent=$_SERVER['HTTP_USER_AGENT'];   $queryVisit = "SELECT nbvisit from visiteurs where login='$loginStat' AND agent='$agent' AND resolution='' AND referer='$referer' AND idphoto='0'"; $resultVisit = mysql_query ($queryVisit) or die ("La requête a échoué :".$queryVisit);  $nbVisit = mysql_fetch_row($resultVisit); if ($nbVisit=="") $queryInsert = "INSERT INTO visiteurs(`login`,`idphoto`,`date`, `ip`, `hostname`, `agent`, `referer`,`resolution`) VALUES ('$loginStat','0',NOW(),'$ip','$hostname','$agent','$referer','');"; else{ $queryInsert = "UPDATE visiteurs SET nbvisit=(nbvisit+1),date=now(),ip='$ip' where login='$loginStat' AND agent='$agent' AND referer='$referer' AND idphoto='0'  LIMIT 1"; }  $resultInsert = mysql_query ($queryInsert) or die ("La requête stats robot accueil a échouée");  $queryVisit = "SELECT nbvisit from visiteurs where login='robot' AND idphoto='0' AND ( agent LIKE '%".$robotName."%' OR hostname LIKE '%".$robotName."%' )" ;  $resultVisit = mysql_query ($queryVisit) or die ("La requête a échoué :".$queryVisit);  if (mysql_num_rows($resultVisit) > 0) $queryInsert = "UPDATE visiteurs SET nbvisit=(nbvisit+1),date=now(),ip='".$ip."',agent='".$agent."',referer='".$referer."',hostname='".$hostname."' where login='robot' AND idphoto='0' AND ( agent LIKE '%".$robotName."%' OR hostname LIKE '%".$robotName."%' ) LIMIT 1" ; else $queryInsert = "INSERT INTO visiteurs(`login`,`idphoto`,`date`, `ip`, `hostname`, `agent`, `referer`,`resolution`) VALUES ('robot','0',NOW(),'$ip','$hostname','".$agent."','$referer','');";   $resultInsert = mysql_query ($queryInsert) or die ("La requête stats techniques a échoué");  mysql_free_result($resultVisit); } ?> 