<?php

			include('correlation.php');
			include('echec_fonctions_communes.php');

			$filename = $_POST['fichier'];
			//$filename = "sauvegarde_edition-13-09-2015-10_17_28.txt";
			
			chdir("sauvegarde_echec");
			$fp = fopen($filename, 'r') or die('Could not open file!');
			$datas = fread($fp, filesize($filename)) or die("Could not read file!");

			$table_parties = array_filter(explode("\n", $datas));
			
			echo "<pre>";
			print_r($table_parties);
			
			 
			
			$joueur = array();
			$sql = "SELECT * FROM classement ORDER by joueur asc"; 
			$results = mysql_query($sql);
								
			while($row = mysql_fetch_assoc($results))
			{
					$joueur[] = $row['joueur'];
			}
				
			// regenerer le classement
			mysql_query('TRUNCATE TABLE classement;');
			mysql_query('TRUNCATE TABLE evolution;');
			mysql_query('TRUNCATE TABLE parties;');
	
			stockage_joueurs_DB($joueur);
	
			$nb_parties = count($table_parties);
		
			for ($item=0; $item < $nb_parties ; $item++)
			{
				$pieces = explode(";", $table_parties[$item]);
			
				$donnees[0] = $pieces[0];
				list($jour, $mois, $annee) = explode('/', $donnees[0]);
				$timestamp = mktime (0, 0, 0, $mois, $jour, $annee);
			
				$donnees[0] = $timestamp;
				$donnees[1] = $pieces[1];
				$donnees[2] = $pieces[2];
				$donnees[3] = $pieces[3];
				$donnees[4] = $pieces[4];
			
				$indice = $item + 1;
				algo_elo($donnees, "nostatistique", "sql", $indice );
	
			}
			
			
			echo 1;


?>


