File "restauration.php"

Full Path: /home/analogde/www/Freebox/CHESS_ON/restauration.php
File size: 5.3 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	session_start ();

	if(!isset($_SESSION['logged']) )
	{
		header ('Location: interdiction.php');
	}
	
	if($_SESSION['logged']== "no")
	{
		header ('Location: interdiction.php');
	}

	header( 'content-type: text/html; charset=utf-8' );
		
	echo '<a href="backup.php">retour ...</a>  
	<br>
	<br>';
	
	$fichier = $_GET['fichier'];
	echo "Fichier choisi: " .$fichier;
	echo '<br>';
	echo '<br>';

?>

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Restauration des parties</title>


<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);
}


function fct_restaurer()
{	
			
		$(function()
					{
								$( "#message_confirmation" ).dialog({
								modal: true,
								title: "Infos",
								buttons: {
											Oui: function()
											{
												$( this ).dialog( "close" );
												start();
													
											},
											Non: function()
											{
												$( this ).dialog( "close" );
													
											}
										 }
									});
					});

} 

function fct_annuler()
{	
	
		javascript:history.go(-1);
} 


function getXhr()
{
    var xhr = null; 
	if(window.XMLHttpRequest) // Firefox et autres
	   xhr = new XMLHttpRequest(); 
	else if(window.ActiveXObject)
	{ // Internet Explorer 
	   try {
				xhr = new ActiveXObject("Msxml2.XMLHTTP");
		   } catch (e) 
		   {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
		   }
	}
	else { // XMLHttpRequest non supporté par le navigateur 
			alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
			xhr = false; 
		 } 

	return xhr;
}


function start()
{
	document.getElementById("message_patience").style.display='block';	
		
	var xhr = getXhr();
				
	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)
		{
			retour = xhr.responseText;
			document.getElementById("message_patience").style.display='none';	
			
				//affiche = "La nouvelle partie a été enregistrée dans la base.";
				$(function()
				{
							$( "#message_suppression" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
										{
											$( this ).dialog( "close" );
											//window.location.reload();
											window.location.href = "backup.php";
										}
									 }
								});
				});
				
		}
	}

	xhr.open("POST","traitement_restaurer_partie.php",true);
	// ne pas oublier ça pour le post
	xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	
	fichier = document.getElementById('fichier').value;
	
	//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_date="+selection_date+"&selection_score="+selection_score);
	xhr.send("fichier="+fichier);
	
}			

</script>

<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>


</head>

<body>
			<input type="hidden" name="fichier" id="fichier" value="<?php echo $fichier; ?>">	

			<div align= "center">
			<input type='submit' name='Restaurer' value='Restaurer' onClick="fct_restaurer()" />
			<input type='submit' name='Annuler' value='Annuler' onClick="fct_annuler()" />  	
			</div>	

			<div id='message_patience' style="display: none">
			<img src="loader.gif" name = "image" id="image"> Traitement en cours ...
			</div> 	
			
			<div id="message_confirmation" style="display: none">
			<p>
			<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
			Voulez-vous vraiment restaurer le fichier choisi ?.
			</p>
			</div>
			
			<div id="message_suppression" style="display: none">
			<p>
			<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
			Restauration à l'état initial.
			</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>

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