File "classement_05.php"

Full Path: /home/analogde/www/Bookmarks/CHESS_ON/classement_05.php
File size: 21.45 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	session_start();

	include('database.php');
//	include('elo_glissant02.php');
	DB_connexion(); 
	error_reporting( 0 );

	header('Content-Type: text/html; charset=utf-8');
	
//	include("FusionCharts.php");
//	include("FC_Colors.php");

	
	$_SESSION['chessmaster'] = "chessmaster_new";	
	$_SESSION['classement'] = "classement_new";
	$_SESSION['parties'] = "parties_new";
	$_SESSION['evolution'] = "evolution_new";

	$_SESSION['membres'] = "membres";
	$_SESSION['elo_affectation'] = "elo_affectation";
	
	
	$sql = "select * from " .$_SESSION['classement'] ." ORDER by elo desc ";
	//echo $sql;
			
	$results = mysql_query($sql);
	$indice = 0;

	while($row = mysql_fetch_assoc($results))
	{
		$joueur = $row["joueur"]; 
		$elo = $row["elo"];
		$parties = $row["parties"];

		
			$arrData[$indice]["label"] = $joueur;
			$arrData[$indice]["value"] = $elo;
			$indice = $indice + 1;
		
	}	
	
	//echo "<pre>";
	//print_r($arrData);
	//echo "<br>";
	
	/*if(!isset($_SESSION['logged']) )
	{		
		header ('Location: interdiction.php');
	}

	if($_SESSION['logged']== "no")
	{
		header ('Location: interdiction.php');
	}*/
	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"> 
<meta name="Description" content="Site perso,cours,ouvrages" />
<meta name="Keywords" content="WEBSITE perso " />
<meta name="Distribution" content="Global" />
<meta name="Robots" content="" />
<meta http-equiv="Content-Language" content="fr" />
<meta name="rating" content="general" />
<meta name="author" content="Patrice DELPY" />
<meta name="copyright" content="Copyright 2013" />
<meta name="generator" content="Patoche" />
<title>Patoche WEBSITE - 2013 - Template du site - en cours de développemment ...Classement ELO</title>

<!---------------------------------------------------------->	
<?php
		include('include_css_template_commun.php');
		include('include_css.php');
		include('css_tools_skill.php');
		include('include_javascript.php');
?> 

<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script language="javascript" src="FusionCharts.js"></script>

<style type="text/css">

#bloc_classement_joueur { 	float: left;
							width: 831px; 
							padding: 50px 50px 25px 50px;
						}	

#navigation_tournoi		{
							float: left;
							width: 910px; // 870
							padding: 10px 0px 0px 10px;
							text-align: center;
						}
</style>

<script src="Charts_2022/js/fusioncharts.js"></script>

<script src="Charts_2022/js/themes/fusioncharts.theme.fusion.js"></script>


<script type="text/javascript">

function call_update()
{
			scruter(); 
			setTimeout("call_update()", 1000); 
}

function scruter()
{
			var xhr = getXhr()
			// On défini ce qu'on va faire quand on aura la réponse
			xhr.onreadystatechange = function()
			{
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if(xhr.readyState == 4 && xhr.status == 200)
					{
						//alert(xhr.responseText);
						retour = xhr.responseText;
						if(retour == 0)
						{  	
							$(function()
							{
									$( "#message_expiration" ).dialog({
									modal: true,
									title: "Infos",
									buttons: {
												Ok: function()
												{
													$( this ).dialog( "close" );
													 document.location.href = "logout_expire.php";
												}
											 }
										});
							});
						}
					}
			}

			xhr.open("GET","session_timeout.php",true);
			xhr.send(null);
}

</script>

<script type="text/javascript">

function plot_chart()
{

	//alert("plot....");
	
	 const chartData = [{
        "label": "Venezuela",
        "value": "290"
    }, {
        "label": "Saudi",
        "value": "260"
    }, {
        "label": "Canada",
        "value": "180"
    }, {
        "label": "Iran",
        "value": "140"
    }, {
        "label": "Russia",
        "value": "115"
    }, {
        "label": "UAE",
        "value": "100"
    }, {
        "label": "US",
        "value": "30"
    }, {
        "label": "China",
        "value": "30"
    }];

    //STEP 3 - Chart Configurations
    const chartConfig = {
    type: 'column3d',
    renderAt: 'chart-container',
    width: '60%',
    height: '400',
    dataFormat: 'json',
    dataSource: {
        // Chart Configuration
        "chart": {
            "caption": "Classement ELO",
            "subCaption": "Onsemi Toulouse",
            "xAxisName": "Joueurs",
            "yAxisName": "ELO",
			"formatNumberScale": "0",
			"yAxisMaxValue": "1800",
			"yAxisMinValue": "900",
            //"numberSuffix": "K",
            "theme": "fusion",
            },
        // Chart Data
        "data": chartData
        }
    };
    FusionCharts.ready(function(){
    var fusioncharts = new FusionCharts(chartConfig);
    fusioncharts.render();
    });


}

