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

# pas de timeout possible quelle que soit l'action effectuée
set_time_limit(0);

# le script continue une fois qu'il est lancé,
# quel que soit l'état de la connection après
ignore_user_abort(true); 

$sSqlDateStatement = " Date > '2004-10-01' ";
#$sSqlDateStatement = " 1 ";
 
$rows = main_db_query("SELECT DISTINCT(PlayerId) FROM Paris WHERE ".$sSqlDateStatement);
echo "<pre>";
$betsDone = 0;
while($row = db_fetch_array($rows))
{
	$tab = array();
	$paris = main_db_query("SELECT * FROM Paris WHERE PlayerId='".$row['PlayerId']."' AND ".$sSqlDateStatement." ORDER BY Date DESC");
	while($pari = db_fetch_array($paris))
	{
		if ($tab[$pari['MatchId']])
		{
			if ($pari['Result'] == 1)
			{
			    $color = "red";
			    $betsDone++;
            }
            else
                $color = "black";

			echo "<font color=".$color.">".(++$r)." \t> error on PId:".$row['PlayerId']." \tMatchId:".$pari['MatchId']." \t(".$pari['Date'].")";
			if ($color == "red")
			    echo "*************************** << Resultat donné";
			echo "</font><br>";
			flush();
            if ($go == 1)
            {
    			main_db_query("DELETE FROM Paris WHERE PlayerId='".$row['PlayerId']."' AND MatchId='".$pari['MatchId']."'");
	    		main_db_query("INSERT INTO Paris (PlayerId, MatchId, Bet, Date, Amount) VALUES ('".$row['PlayerId']."','".$pari['MatchId']."','".$pari['Bet']."','".$pari['Date']."','".$pari['Amount']."')");
            }
		}
		else
			$tab[$pari['MatchId']] = true;
	}
}


?>
</pre>
<br>Fini !
<br>
<?php echo "Paris déjà validés : $betsDone"; ?>