<?php
include("../config.php3");
include($BIB."bib_generic.php3");


if(strlen($email)<=0 || $email=="__EMAIL__")
	$email = "NON DEFINI";
else
	$email = strtolower($email);

if(isset($code))
{
	$TABID = explode("_",$code);
	$Id = $TABID[1];
	
	//on ajoute 1 au total pour cet id
	main_db_query("UPDATE Tracking SET Nb = Nb + 1 WHERE Id = '".$Id."'");
	
	if(!isset($email) || $email=="__EMAIL__")
		$email = "NON DEFINI";
	
	$row = db_fetch_assoc(main_db_query("SELECT * FROM Tracking_Email WHERE TrackId = '".$Id."' AND Email = '".$email."' "));
	//si on a deja des clics pour ce mail et cet id on incremente
	if($row["Id"] > 0)
	{
		main_db_query("UPDATE Tracking_Email SET Nb = Nb + 1 WHERE Id = '".$row["Id"]."'");
	}
	//sinon on ajoute un entrée à 1
	else
	{
		main_db_query("INSERT INTO Tracking_Email (Email,TrackId,Nb) VALUES ('".$email."','".$Id."',1)");
	}
}

readfile("x.gif");
?>