</script>

<!---------------------------------------------------------->	

</head>

<body>

<!---------------------------------------------------------->	
	<div class="main"> <!-- main -->
<!---------------------------------------------------------->	

			<div class="header">
                <div class="balise_titre">Patoche</div>
                <div class="balise_citation">
                &quot;Etre conscient que l'on est ignorant est un grand pas vers le savoir&quot;
                </div>
			</div> 

			<div class="banniere"></div>  

<!---------------------------------------------------------->

<?php
/*	include("include_barre_login.php");
	echo '<div id="box_icon">';
	include("debug_connexion_membre.php");
	echo '</div>';
	include("include_menu.php");*/

	echo '<div id="box_infos">';
			include("include_menu.php");
			echo '<div id="box_icon2">';
			include("connexion_membre.php");
			echo	'</div>';
			echo '<div id="box_icon3">';
			include("include_barre_login.php");
			echo	'</div>';
	echo	'</div>';

	$_SESSION['page_active'] = basename (__FILE__ );
?>

<!---------------------------------------------------------->	
            <div class="contenu"> <!-- contenu -->
<!---------------------------------------------------------->	

			<div class="barre_vide"></div>
			<div id="navigation_tournoi">
				<ul id="menu_horiz">
				<li class="tournoi_partie_tag"><a href="partie.php" title="aller à la section">Duel</a></li>
				<li class="tournoi_simulation_tag"><a href="simulation.php" title="aller à la section">Sim</a></li>
				<li class="tournoi_classement_tag_selected"><a href="classement02.php" title="aller à la section">ELO</a></li>
				<li class="tournoi_master_tag"><a href="on_chess_master02.php" title="aller à la section">Master</a></li>
				<li class="tournoi_liste_joueurs_tag"><a href="joueurs_echec.php" title="aller à la section">Players</a></li>
				<li class="tournoi_stats_tag"><a href="historique.php" title="aller à la section">Games</a></li>
				<li class="tournoi_reglement_tag"><a href="reglement.php" title="aller à la section">Rules</a></li>
				<li class="tournoi_securite_tag"><a href="admin.php" title="aller à la section">Admin</a></li>
				</ul>
			</div>

			<div id="bloc_classement_joueur">

<?php			
			
			
			/***************** Filtre 1 **************************/
			
			//$sql = "select * from classement ORDER by elo desc ";
			$sql = "select * from " .$_SESSION['classement'] ." ORDER by elo desc ";
			
			$results = mysql_query($sql);
			$number = mysql_num_rows($results);
			$indice = 0;

			while($row = mysql_fetch_assoc($results))
			{
							$joueur = $row["joueur"]; 
							$elo = $row["elo"];
							$parties = $row["parties"];
							$wins = $row["wins"];
							$losses = $row["losses"];
							$draws = $row["draws"];
							$playerID=$row["id"];
							$oldrating=$row["oldrating"];

							//if($elo > 900 && $parties >= 20)
							//{
								$tab_classement[$indice][0] = $indice;
								$tab_classement[$indice][1] = $joueur;
								$tab_classement[$indice][2] = $elo;
								$tab_classement[$indice][3] = $parties;
								$tab_classement[$indice][4] = $wins;
								$tab_classement[$indice][5] = $losses;
								$tab_classement[$indice][6] = $draws;
								$tab_classement[$indice][7] = $playerID;
								$tab_classement[$indice][8] = $oldrating;
								
								$indice = $indice + 1;
							//}
			}	
			
			//echo "<pre>";
			//print_r($tab_classement);
			//echo "<br>";

			
			
			echo "<br><br>";
?>

