<?php
error_reporting(0);

$queryPurg = "SELECT count(*) FROM visiteurs where login!='robot'"; 
$resultPurg = mysql_query ($queryPurg) or die ("La requête de sélection des lignes a échoué"); 
$linePurg = mysql_fetch_row($resultPurg);
if(is_array($linePurg) && $linePurg[0]>3000){


$queryPurg = "delete FROM `visiteurs` where `login`='robot' ORDER BY `date` ASC LIMIT 1000;";
$resultPurg = mysql_query ($queryPurg) or die ("La requête a échoué :".$queryPurg);
$queryPurg = "delete FROM `visiteurs` where `login`='public' ORDER BY `date` ASC LIMIT 300;";
$resultPurg = mysql_query ($queryPurg) or die ("La requête a échoué :".$queryPurg);


}
mysql_free_result($resultPurg);

$queryClick = "SELECT nbclick from statclick where login='$Ulogin' AND nom='$nom' AND repertoire='$repertoire'";

$resultClick = mysql_query ($queryClick) or die ("La requête a échoué :".$queryClick);
$nbclick = mysql_fetch_row($resultClick);
if ($nbclick=="") 
	$queryInsert = "INSERT INTO statclick(`nom`,`login`,`repertoire`,`date`,`nbclick`) VALUES ('$nom','$Ulogin','$repertoire',NOW(),1);";
else{ 
	$queryInsert = "UPDATE statclick SET nbclick=(nbclick+1),date=now() WHERE login='$Ulogin' AND nom='$nom' AND repertoire='$repertoire' LIMIT 1";

}  

$resultInsert = mysql_query ($queryInsert) or die ("La requête a échoué :".$queryInsert);

 mysql_free_result($resultClick);

?> 