<?php
  if (!isset($res)) $res='';  if (!isset($ntof)) $ntof='0';  if (isset($_SERVER['REMOTE_ADDR'])) $hostname=gethostbyaddr( $_SERVER['REMOTE_ADDR']); else $hostname='';  if (isset($_SERVER['HTTP_USER_AGENT'])) $agent=$_SERVER['HTTP_USER_AGENT']; else $agent='';  if ( isset($_SESSION['SESS_REFERER_BASE']) && ($_SESSION['SESS_REFERER_BASE'] != "")) { $referer = $_SESSION['SESS_REFERER_BASE']; }  else if ( isset($_SERVER['HTTP_REFERER'])) $referer= $_SERVER['HTTP_REFERER']; else $referer= '';  $ip=get_IP();   $i=0; $tab_robots = array ("googlebot","inktomi","webcrawler","dir.com","MSNBOT","crawler","ASPseek","DeepIndex","ultraseek","Lycos_Spider","scooter","VoilaBot","SurferF3","linkwalker");  $robotName="";  $strRobot=trim($agent.$hostname);  while( $i < sizeof($tab_robots)) { if (eregi($tab_robots[$i], $strRobot)) { $loginStat='robot'; $robotName=$tab_robots[$i]; break; } $i++;  }   if ($loginStat!='robot') { if (!eregi($agent, "Mozilla")) {  $tab_aspi = array ("MSIECrawler","Email","almaden","CherryPicker","Crescent","ExtractorPro","cs02.crawlspace","DirectUpdate","eCatch","flashget","Go!Zilla","HTTPConnect","HTTrack","Indy Library","IPiumBot","Kapere","NaverRobot","MSFrontPage","My User Agent","NICErsPRO","NPBot","Program Shareware","Teleport","Telesoft","TuringOS","TurnitinBot","vobsub","WebBandit","WebCapture","WebCopier","WebDAV","WebReaper","WEBsaver","WebStripper","WebZIP","Wget","WinMHT","Wysigot","Zeus"); $j=0;  while( $j < sizeof($tab_aspi)) { if (eregi($tab_aspi[$j], $agent)) {  $aspi='1'; $loginStat='aspi'; break; } $j++;  } }else $loginStat=$login;   }   if (  $loginStat!='robot' ) { $querySelect = "UPDATE participants SET nbConnexion=(nbConnexion+1),derniereConnexion=NOW() WHERE nom LIKE '$login' LIMIT 1"; $resultSelect = mysql_query ($querySelect) or die ("La requête d'incrémentation a échoué");  if ($referer!='' && eregi("^http://".$_SERVER['HTTP_HOST'], $referer) ) $referer='';  $queryVisit = "SELECT nbvisit from visiteurs where login='$loginStat' AND agent='".$agent."' AND referer='$referer' AND hostname='$hostname'" ; $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."',idphoto='".$ntof."',resolution='$res' where login='$loginStat' AND agent='".$agent."' AND referer='$referer' AND hostname='$hostname' LIMIT 1"; else $queryInsert = "INSERT INTO visiteurs(`login`,`idphoto`,`date`, `ip`, `hostname`, `agent`, `referer`,`resolution`) VALUES ('$loginStat','$ntof',NOW(),'$ip','$hostname','".$agent."','$referer','$res');";  $resultInsert = mysql_query ($queryInsert) or die ("La requête stats techniques a échoué");  } else {  $queryVisit = "SELECT nbvisit from visiteurs where login='robot' AND idphoto='$ntof' 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='$ntof' 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','$ntof',NOW(),'$ip','$hostname','".$agent."','$referer','$res');";   $resultInsert = mysql_query ($queryInsert) or die ("La requête stats techniques a échoué"); }   mysql_free_result($resultVisit); ?> 