<?php

	$J1 = $tab_classement[0][1]; 
	$J2 = $tab_classement[1][1]; 
	$J3 = $tab_classement[2][1]; 
	
	//echo " ---> " .$J1 ."  " .$J2  ."  " .$J3;

	$J1_image = "Chess joueurs/".$J1 .".jpg";
	$J2_image = "Chess joueurs/".$J2 .".jpg";
	$J3_image = "Chess joueurs/".$J3 .".jpg";

	if(!file_exists($J1_image)) 
	{
		$J1 = "nophoto";
	} 
	
	if(!file_exists($J2_image)) 
	{
		$J2 = "nophoto";
	} 

	if(!file_exists($J3_image)) 
	{
		$J3 = "nophoto";
	} 

	

?>





<?php
	
		//echo "<pre>";
		//print_r($arrData);
		//echo "<br>";
		echo "riri";
	
	//echo '<script type="text/javascript">classement();</script>';
	
	
	
?>

<div id="chart-container">FusionCharts XT will load here!</div>

<?php

	

	$sql = "SELECT * FROM " .$_SESSION['parties'];
	$results = mysql_query($sql);
	$number = mysql_num_rows($results);

	echo "Nombre de parties : " .$number; 
	echo "<br><br>"; 

	// affichage du podium
	if( $number != 0)
	{	
		echo '
				<center>
				<table width="500" border="0"> ';
		echo '
	
				<tr>
				<th scope="col"><img src="Chess joueurs/' .$J2 .".jpg"  .'" width="128" height="128"  title="Pas de photo disponoble !" /></th>	
				<th scope="col"><img src="Chess joueurs/' .$J1 .".jpg"  .'" width="128" height="128"  title="Pas de photo disponoble !" /></th>	
				<th scope="col"><img src="Chess joueurs/' .$J3 .".jpg"  .'" width="128" height="128"  title="Pas de photo disponoble !" /></th>	
				</tr>';
		echo '  
				<tr>
				<td>&nbsp;</td>
				<td rowspan="3" align="center" bgcolor="#B0D7F8">'  .$tab_classement[0][1] .' </td>
				<td>&nbsp;</td>
				</tr>

				<tr>
				<td rowspan="2" align="center" bgcolor="#F5BF0C">' .$tab_classement[1][1] .' </td>
				<td>&nbsp;</td>
				</tr>

				<tr>
				<td align="center" bgcolor="#8CBA02">' .$tab_classement[2][1] .' </td>
				</tr>

				</table>	
				</center>

				<br><br> ';
	}
