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

$ALL_WINNERS_INC = $ARCHIVES_DIR."all_winners.inc";
$ALL_WINNERS_TEMPLATE = "all_winners_template.inc";

$MARKER_ALL_WINNERS="__ALL_WINNERS__";

$DATE_DEBUT = "2001-01-01 00:00:00";
$DATE_FIN = "2008-01-01 00:00:00";

?>
<html>
<head></head>
<link rel="stylesheet" href="admin.css">
<body rightmargin=0>
<div align=center class=trTitle>Générer la page des gagnants</div>
<br>
<?php
if ($submit=="Générer la page des gagnants")
{
	# on lit le template
	$tabIn = file($ALL_WINNERS_TEMPLATE);
	
	# ouverture du calendar.inc pour ecriture
	$f_out = fopen($ALL_WINNERS_INC,'w');

	if ($auto == 1)
	{
		$Start = $DATE_DEBUT;
		$Stop = $DATE_FIN;
	}
	
	# on écrit déjà ce qu'il y a dans le template
	for($r=0;$r<count($tabIn);$r++)
	{
		switch(chop($tabIn[$r]))
		{
			case $MARKER_ALL_WINNERS:
				build_all_winners($Start,$Stop,$f_out,$COULEUR_FONT1, $COULEUR_FOND1,$COULEUR_FOND4);
			break;
			
			default:
				fwrite($f_out,$tabIn[$r]);
		}
	}
	echo "<font color=red><b>Terminé !</b></font>";
}

$Stop = "2008-01-01 00:00:00";
?>
<form>
<b>Date début : </b>
<br>
<input type="text" name="Start" value="<?php echo $Start ?>">AAAA-MM-JJ HH:MM:SS<br>
<br><br>
<b>Date fin : </b>
<br>
<input type="text" name="Stop" value="<?php echo $Stop ?>">AAAA-MM-JJ HH:MM:SS<br>
<br><br>
Ou : <input type=CheckBox name=auto value="1">Automatique<br>
<br><br>
<input type=submit name=submit value="Générer la page des gagnants">
</form>
<?php

?>