<?
@session_start();
//connection au serveur local
$cnx = mysql_connect("localhost", "root", "");
$db=mysql_select_db('timbres_ver2',$cnx);
//l'adresse de connexion
$_SESSION['adresse_site']="http://127.0.0.1/timbres VER2/";
$_SESSION['ip_visiteur']=$_SERVER['REMOTE_ADDR'];
?>
<?php
//======================== mise à jour des statistiques====================================
if(!isset($_SESSION['pseudo'])) $_SESSION['pseudo']="";
$pseu=$_SESSION['pseudo'];
//détection des robots et aspirateurs
//pour les robots
$UA=$_SERVER["HTTP_USER_AGENT"];
$brow = strtolower($UA);//en minuscules pour toutes les versions
$bots = array ("alexa","antibot","appie1.1","archive","ask","askjeeves","baiduspider","bspider","cfnetwork","converacrawler","custo","deepIndex","dloader","exabot","fast","fish search","fluffy","gaisbot","gigabot","girafabot","google","google adsence","googlebot","googlebot-image","grub.org","henrilerobotmirago","heritrix","holmes","httrack","ia_archiver","ichiro","inktomi slurp","iwp-trivial","java","larbin","mediapartners-google","mj12bot","msnbot","msnbot-media","msiecrawler","msrbot","netresearchserver","nimblecrawler","nutch","nutchcvs","openbot","openfind","picsearch","pompos","psbot","python-urllib","robozilla","sbider","seekbot","scooter","shinchakubin","slurp","speedy spider","spider","stackramber","surveybot","szukacz","tencentraveler","teoma","the web archive","turn it in","vagabondo","voila","voilabot","voyager","webcollage","webcrawler","xenu link sleuth","yacy","yandex","yahoo","yahoo!","yahoo-mmcrawler","yahooseeker","zyborg");//on ajoute ici les noms des autres robots en minuscules
$n=0;$robotstat="vide";$robot="";
do
{
$robot = strchr($brow,$bots[$n]);
if($robot<>"") $robotstat="robot";
$n=$n+1;
}while ((!$robot) && ($n<count($bots)));
//$date_robot=date("d-m-Y");
if($robot<>"")
{ $page_robot=0;$lig_robot=0;
$result = mysql_query("SELECT * FROM robot");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
if($robot==trim($row[4]))
{
$page_robot=$row[3];$lig_robot=$row[0];
}
}
if($page_robot>0)
{ $page_robot++;
$sql='REPLACE INTO robot VALUES ("'.$lig_robot.'","'.date("Y-m-d").'","'.$_SESSION['ip_visiteur'].'","'.$page_robot.'","'.$robot.'","x","x","x")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
if($page_robot==0)
{ $page_robot++;
$sql='INSERT INTO robot VALUES (" ","'.date("Y-m-d").'","'.$_SESSION['ip_visiteur'].'","'.$page_robot.'","'.$robot.'","x","x","x")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
}//fin de if robot<>""
//elimination des aspirateurs
$bots = array ("curl","^-?$ ","advanced\ email\ extractor","acrobat","almaden","@nonymouse","art-online","cherrypicker","crescent\ internet\ toolpack","directupdate","download\ accelerator","ecatch","extense","emailcollector","emailwolf","extractorpro","fetch","api request","flashget","frontpage","go!zilla","http agent","httpconnect","httrack","indy","library","ipiumbot laurion(dot)com","kapere","libwww-perl","microsoft control","minibot(naverrobot)","nicerspro","npbot","offline explorer","offline navigator","program shareware","quepasacreep","sitemapper","star downloader","surveybot","teleport pro","telesoft","turingos","turnitinbot","vobsub","webbandit","webcapture","webcollage","webcopier","webdav","webemailextractor","webreaper","websaver","webstripper","webzip","wget","wysigot","zeus.*webster","zeus","^xxx"); //on ajoute ici les noms des autres aspirateur en minuscules
$n=0;$aspirateur="vide";$aspi="";
do
{
$aspi = strchr($brow,$bots[$n]);
if($aspi<>"") $aspirateur="aspiOK";
$n=$n+1;
}while ((!$aspi) && ($n<count($bots)));
if($aspirateur=="aspiOK") header('location:'.$_SESSION["adresse_site"]."aspirateur.html");
//=================================================================================================================
$pseu=$_SESSION['pseudo'];
if($pseu<>"crepy" && $robotstat<>"robot")
{
// blocage des IP qui visite trop de pages
$Vcpt = 0;
$Vdate = date("Y/m/d H:i");
$Vua = $HTTP_SERVER_VARS["HTTP_USER_AGENT"];
$Vip = $HTTP_SERVER_VARS["REMOTE_ADDR"];
// clean up old IP
mysql_query("DELETE FROM ip WHERE date <> '$Vdate'");
// chercher si le visiteur est interdit
$jj=0;
$result = mysql_query("SELECT * FROM ip_bl");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{ if($row[2]==$Vip) $jj=1; }
// Visiteur trouvé dans les IP interdites
mysql_free_result($result);
if($jj==1) header('location:'.$_SESSION["adresse_site"]."aspirateur.html");
// chercher si le visiteur est déjà passé
$res = mysql_query("SELECT id, ip, date, cpt FROM ip WHERE ip='$Vip'");
while(list($id, $ip, $date, $cpt) = mysql_fetch_row($res)) $Vcpt = $cpt;
mysql_free_result($res);
if ($Vcpt == 0) mysql_query("INSERT into ip (id, ua, ip, date, cpt) values ('', '$Vua', '$Vip', '$Vdate', '1')");
else
{
// Visiteur ayant déjà chargé des pages dans la même minute ==> +1 sur le compteur
mysql_query("UPDATE ip SET cpt=cpt+1 WHERE ip='$Vip'");
// si limite atteinte (25 pages php/min) ajouter dans la table des ip interdites.
if ($Vcpt >= 35)
{
$jj=0;
$result = mysql_query("SELECT * FROM ip_bl");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{ if($row[2]==$Vip) $jj=1; }
mysql_free_result($result);
if($jj==0)
{
mysql_query("INSERT into ip_bl (id, ua, ip, date, cpt) values ('', '$Vua', '$Vip', '$Vdate', '$Vcpt')");
$msg = "HTTP_SERVER_VARS:\n<br><br>".$Vua ;
while (list ($key, $val) = each ($HTTP_SERVER_VARS)) $msg .= "$key => $val\n";
$msg = addslashes($msg);
eval("\$msg = \"$msg\";");
$msg = stripslashes($msg);
mail ("contac.web@laposte.net", "[IP Interdite] $Vip - $Vdate", $msg, "From: Timbres@france.com");
header('location:'.$_SESSION["adresse_site"]."aspirateur.html");
}
}
}
//========================mise à jour des stat=================================
//mise à zéro de la table IP et de la table VISITEUR en début de mois
if($s_mois<>$mois)
{
$sql='TRUNCATE table_ip' ; mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$sql='TRUNCATE visiteur' ; mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
//---------------------------------------------------------------------------------------------------
//lecture de la table des IP pour vérifier la presence ou non
$connu=0;
$result = mysql_query("SELECT * FROM table_ip");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
if($_SESSION['ip_visiteur']==trim($row[1]))
{
$connu=1; $ligip=$row[0];$pageip=$row[3]+1;
}
}
if($s_jour<>$jour)
{
$sql='TRUNCATE ip' ; mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$sql='TRUNCATE robot' ; mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$sql='TRUNCATE table_ip' ; mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$sql='INSERT INTO visiteur VALUES ("","'.$dat.'","1","1","0","0","0","'.$jour.'","x","'.$mois.'","'.$s_jour.'","x")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$result = mysql_query("SELECT * FROM enchere");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
if(trim($row[18])=="bl" && trim($row[3])<>"0000.gif") @unlink('../encheres/image-enchere/'.trim($row[3]));
}
//mise à jour de la table des records (pour le nombre de visiteurs)
$result = mysql_query("SELECT * FROM record");
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{$visiteur=$row[8];$page=$page+$row[11];}
$visiteur=$visiteur+$visite;
$sql = 'UPDATE record SET visiteur = "'.$visiteur.'" WHERE id = "1"';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$sql = 'UPDATE record SET pagetot = "'.$page.'" WHERE id = "1"';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
Function notag($txt) { // Vire les balises
// ^ signifie "tout sauf"
// + signifie 1 car au moins
$pattern = "<[^>]+>";
// remplace par vide
return(ereg_replace($pattern,":",$txt));
}
Function notlg($txt) { // Vire fin de ligne
// ^ signifie "tout sauf"
// + signifie 1 car au moins
$pattern = "\r\n";
// remplace par vide
return(ereg_replace($pattern,":",$txt));
}
$fp = fopen($_SESSION['chemin']."admi/fic_collec.txt", "w");
$result = mysql_query("SELECT * FROM collec");
$nb = mysql_num_rows ($result);$a=0;
while ($row = mysql_fetch_array($result, MYSQL_NUM))
{ $a++;$lig="";
$row[10] = notag($row[10]); $row[10] = notlg($row[10]);
$lig=implode("#",$row);
fwrite($fp,$lig);fwrite($fp,"\n");
}
mysql_free_result($result);
fclose($fp);
}// fin de if jour<>$$jour
if($s_jour==$jour)
{ $pageip=0;
if($connu==0)
{
$sql='INSERT INTO table_ip VALUES ("","'.$_SESSION['ip_visiteur'].'","'.$dat.'","'.$pageip.'","'.$UA.'")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$visite++;$page++;
$sql='REPLACE INTO visiteur VALUES ("'.$lig.'","'.$datevisite.'","'.$visite.'","'.$page.'","'.$inscrit.'","'.$eval.'","'.$payant.'","'.$jour.'","'.$memb.'","'.$mois.'","'.$jour_ancien.'","'.$mois_ancien.'")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
if($connu==1)
{
$page++;
$sql='REPLACE INTO visiteur VALUES ("'.$lig.'","'.$datevisite.'","'.$visite.'","'.$page.'","'.$inscrit.'","'.$eval.'","'.$payant.'","'.$jour.'","'.$memb.'","'.$mois.'","'.$jour_ancien.'","'.$mois_ancien.'")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
$sql='REPLACE INTO table_ip VALUES ("'.$ligip.'","'.$_SESSION['ip_visiteur'].'","'.$dat.'","'.$pageip.'","'.$UA.'")';
mysql_query($sql)or die ('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
} //fin de "if($s_jour==$jour)
} //fin de "if(pseu<>"crepy")
?>
Notice: Undefined variable: HTTP_SERVER_VARS in C:\Program Files\EasyPHP-5.3.1\www\timbres VER2\conex.php on line 88
Notice: Undefined variable: HTTP_SERVER_VARS in C:\Program Files\EasyPHP-5.3.1\www\timbres VER2\conex.php on line 89
Warning: mysql_query() [function.mysql-query]: Accès refusé pour l'utilisateur: 'Utilisateur_Culturel'@'@localhost' (mot de passe: NON) in C:\Program Files\EasyPHP-5.3.1\www\timbres VER2\conex.php on line 92