?>
<?php
	
			echo "<script> plot_chart(); </script>"; 	
	
			$nb_joueur = sizeof($tab_classement);
	
			echo "<p align=center>" .$nb_joueur . " joueurs en lice.</p><br>";
			//echo "<p align=center>Joueurs en lice.</p><br>";

			echo "<table border=1 align=center width='80%'><tr>
			<th>ID</th>
			<th>Joueur</th>
			<th>ELO</th>
			<th>Parties</th>	
			<th>Victoires</th>	
			<th>Défaites</th>	
			<th>Match nul</th>
			<th>Efficacité (20 parties)</th>";
			
			for ($i=0; $i < $nb_joueur ; $i++) 
			{
				$indice = $i + 1;
				
				$joueur = $tab_classement[$i][1]; 
				$elo = $tab_classement[$i][2]; ;
				$parties = $tab_classement[$i][3]; 
				$wins = $tab_classement[$i][4]; 
				$losses = $tab_classement[$i][5]; 
				$draws = $tab_classement[$i][6]; 
				$playerID = $tab_classement[$i][7]; 
				$oldrating = $tab_classement[$i][8]; 
				
				$difference_elo = $elo - $oldrating;
				//$plage = $parties - 20;
				$plage = 20;
				
				//$sql = "SELECT * FROM parties WHERE w_playerid = '$playerID' OR b_playerid = '$playerID' ORDER by date desc LIMIT " .$plage;
				$sql = "SELECT * FROM " .$_SESSION['parties'] ." WHERE w_playerid = '$playerID' OR b_playerid = '$playerID' ORDER by date desc LIMIT " .$plage;
				
				//echo $sql;
				//echo "<br>";

				$partie_win = 0;
				$partie_losses = 0;
				$partie_nulle = 0;
				
				$results = mysql_query($sql);
				$nb_parties = mysql_num_rows($results);
				//echo $nb_parties;
				//echo "<br>";
				
				while ($row = mysql_fetch_array($results)) 
				{	 
						$white = $row["w_playerID"]; 
						$black = $row["b_playerID"];
						$result=$row["result"];

						if($white==$playerID)
						{
							if ($result==1) 
							{
								$partie_win = $partie_win + 1;		
							}

							if($result==2)
							{
								$partie_losses = $partie_losses + 1;		
							}

							if ($result==3)
							{
								$partie_nulle = $partie_nulle + 1;		
							}
						}

						if ($black==$playerID)
						{
							if($result==1)
							{
								$partie_losses = $partie_losses + 1;		
							}

							if ($result==2)
							{
								$partie_win = $partie_win + 1;		
							}

							if ($result==3)
							{
								$partie_nulle = $partie_nulle + 1;		
							}
						} 
				} 
	
				//echo $partie_win ."  " .$partie_losses ."  " . $partie_nulle;
				//echo "<br>";	
				
				$efficacite = ($partie_win + 0.5 * $partie_nulle) / $plage;
				$efficacite = $efficacite * 100;
				$efficacite = round($efficacite, 2);
				
				echo "<tr>
					  <td align=center>".$indice."</td>";

				echo "<td align=center><a href=\"statistiques_joueurs03.php?playerID=$playerID\" title='Statistiques'>".$joueur."</a></td>";
				
				if($elo > $oldrating)
				{
					echo "<td align=center>".$elo." (+".$difference_elo.")&nbsp;<img src='images/up.png' title='Derniére partie'></td>";
				}
				if($difference_elo < 0)
				{
					echo "<td align=center>".$elo." (".$difference_elo.")&nbsp;<img src='images/down.png' title='Derniére partie'></td>";
				}
				
				if($difference_elo == 0)
				{
					echo "<td align=center>".$elo." (".$difference_elo.")&nbsp;<img src='images/draw.png' title='Derniére partie'></td>";
				}
				//echo "<td align=center>".$elo."</td>";  // temporaire
				
				if($parties > 20)
				{
					echo "<td align=center>".$parties."</td>
						  <td align=center>".$wins."</td>
						  <td align=center>".$losses."</td>
						  <td align=center>".$draws."</td>
						  <td align=center>".$efficacite."</td>
						  </tr>";
				}	  
				else
				{
					echo "<td align=center>".$parties."</td>
						  <td align=center>".$wins."</td>
						  <td align=center>".$losses."</td>
						  <td align=center>".$draws."</td>
						  <td align=center> > 20 parties </td>
						  </tr>";
				}
					
			}			
			
			/*
			for ($i=0; $i < $nb_joueur ; $i++) 
			{
				$playerID = $tab_classement[$i][9]; 
				$parties = $tab_classement[$i][5]; 
				$plage = $parties - 20;
				
				$sql = "SELECT * FROM parties WHERE w_playerid = '$playerID' OR b_playerid = '$playerID' ORDER by date desc LIMIT " .$plage;
				echo $sql;
				echo "<br>";
					
				$retid = mysql_query($sql);

				$partie_win = 0;
				$partie_losses = 0;
				$partie_nulle = 0;
				
				$results = mysql_query($sql);
				$nb_parties = mysql_num_rows($results);
				echo $nb_parties;
				echo "<br>";
				
				while ($row = mysql_fetch_array($retid)) 
				{	 
						$white = $row["w_playerID"]; 
						$black = $row["b_playerID"];
						$result=$row["result"];

						if($white==$playerID)
						{
							if ($result==1) 
							{
								$partie_win = $partie_win + 1;		
							}

							if($result==2)
							{
								$partie_losses = $partie_losses + 1;		
							}

							if ($result==3)
							{
								$partie_nulle = $partie_nulle + 1;		
							}
						}

						if ($black==$playerID)
						{
							if($result==1)
							{
								$partie_losses = $partie_losses + 1;		
							}

							if ($result==2)
							{
								$partie_win = $partie_win + 1;		
							}

							if ($result==3)
							{
								$partie_nulle = $partie_nulle + 1;		
							}
						} 
				} 
	
				echo $partie_win ."  " .$partie_losses ."  " . $partie_nulle;
				echo "<br>";	
				
				$efficacite = ($partie_win + 0.5 * $partie_nulle) / $plage;
				$efficacite = $efficacite * 100;
				$efficacite = round($efficacite, 2);

				echo $efficacite;
				echo "<br>";	
				
			}
			*/
			
			
	/*****/
