<?php 
####################################################
/*
on va supprimer les guests dont le Member=1 (ie qui ont sensé été transformé en joueur)
pour lesquels il n'y a plus de member en bdd
*/
####################################################
include("../config.php3");
include($BIB."bib_generic.php3");

set_time_limit($TIME_LIMIT);
?>
<html>
<head></head>
<link rel="stylesheet" href="admin.css">
<body rightmargin=0>
<div align=center class=trTitle>Suppression des Guests fantôme !</div>
<br>
<?php

# récup des Guests dont le Member=1
$rows = main_db_query("SELECT * FROM Guests WHERE Member=1");
$nb = 0;
while($row=db_fetch_array($rows))
{
	# on vérifie s'il existe dans la table Members
	$rowMember = db_fetch_array(main_db_query("SELECT COUNT(*) AS total FROM Members WHERE Email='".$row['Email']."'"));
	if ($rowMember['total'] > 1)
	{
		echo "<br>Il y a ".$rowMember['total']." members pour le guest : ".$row['Email'];
	}
	elseif ($rowMember['total'] == 0)
	{
		echo "<br>DELETE FROM Guests WHERE Id='".$row['Id']."'";
		main_db_query("DELETE FROM Guests WHERE Id='".$row['Id']."'");
		$nb++;
	}
}

echo "<hr>".$nb." guests supprimé";