<?php
	session_start();
	include('database.php');
	DB_connexion(); 
	
	charger_configuration();
	
	/*if(!isset($_SESSION['logged']) )
	{		header ('Location: interdiction.php');
	}
	
	if($_SESSION['logged']== "no")
	{
		header ('Location: interdiction.php');
	}*/
	
	function charger_configuration()
	{		
		
		$_SESSION['chessmaster'] = "chessmaster_new";	
		$_SESSION['classement'] = "classement_new";
		$_SESSION['parties'] = "parties_new";
		$_SESSION['evolution'] = "evolution_new";

		$_SESSION['membres'] = "membres";
		$_SESSION['elo_affectation'] = "elo_affectation";
		
		/*
		chessmaster   
		classement
		elo_affectation
		evolution
		membres
		parties
		*/
	
	}
			
?>
  
<!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=utf-8" />
<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 ...</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>


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

#bloc_image_echec { float: left;
					width: 831px; 
					padding: 3px 50px 25px 50px;
					}	
					
.centerDiv { width: 60%; height:200px; margin: 0 auto; background-color:#FFA500 ; } 
.div1 { width: 50%; height:600px; background-color:#A52A2A ; float:left; } 
.div2 { width: 50%; height:600px; background-color:#FFA500 ; float:left; }

.pageCenter {
	margin-left: auto;
	margin-right: auto;
	max-width: 1000px;
	float: none;
}
			
#bloc_position { 
					float:left;
					text-align: center;
				}		
.center_element {
    text-align: center;
	font-size: 20px;
    //border: 3px solid green;
}		
		
.center-div
{
  position: absolute;
  margin: auto;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 100px;
  background-color: #ccc;
  border-radius: 3px;
}
		
#mydiv {
	position:absolute;
	top: 50%;
	left: 50%;
	width:30em;
	height:18em;
	margin-top: -9em; /*set to a negative number 1/2 of your height*/
	margin-left: -15em; /*set to a negative number 1/2 of your width*/
	border: 1px solid #ccc;
	background-color: #f3f3f3;
}
		
		#plouf {
background:#ccc; 
width:200px;
height:200px;
line-height:200px; /* centrage vertical */
text-align:center; /* centrage horizontal */ }
		
		IMG.displayed {
		// height: auto; 
    //width: auto; 
	
	max-width: 100%;
	height: 600px;
	//height: auto;
   // max-width: 300px; 
   // max-height: 300px;
    
	display: block;
    margin-left: auto;
    margin-right: auto }

		
</style>

<script type="text/javascript">

function call_update()
{
	 //ajax_routine(); 
	 scruter();
	 setTimeout("call_update()", 1000); //appelle la fonction 1 fois par  seconde
}

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>

<!---------------------------------------------------------->	
</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"><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>
			
			<!--
			https://www.alsacreations.com/xmedia/tuto/exemples/vertical/demos.html#cv_ligne
			
			https://www.w3.org/Style/Examples/007/center.en.html
			
			-->
<?php
/*
			$sql = "select * from classement_new ORDER by elo desc ";
			
			$sql = "SELECT * FROM classement_new WHERE id=LAST_INSERT_ID()";
			
			

			$sql = "SELECT * FROM classement_new ORDER BY id DESC LIMIT 1";
			$sql = "SELECT * FROM classement_new";
			echo $sql;
			echo "<br>";		
			
			$results = mysql_query($sql);
			$n = mysql_num_rows($results);
			echo "++++" .$n;
			echo "<br>";		
			

			$row = mysql_fetch_assoc($results);
			echo $row["gagnant"];
			
			
*/			
			//$sql = "SELECT * FROM chessmaster_new";
			$sql = "SELECT * FROM " .$_SESSION['chessmaster'];
			$results = mysql_query($sql);
			$n =  mysql_num_rows($results);
			// pointe sur le dernier enregistrement
			//$sql = "SELECT * FROM chessmaster_new WHERE id = '$n' ";
			$sql = "SELECT * FROM " .$_SESSION['chessmaster'] ." WHERE id = '$n' ";
			$results = mysql_query($sql);
			$row = mysql_fetch_assoc($results);
			$master = $row['gagnant'];
			$date = date('d/m/Y', $row['date']);

			echo "<br><br>
			<table width='500' border='0' align = 'center' >
			<tr>
			<td><img src='images/new_version.png' ></td>
			<td>
			
			<div class='center_element'>";
			
			echo '<div id="mess">';
			echo "<br>";
			echo $master;
			echo "<img src='images/fireworks.png' >";
			echo "<br>";
			echo "<br>";
			echo "<div style='text-align:center;'>ON Chess master en titre</div>";  // depuis le $date	
			echo "</div>";
			
					
?>		


			</div>
			
			</td>
			</tr>
			</table>
<!--	
		<audio controls>
		<source src="marseillaise.mp3" type="audio/mpeg">
		Your browser does not support the audio element.
		</audio>
-->			
			
<?php			

/*			
			echo $sql;
			$data = mysql_query($sql);
			$info = mysql_fetch_array( $data );
			print_r($info);
			echo $info["gagnant"];
*/
?>
			
			<br><br><br>
			
			
<?php	
/*		
			echo "<div class='center_element'>";
				echo '<div id="mess">';
				echo "<br>";
				echo $master;
				echo "<img src='images/fireworks.png' >";
				echo "<br>";
				echo "<br>";
				echo "<div style='text-align:center;'>ON Chess master en titre</div>";  // depuis le $date	
				echo "</div>";
			echo "</div>";
*/				
?>		


			
<!--	
			<p>ON CHESSMASTER en titre : Bidule</p>
			</div>
-->
			<div id="bloc_image_echec">
				<img src="images/chess-game.jpg" alt="Echec">	
			</div>
			
			<!--
			<div class="centerDiv"> 
			-->
<!--			
			<div class="div1">
				<IMG class="displayed" src="images/chess-game.jpg" alt="...">
-->
<!--			
			<div class="bloc_position">
			<p>Salut</p>	
				</div>
-->
<!--			
			</div> 
			
			<div class="div2">

				<div class="center_element">
				<br><br><br>
				<p>This text is centered.</p>
				</div>


				<div class="plouf">
				<p>This is a vertically and horizontally centered &lt;div&gt; tag. Try resizing your browser.</p>
				</div> 
			</div> 
-->			
			<!--
			</div>
			-->
			
			<div id="message_connexion" style="display: none">
			<p>
			<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
			Bienvenue.
			</p>
			</div>
			
			<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>
			
			<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>