/*	
			$sql = "select * from classement where active=1 ORDER by elo desc ";
			$results = mysql_query($sql);
			$number = mysql_num_rows($results);

			//echo "<p align=center>$number joueurs en lice.</p><br>";
			echo "<p align=center>Joueurs en lice.</p><br>";

			echo "<table border=1 align=center width='80%'><tr>
			<th>ID</th>
			<th>Joueur</th>
			<th>ELO</th>
			<th>Parties</th>	
			<th>Victoires</th>	
			<th>Défaites</th>	
			<th>Match nul</th>
			<th>Efficacité (20 parties)</th>";

			$indice = 1;

			while($row = mysql_fetch_assoc($results))
			{
					$joueur = $row["joueur"]; 
					$elo = $row["elo"];
					$parties = $row["parties"];
					$prior = $row["prior"];
					$bonus = $row["bonus"];
					$wins = $row["wins"];
					$losses = $row["losses"];
					$draws = $row["draws"];

					$toto = ($wins + 0.5 * $draws) / $parties;
					$toto = $toto * 100;
					$toto = round($toto, 2);
					$toto = $toto ." %";

					$oldrating=$row["oldrating"];
					$playerID=$row["id"];
					$rat_increase = $elo - $oldrating;

					// si partie < 20 -> italique <EM>texte en italique</EM>

					if ($oldrating !=0)
					{
						if ($rat_increase>0)
						{
							if($elo > 900 && $parties >= 20)
							{
							    $toto = elo_glissant($playerID);
								echo "	<tr>
									<td align=center>".$indice."</td>";
								/*if($parties >= 20) 		
								{	
									echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'>".$joueur."</a></td>";
								}		
								else
								{
									echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'><em>".$joueur."</em></a></td>";
								}*/
/*
								echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'>".$joueur."</a></td>";		
								echo "
										<td align=center>".$elo." (+".$rat_increase.")&nbsp;<img src='images/up.png' title='Derniére partie'></td>
										<td align=center>".$parties."</td>
										<td align=center>".$wins."</td>
										<td align=center>".$losses."</td>
										<td align=center>".$draws."</td>
										<td align=center>".$toto."</td>
										</tr>";
							}									
						}	 

						else
						{
							if($elo > 900 && $parties >= 20)
							{
							    $toto = elo_glissant($playerID);
								echo "	<tr>
										<td align=center>".$indice."</td>";
								/*if($parties >= 20) 		
								{		
										echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'>".$joueur."</a></td>";
								}
								else
								{
										echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'><em>".$joueur."</em></a></td>";
								}*/
/*
								echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'>".$joueur."</a></td>";
								echo "	<td align=center>".$elo." (".$rat_increase.")&nbsp;<img src='images/down.png' title='Derniére partie'></td>
										<td align=center>".$parties."</td>
										<td align=center>".$wins."</td>
										<td align=center>".$losses."</td>
										<td align=center>".$draws."</td>
										<td align=center>".$toto."</td>
										</tr>";
							}			
						}
					}

					else
					{
						echo "	<tr>
								<td align=center>".$indice."</td>";

						if($parties >= 20) 		
						{		
							echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'>".$joueur."</a></td>";
						}
						else
						{
							echo "<td align=center><a href=\"statistiques_joueurs.php?playerID=$playerID\" title='Statistiques'><em>".$joueur."</em></a></td>";
						}

					    $toto = elo_glissant($playerID);

						echo "	<td align=center>".$elo."</td>
								<td align=center>".$parties."</td>
								<td align=center>".$wins."</td>
								<td align=center>".$losses."</td>
								<td align=center>".$draws."</td>
								<td align=center>".$toto."</td>
								</tr>";
					}

					$indice = $indice + 1;

			} 	
*/
			echo "</table>";
			mysql_close();
?>
			</td>
			</tr>
			</table>
            
<?php
                
//            $str_tmp = implode(",", $exclu_classement);
//            $msg = "Nota: Voici les joueurs qui sont sorti du classement ELO car ils n'ont jou顡ucunes parties depuis au mois 50 jours ! " .$str_tmp;
//            echo "<p align=center>" .$msg ."</p><br>";
            
            
?>            
            

			<div id="message_expiration" style="display: none">
			<p>
			<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
			La session a expiré. veuillez vous reconnecter.
			</p>
			</div>
	
			</div>

			<br/>
			<br/>
			<br/>
			<br/>
			<br/>

<!---------------------------------------------------------->	
<?php			
    include('include_pied_page.php');
	include('include_publicite.php');
?>
<!---------------------------------------------------------->	
			</div>  <!-- contenu -->
<!---------------------------------------------------------->	
	</div>   <!-- main -->
<!---------------------------------------------------------->	

	<script type="text/javascript">
		call_update();
	</script>

</body>
</html>