<?PHP
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.6
Copyright (C) 2006  Sylvain FATOME

This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr
****************************************************************************************/

/********************/
/* 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);

}

?>