<?PHP
/********************/
/* Gestion des logs */
/********************/

// Archivage du log courant

function Archivelog($code_session)
{
	global
		$racine_web;
		
	if ($code_session == "") // Test si pas encore connecté
		$code_session = "?";
	$datecourante = date("Y-m-d");
	$heurecourante = date("H:i:s");
	$urlpr = $_SERVER['HTTP_REFERER'];
	$racinesrv = $racine_web;
	$urlprecedent = ereg_replace($racinesrv,"",$urlpr); // "Nettoyage" si on était en domaine principal
	$urlcourant = $_SERVER['REQUEST_URI'];
	
	$log_ip = $_SERVER['REMOTE_ADDR']; // Récupération adresse IP

	$conn2 = mysql_connect(DBHOST, DBUSER, DBPASS);
	mysql_select_db(DBNAME);
	$rechlog  = "INSERT INTO " .TBLOG;
	$rechlog .= " (log_code,log_date,log_heure,log_urlprec,log_url,log_ip) VALUES";
	$rechlog .= " ('$code_session','$datecourante','$heurecourante','$urlprecedent','$urlcourant','$log_ip')";
	$rslog = mysql_query($rechlog) or die(mysql_error());
	mysql_close($conn2);

}

?>