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


# la seconde base (pour les JO et le KTF)
$DATABASES[0] = array(# Host for the database
		  "host" => "localhost",
		  # Login for the database connection
		  "login" => "euro_turf",
		  # Password for the database connection
		  "password" => "6gfjM",
		  # Name of the main database
//		  "main_name" => "euro_turf_test",
		  # Name of the session database
//		  "session_name" => "euro_turf_test");

		  "main_name" => "euro_turf",
		  # Name of the session database
		  "session_name" => "euro_turf");

$DATABASE_NAMES[0] = "Lottoturf";

# La base du jeu
$DATABASES[1] = array(# Host for the database
		  "host" => "localhost",
		  # Login for the database connection
		  "login" => "rtl_qod",
		  # Password for the database connection
		  "password" => "jpf4M",
		  # Name of the main database
		  "main_name" => "rtl_qod",
		  # Name of the session database
		  "session_name" => "rtl_qod");

$DATABASE_NAMES[1] = "Quitte ou Double payant";

$DATABASES[2] = array(# Host for the database
		  "host" => "localhost",
		  # Login for the database connection
		  "login" => "rtl_qod",
		  # Password for the database connection
		  "password" => "jpf4M",
		  # Name of the main database
		  "main_name" => "rtl_qod_gratuit",
		  # Name of the session database
		  "session_name" => "rtl_qod_gratuit");

$DATABASE_NAMES[2] = "Quitte ou Double gratuit";

# La base centrale
$DATABASES[3] = array(# Host for the database
		  "host" => "localhost",
		  # Login for the database connection
		  "login" => "rtl_qod",
		  # Password for the database connection
		  "password" => "jpf4M",
		  # Name of the main database
		  "main_name" => "rtl_main",
		  # Name of the session database
		  "session_name" => "rtl_main");

$DATABASE_NAMES[3] = "Ensemble du Quitte ou Double";

# Database information
$DATABASES[4] = array(# Host for the database
		  "host" => "localhost",
		  # Login for the database connection
		  "login" => "viral_ktf",
		  # Password for the database connection
		  "password" => "ktflove",
		  # Name of the main database
		  "main_name" => "kestufoot_v2",
		  # Name of the session database
		  "session_name" => "kestufoot_v2");

$DATABASE_NAMES[4] = "Kestufoot";

# La base du jeu
$DATABASES[5] = array(# Host for the database
		  "host" => "localhost",
		  # Login for the database connection
		  "login" => "m6_quiz",
		  # Password for the database connection
		  "password" => "sok3d",
		  # Name of the main database
		  "main_name" => "m6_quiz",
		  # Name of the session database
		  "session_name" => "m6_quiz");

$DATABASE_NAMES[4] = "M6quiz 2.0";


function nb_emails_communs($sourceId, $targetId)
{
	global $DATABASES, $DATABASE_NAMES;

	switchBase($DATABASES[$sourceId]);
	$source_emails = mysql_query("SELECT Email FROM Members");
	echo "Nb de joueurs dans la base ".$DATABASE_NAMES[$sourceId]." : ".db_num_rows($source_emails)."<br>";

	switchBase($DATABASES[$targetId]);
	echo "Nb de joueurs dans la base ".$DATABASE_NAMES[$targetId]." : ".db_num_rows(mysql_query("SELECT Email FROM Members"))."<br>";

	$count = 0;
	while ($source_email = db_fetch_array($$source_emails))
	{
		$target_email = db_fetch_array(mysql_query("SELECT Id, NickName FROM Members WHERE Email='".$email."'"));
		if ($target_email['Id']>0)
		{
			$count++;
			echo ".";
			flush();
	}

	echo "Nombre de joueurs avec le même mail : ".$count."<br>";
}

if ($submit == "Valider")
{
	if (!($cible >= 0))
		echo "il faut choisir la cible<br>";
	if (!($source >= 0))
		echo "il faut choisir la source<br>";
	
	if (($cible >= 0) && ($source >= 0))
	{
		nb_emails_communs($source, $cible);
	}
}


?>
<html>
<head></head>
<link rel="stylesheet" href="admin.css">
<body rightmargin=0>
<div align=center class=trTitle>Croisement de bases</div>
<br>

Choisissez 2 bases :
<form method="post" ENCTYPE="multipart/form-data" action="<?php echo $form_action ?>" name="main">
<select name="source">
<?php
for ($i = 0 ; $i < count($DATABASE_NAMES) ; $i++)
{
	echo "<option value=\"".$i."\">".$DATABASE_NAMES[$i]."</option><br>";
}
?>
</select>
<br>
<select name="cible">
<?php
for ($i = 0 ; $i < count($DATABASE_NAMES) ; $i++)
{
	echo "<option value=\"".$i."\">".$DATABASE_NAMES[$i]."</option><br>";
}
?>
</select>
<br>
<input type=submit name=submit value="Valider">
</form>
<?php
}
?>
</body>
</html>

?>