<?php	

	session_start();
	
	$basedir = $_SESSION['repertoire'];
	
	if (isset($_GET['action']))
	{
	
		$action = $_GET['action'];
		$display = $_GET['display'];
		
		$file = $_GET['file'];
		
		$repertoire = $_GET['repertoire'];
	
		$repertoire_courant = $_GET['repertoire'];
		//echo $file ."aaaaaa" ."<br>";
		//echo "++++++" ."<br>";
		
		
		$PHP_SELF = $_SERVER['PHP_SELF'];
		//echo $PHP_SELF;
		
		//$rep = dirname($_SERVER["PHP_SELF"]);
		//echo $rep;
		
		$savesave = $_GET['save'];
		$save = $_GET['save'];
		
		if($_GET['action'] == "chdr")
		{
			$repertoire_courant = $_GET['repertoire'];
			echo "Rép courant: " .$repertoire_courant;
		}
	}
	
	if( isset($_POST['submit']) && $_POST['submit'] == "submit" )
	{
		$tmp_file = $_FILES['fileToUpload']['tmp_name'];
		echo $tmp_file;
		
		chdir("zorro\\patoche");
		
		$name_file = $_FILES['fileToUpload']['name'];
		
		if(move_uploaded_file($tmp_file, $name_file)) 
		{
			echo 'Upload effectuÃ© avec succÃ¨s !';
		}
		else 
		{
			echo 'Echec de l\'upload !';
		}
		//echo "wdir" .$wdir;
		$path =  $wdir .$file;
		$path = substr($path,1);
		echo "*****: " .$_GET['repertoire'];
	}
	
	
	//echo $basedir;
	//echo "<br>";
	//echo getcwd();
	//echo "<br>";
	
	//$s = getcwd();
	//$decompose = explode('/',$s);
	//$element = end($decompose);  
	//echo $element;
	
	
	//$PHP_SELF = $_SERVER['PHP_SELF'];
	

$updatecheck = "yes";

### 
$enable_css = "no";
$enable_logout = "no";

### autorisation
$allow_move = "yes";
$allow_download = "yes";
$allow_copy = "yes";
$allow_touch = "no";
$allow_rename = "yes";
$allow_edit = "yes";
$allow_chmod = "yes";
$allow_delete = "yes";
$allow_upload = "yes";
$allow_create_dir = "yes";
$allow_create_file = "yes";
$allow_display_env = "no";

$not_allowed = "Cette fonction n'est pas disponible. Consulter l'administrateur.";


$couleur = array('#F0F9FE','#FFFFFF');

############### Size for textarea
if($enable_css == "yes")
	{
	$textrows = "27";
	$textcols = "160";
	}
else
	{
	$textrows = "20";
	$textcols = "100";
	}

############### If $wdir (working directory) isn't specified, set it as a slash (/)
if(!$wdir) $wdir="\\";


//echo "***".$wdir."****";
//echo "<br>";

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

?>


<!--
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="https://code.jquery.com/jquery.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript" src="jquery.form.js"></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>

<script type="text/javascript" src="upload.js"></script>

<style>
ul, ol, li {
	margin: 0;
	padding: 0;
	list-style: none;
}
.gallery{ width:100%; float:left; margin-top:30px;}
.gallery ul{ margin:0; padding:0; list-style-type:none;}
.gallery ul li{ padding:7px; border:2px solid #ccc; float:left; margin:10px 7px; background:none; width:auto; height:auto;}
.gallery img{ width:250px;}
.none{ display:none;}
.upload_div{ margin-bottom:50px;}
.uploading{ margin-top:15px;}

</style>

<script type="text/javascript">

$(document).ready(function(){
	$('#images').on('change',function(){
		$('#multiple_upload_form').ajaxForm({
			
			beforeSubmit:function(e){
				$('.uploading').show();
			},
			success:function(e){
				$('.uploading').hide();
				document.getElementById('msg_debug').innerHTML = "Fin";
			},
			error:function(e){
			}
		}).submit();
	});
});

function upload_fichier()
{
		document.getElementById("message_patience").style.display='block';
		
        var formData = new FormData();
        //for each entry, add to formdata to later access via $_FILES["file" + i]
        for (var i = 0, len = document.getElementById('fichiers_choix').files.length; i < len; i++)
		{
            formData.append("file" + i, document.getElementById('fichiers_choix').files[i]);
        }
 
        //send formdata to server
        $.ajax({
            url: "upload_multiple03.php", // our php file
            type: 'post',
            data: formData,
            dataType: 'html', // we return html from our php file
            async: true,
            processData: false,  // tell jQuery not to process the data
            contentType: false,   // tell jQuery not to set contentType
            success: function (response) {
                // La réponse du serveur
				//alert(response);
				//document.getElementById('msg_debug').innerHTML = response;
				document.getElementById('message').innerHTML = response;
				$( "#message" ).dialog({
									modal: true,
									title: "Infos",
									buttons: {
												Ok: function()
												{
													$( this ).dialog( "close" );
													recharger();
												}
											 }
										});
				
				
            },
			
			/*success : function(data) {
                $('#upload-result').append('<div class="alert alert-success"><p>Fichier(s) envoyés avec succes!</p><br />');
                $('#upload-result .alert').append(data);
            },*/
            error : function(request) {
                console.log(request.responseText);
            }
        });
   
		document.getElementById("message_patience").style.display='none';
	
	
	/*var fileInput = document.getElementById("fichiers_choix");

	if (fileInput.multiple == true) 
	{

		for (var i = 0, len = fileInput.files.length; i < len; i++)
		{
			alert("plouf");
		}
	}
	else 
	{
		var file = fileInput.files.item(0);
		alert(file);
	}*/
	
	/*var fichiers = document.getElementById('fichiers_choix').files;
	
	var listefiles = '';
	var formData = new FormData();
	for(var j=0;j<fichiers.length;j++)
	{
			//listefiles += fichiers[j].name+"<br />\n";
			//alert(listefiles);
			//formData.append(fichiers[j].name);
		//alert( fichiers[j].name);
//var fileup = fichiers.files[i];
		//formData.append('fichiers_choix[]', fileup, fileup.name);
		var k = 8;
	}

	alert("alpha");

/*	var days_of_week = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
alert(days_of_week);
	*/
	
/*	var file = document.getElementById('fichiers_choix').files;
	var formData = new FormData();
	for (var i = 0; i < file.files.length; i++) 
	{	
		var fileup = file.files[i];
		formData.append('fichiers_choix[]', fileup, fileup.name);
	}
	alert(formData);
	uploadajax(formData);
	*/
 }
 
function uploadajax(formData)
{
			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;
					alert("fin des haricots");
				}
			}

			xhr.open("POST","upload_multiple03.php",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_score="+selection_score);
			xhr.send(formData);
			//xhr.send("fichier="+fichier+"&contenu="+contenu);	
	
	/*var xhr = new XMLHttpRequest();
	xhr.open('POST', 'upload_multiple02.php', true);
	xhr.onload = function ()
	{
		if (xhr.status === 200)
		{
		//<span class="IL_AD" id="IL_AD5">console</span>.log(xhr.responseText);
		} 
		else 
		{
			alert('An error occurred!');
		}
	};

	xhr.upload.addEventListener("progress", imageprogress, false);
	xhr.addEventListener("load", Completed, false);
	xhr.addEventListener("error", failstatus, false);
	xhr.addEventListener("abort", Abortedstatus, false);
	xhr.send(formData);*/

}
 

function sauver_fichier()
{
				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;
													
						$(function()
						{
									$( "#message_sauvegarde" ).dialog({
									modal: true,
									title: "Infos",
									buttons: {
												Ok: function()
												{
													$( this ).dialog( "close" );
													
												}
											 }
										});
						});
						
					}
				}
				
				fichier = document.getElementById('fichier').value;
				contenu = document.getElementById('contenu').value;
				xhr.open("POST","editeur_sauver_fichier.php",true);
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_score="+selection_score);
				xhr.send("fichier="+fichier+"&contenu="+contenu);
				
			
}

function creer_repertoire()
{
			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('msg_debug').innerHTML = retour;
					
					if(retour == "1")
					{
						
						$(function()
						{
						$( "#message_creer_repertoire" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
												recharger();
											}
									 }
							});
						});
					}
					
					if(retour == "2")
					{
						
						$(function()
						{
						$( "#message_repertoire_existe" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
											}
									 }
							});
						});
					}
						
				}
			}
				
			repertoire = document.getElementById('new_dir').value;
			base = document.getElementById('base').value;
			chemin = document.getElementById('chemin').value;
			//alert(repertoire+" " + base + "  " +chemin);
			xhr.open("POST","editeur_creer_repertoire.php",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_score="+selection_score);
			xhr.send("repertoire="+repertoire+ "&base="+base+ "&chemin="+chemin);

}

function creer_fichier()
{
			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('msg_debug').innerHTML = retour;
					
					if(retour == "1")
					{
						
						$(function()
						{
						$( "#message_creer_fichier" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
												recharger();
											}
									 }
							});
						});
					}
					
					if(retour == "2")
					{
						
						$(function()
						{
						$( "#message_fichier_existe" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
											}
									 }
							});
						});
					}
					
					
					
						
				}
			}
				
			fichier = document.getElementById('new_file').value;
			base = document.getElementById('base').value;
			chemin = document.getElementById('chemin').value;
			//alert(repertoire+" " + base + "  " +chemin);
			xhr.open("POST","editeur_creer_fichier.php",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_score="+selection_score);
			xhr.send("fichier="+fichier+ "&base="+base+ "&chemin="+chemin);

}
			
function confirmation_effacer_fichier(chemin)
{	
			$(function()
			{
					$( "#message_confirmation_suppression" ).dialog({
					modal: true,
					title: "Infos",
					buttons: {
								Oui: function()
								{
									$( this ).dialog( "close" );
									effacer_fichier(chemin);
								},
								Non: function()
								{
									$( this ).dialog( "close" );
								}
							 }
					});
			});
			
}

function confirmation_renomer_fichier(chemin)
{
	//window.location.href = "traitement_fichier.php";
	//alert(chemin);
	
	$( "#fenetre_renomer" ).dialog({
					modal: true,
					title: "Renomer",
					buttons: {
								Valider: function()
								{
									$( this ).dialog( "close" );
									renomer(chemin);
								},
								Non: function()
								{
									$( this ).dialog( "close" );
								}
							 }
					});

}

function renomer(chemin)
{
		fichier = document.getElementById('nouveau_nom').value;
		    
        $.ajax({
            url: "traitement_fichier.php", 
            type: 'post',
            data: 'nouveau_nom=' + fichier + '&chemin=' + chemin,
            dataType: 'html', 
            success: function (response) 
			{
				//alert(response);
				//document.getElementById('message').innerHTML = response;
				
				//alert("Stop");
				
				$(function()
					{
						$( "#message_fichier_renomer" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
												recharger();
											}
									 }
							});
					});
				
            },
            error : function(request) {
                console.log(request.responseText);
            }
        }); 
}

function effacer_fichier(chemin)
{
			
			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('msg_debug').innerHTML = retour;
					
					$(function()
					{
						$( "#message_suppression_fichier" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
												recharger();
											}
									 }
							});
					});
						
				}
			}
				
			
			//alert(chemin);
			xhr.open("POST","editeur_supprimer_fichier.php",true);
			xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_score="+selection_score);
			xhr.send("chemin="+chemin);
	
}
/*******************************************************************************************/

function operation_fichier(chemin,operation)
{
	if(operation == "copie")
	{
		$( "#fenetre_copier" ).dialog({
					modal: true,
					title: "Copier",
					buttons: {
								Valider: function()
								{
									$( this ).dialog( "close" );
									traitement_fichier(chemin,operation);
								},
								Non: function()
								{
									$( this ).dialog( "close" );
								}
							 }
					});
	}
	
}


function traitement_fichier(chemin,operation)
{

	if(operation == "copie")
	{
			fichier = document.getElementById('nom_copie').value;
			alert(fichier+chemin);
			
			$.ajax({
            url: "operation_fichier.php", 
            type: 'post',
            data: 'fichier=' + fichier + '&chemin=' + chemin + '&operation=' + operation,
            dataType: 'html', 
            success: function (response) 
			{
				alert(response);
				//document.getElementById('message').innerHTML = response;
				
				//alert("Stop");
				
				$(function()
					{
						$( "#message_fichier_copier").dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
												recharger();
											}
									 }
							});
					});
				
            },
            error : function(request) {
                console.log(request.responseText);
            }
        }); 
			
			
			
			
	}
}
/*******************************************************************************************/


function aaaaupload_fichier()
{
			//alert("toto");
	
			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;
					alert(retour);
					document.getElementById('msg_debug').innerHTML = retour;
/*					
					$(function()
					{
						$( "#message_suppression_fichier" ).dialog({
							modal: true,
							title: "Infos",
							buttons: {
										Ok: function()
											{
												$( this ).dialog( "close" );
												recharger();
											}
									 }
							});
					});
*/					
						
				}
			}
			
			//var x = document.getElementById("myFile").value;
			//document.getElementById("demo").innerHTML = x;
				
			var temp = "";
			var tab = new Array;	
				
			var input = document.getElementById("myFile");
			var ul = document.getElementById("fileList");
			while (ul.hasChildNodes()) {
				ul.removeChild(ul.firstChild);
			}
			
			for (var i = 0; i < input.files.length; i++) 
			{
				var li = document.createElement("li");
				li.innerHTML = input.files[i].name;
				z = input.files[i].name;
				ul.appendChild(li);
				tab.push(z); // Ajoute « Ludovic » à la fin du tableau
			}

			s = tab.join();
			alert(s);
			
			
			var formData = new FormData();
			
			for (var i = 0; i < file.files.length; i++)
			{
				var fileup = file.files[i];
 
				formData.append('filename[]', fileup, fileup.name);
			}
			
			//document.getElementById("demo").innerHTML = temp;
			
			/*if(!ul.hasChildNodes()) {
				var li = document.createElement("li");
				li.innerHTML = 'No Files Selected';
				ul.appendChild(li);
			}	*/
				
			//liste_fichier = document.getElementById('fileToUpload').value;	
			//alert(liste_fichier);
			
			//var x = document.getElementById("fileToUpload").value;
			//document.getElementById("demo").innerHTML = "lkllhhkl";
			
			//repertoire_courant
			//xhr.open("POST","telecharger_fichier.php",true);
			//xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			//xhr.send("J1="+J1+"&J2="+J2+"&jour="+jour+"&mois="+mois+"&annee="+annee+"&selection_score="+selection_score);
			//xhr.send("fichier="+s);

}


function makeFileList()
{
			var input = document.getElementById("fileToUpload");
			var ul = document.getElementById("fileList");
			while (ul.hasChildNodes()) {
				ul.removeChild(ul.firstChild);
			}
			for (var i = 0; i < input.files.length; i++) {
				var li = document.createElement("li");
				li.innerHTML = input.files[i].name;
				ul.appendChild(li);
			}
			if(!ul.hasChildNodes()) {
				var li = document.createElement("li");
				li.innerHTML = 'No Files Selected';
				ul.appendChild(li);
			}
}

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 recharger()
{	
	window.location.reload();
}

function retour()
{
			history.back();
}

</script>


<style type="text/css">

.css_message {	width: 500px;
				border-style: solid;
				border-width: 1px;
				border-color: #1c75c8;
				padding: 3px; 
				background-color: #c5ddf6; 
			}

			 .ui-widget-overlay
        {
            background: gray;
            
        }
			
/* Couleur de fond de chaque cellule */
td{
    background-color:yellowgreen;
}
 
/*
Lors du survol d'un tr, tout les td contenu dans ce tr changeront de couleur de fond
Fais une recherche "css :hover", tu auras toutes les infos nécessaires
*/
tr:hover td{
    background-color:red;
}
 
  
}
</style>

<?php
//..overlay.background
//http://stackoverflow.com/questions/7554681/jquery-ui-modal-window-causes-gray-line/
//horizontal white stripe across the darken background. I think this file is broken:
//jQuery UI Modal Dialog Stripe Issue
 //background: #000;
 //background-color: none;
 /*
 {
            background: #000;
            opacity: .7;
            -moz-opacity: 0.7;
            filter: alpha(opacity=70);
        }*/
############################################################################### 

function image_size()
	{
	$size = GetImageSize("$image");
	}

############################################################################### 
	
function html_header(){
	global $basedir;
	global $wdir;
	global $lastaction;
	global $version;
	global $HTTP_REFERER;
	global $action;
	global $webname;
	global $display;
	global $file;
	global $browse;
	global $raw;
	global $image;
	global $fileurl;
	global $enable_css;
	global $allow_display_env;
	global $enable_logout;
	
	echo " <BR> ";
	echo " <BR> ";
	
	

	############ We want a BACK link when viewing pictures and raw text.
	if($action == "show")
		{
		echo " <td width=\"50%\" nobreak><b><font size=\"3\" color=\"#4C4C99\" face=\"arial, helvetica\">$lastaction</font></b></td>";
		echo "<div id=\"back_link\">";
		echo " <td width=\"50%\" nobreak align=\"right\"><b><font size=\"3\" color=\"#4C4C99\" face=\"arial, helvetica\"><a href=\"$HTTP_REFERER\" title=\"Retour\"><img SRC=\"images/undo.png\" title=\"Retour\">Back</a></font></b></td>";
		
		//<IMG SRC=\"images/word.png\" title=\"Fichier Word\" alt=\"Fichier Word\" border=\"0\" width=\"13\" height=\"16\">
		echo "</div>";
		}

	############ We dont want a BACK link
	else
		{
		echo " <td colspan=\"2\"><b><font size=\"3\" color=\"#4C4C99\" face=\"arial, helvetica\">$lastaction</font></b></td>";
		}
	
	echo "<BR>";
	echo "<BR>";
	
	echo "<tr>";
	echo "<td colspan=\"2\"><hr><td>";
	echo "</tr>";
	echo "<tr>";
	echo "<td colspan=\"2\">";
}



############################################################################### 
function display_size($file)
        { 
		
			 //preg_match("/([^A-Za-z0-9])/",$file,$result);
			//On cherche tt les caractères autre que [A-Za-z] ou [0-9]
			//if(empty($result))
			
			if(is_file($file))
			{
					$file_size = filesize($file);

					if($file_size >= 1073741824)
					{
					### en giga 
					$file_size = round($file_size / 1073741824 * 100) / 100 . " Go";
					}
					elseif($file_size >= 1048576)
					{ ### en mega
					$file_size = round($file_size / 1048576 * 100) / 100 . " Mo";
					}
					elseif($file_size >= 1024)
					{ ### en kilo
					$file_size = round($file_size / 1024 * 100) / 100 . " Ko";
					}
					else{   ### en octet (byte)
					$file_size = $file_size . " Octets";
					}
					return $file_size;
			}		
}
############################################################################### 

function list_files()
{
	global $basedir;
	global $wdir;	
	global $single;
	global $key;

	global $allow_move;
	global $allow_chmod;
	global $allow_create_file;
	global $allow_create_dir;	
	global $allow_upload;

	global $allow_touch;
	global $allow_delete;

	################## Load directory into array
	$handle = opendir(".");
	while($file = readdir($handle))
	{
		if(is_file($file))
		{
			$filelist[] = $file;
		}	
	}
	closedir($handle);

	if($filelist)
	{
		
		asort($filelist);
		while (list ($key, $file) = each ($filelist))
		{
			
			$ext = strrchr ( $file , "." );
			$ext = strtolower($ext);

			$gloup = $file;

			############### Image
			if((!strcasecmp ($ext, ".gif")) || (!strcasecmp ($ext, ".jpg")) || (!strcasecmp ($ext, ".png")) || (!strcasecmp ($ext, ".bmp")) || (!strcasecmp ($ext, ".jpeg")))
			{ 
			
				// suppression de \
				$tmp = substr($wdir,1);
/*				$n=substr($n,0,1); 
				if($tmp == "/")
				{	// suppression de \
					$tmp = substr($tmp,1);
					
				}
*/			
				
				$path = $tmp.$file;
				$path = $_SESSION['utilisateur'].$wdir.$file;
				
				$icon = '<a href="charge_image.php?image='.$path.'&chemin='.$wdir.'"><img src = "images/image.gif" title= "Visualiser l\'image"></a>';
				$browse = "1";
				$raw = "0";
				$image = "1";
				}

			############### Documents Office & autres
						
			elseif((!strcasecmp ($ext, ".doc")) || (!strcasecmp ($ext, ".docx")) )
			{ 
				if(strlen($wdir) == 1)
				{
					$path = $_SESSION['utilisateur'] ."/" .$file;
					//http://localhost/DEBUG_08_10_2015/Utilisateurs/20151001000A010000014715C.pdf
				}
				else
				{  
					$tmp = str_replace("\\", "/", $wdir);
					$path = $_SESSION['utilisateur'] .$tmp .$file;
				}

				$icon = "<a href=\"$path\"><IMG SRC=\"images/word.png\" title=\"Fichier Word\" alt=\"Fichier Word\" border=\"0\" width=\"13\" height=\"16\"></a>";
				$browse = "1";
				$raw = "0";
				$image = "0";
				}
			
			elseif((!strcasecmp ($ext, ".xls")) || (!strcasecmp ($ext, ".xlsx")) )
			{	
				if(strlen($wdir) == 1)
				{
					$path = $_SESSION['utilisateur'] ."/" .$file;
					//http://localhost/DEBUG_08_10_2015/Utilisateurs/20151001000A010000014715C.pdf
				}
				else
				{  
					$tmp = str_replace("\\", "/", $wdir);
					$path = $_SESSION['utilisateur'] .$tmp .$file;
				}

				$icon = "<a href=\"$path\"><IMG SRC=\"images/excel.png\" title=\"aaaaFichier Excel\" alt=\"Fichier Excel\" border=\"0\" width=\"13\" height=\"16\"></a>";
				$browse = "1";
				$raw = "0";
				$image = "0";
				}
			
			elseif((!strcasecmp ($ext, ".ppt")) || (!strcasecmp ($ext, ".pptx")) )
			{	
				if(strlen($wdir) == 1)
				{
					$path = $_SESSION['utilisateur'] ."/" .$file;
					//http://localhost/DEBUG_08_10_2015/Utilisateurs/20151001000A010000014715C.pdf
				}
				else
				{  
					$tmp = str_replace("\\", "/", $wdir);
					$path = $_SESSION['utilisateur'] .$tmp .$file;
				}
			
				$icon = "<a href=\"$path\"><IMG SRC=\"images/powerpoint.png\" title=\"Fichier Powerpoint\" alt=\"Fichier Powerpoint\" border=\"0\" width=\"13\" height=\"16\"></a>";
				$browse = "1";
				$raw = "0";
				$image = "0";
			}
			
			elseif(!strcasecmp ($ext, ".pdf"))
			{	
				if(strlen($wdir) == 1)
				{
					$path = $_SESSION['utilisateur'] ."/" .$file;
					//http://localhost/DEBUG_08_10_2015/Utilisateurs/20151001000A010000014715C.pdf
				}
				else
				{  
					$tmp = str_replace("\\", "/", $wdir);
					$path = $_SESSION['utilisateur'] .$tmp .$file;
				}
				
				$icon = "<a href=\"$path\"><IMG SRC=\"images/pdf.png\" title=\"Fichier Acrobat\" alt=\"Fichier Acrobat\" border=\"0\" width=\"13\" height=\"16\"></a>";
				$browse = "1";
				$raw = "0";
				$image = "0";
			}
	
			############### Fichier texte
			elseif(!strcasecmp ($ext, ".txt"))
				{
				$icon = "<IMG SRC=\"images/text.gif\" title=\"Fichier Texte\" alt=\"Fichier Texte\" border=\"0\" width=\"13\" height=\"16\">";
				$browse = "1";
				$raw = "1";
				$image = "0";
				}
		
			############### Audiofile
			elseif((!strcasecmp ($ext, ".wav")) || (!strcasecmp ($ext, ".mp3"))  || (!strcasecmp ($ext, ".midi")) || (!strcasecmp ($ext, ".mid")))
				{
				$icon = "<a href=\"$path\"><IMG SRC=\"images/music.png\" title=\"Fichier Audio\" alt=\"Fichier Audio\" border=\"0\" width=\"13\" height=\"16\"></a>";
				$browse = "1";
				$raw = "0";
				$image = "0";
				}

			############### Videofile
			elseif((!strcasecmp ($ext, ".mp4")) || (!strcasecmp ($ext, ".avi")) || (!strcasecmp ($ext, ".mpg")) || (!strcasecmp ($ext, ".wmv")) || (!strcasecmp ($ext, ".flv")) || (!strcasecmp ($ext, ".mov")))
				{
				$icon = "<a href=\"$path\"><IMG SRC=\"images/video.png\" title=\"Fichier Video\" alt=\"Fichier Video\" border=\"0\" width=\"13\" height=\"16\"></a>";
				$browse = "1";
				$raw = "0";
				$image = "0";
				}
	
			############### Fichier Zip 
			
			elseif((!strcasecmp ($ext, ".zip")) || (!strcasecmp ($ext, ".tar")) || (!strcasecmp ($ext, ".rar")) || (!strcasecmp ($ext, ".gz")) || (!strcasecmp ($ext, ".tgz")))
				{
				$icon = "<IMG SRC=\"images/compressed.png\" title=\"Fichier compressé'\" alt=\"Fichier compressé'\" border=\"0\" width=\"15\" height=\"15\">";
				$browse = "0";
				$raw = "0";
				$image = "0";
				}
				
			############### Script
			elseif((!strcasecmp ($ext, ".phps")) || (!strcasecmp ($ext, ".php")) || (!strcasecmp ($ext, ".php2")) || (!strcasecmp ($ext, ".php3")) || (!strcasecmp ($ext, ".php4")) || (!strcasecmp ($ext, ".phtml")) || (!strcasecmp ($ext, ".asp")) || (!strcasecmp ($ext, ".asa")) || (!strcasecmp ($ext, ".cgi")) || (!strcasecmp ($ext, ".shtml")) || (!strcasecmp ($ext, ".pl")))
				{
				$icon = "<IMG SRC=\"images/webscript.gif\" title=\"Script exécuté par le serveur\" alt=\"Script exécuté par le serveur\" border=\"0\" width=\"15\" height=\"15\">";
				$browse = "1";
				$raw = "1";
				$image = "0";
				}

			############### Apache Webserver security settings
			elseif(!strcasecmp ($ext, ".htaccess"))
				{
				$icon = "<IMG SRC=\"images/security.gif\" title=\"Fichier de sécurité du serveur Apache (configuration)\" border=\"0\" width=\"15\" height=\"16\">" ;
				$browse = "0";
				$raw = "1";
				$image = "0";
				}

			############### Web page
			elseif ((!strcasecmp ($ext, ".html")) || (!strcasecmp ($ext, ".htm")))
				{
				$icon = "<IMG SRC=\"images/webpage.gif\" title=\"Page web HTML\" alt=\"Page web HTML\" border=\"0\" width=\"15\" height=\"15\">";
				$browse = "1";
				$raw = "1";
				$image = "0";
				}
			
			############### Inconnu
			else
				{ 
				$icon = "<IMG SRC=\"images/text.gif\" alt=\"Extension non répertorié par l'application\" border=\"0\" width=\"15\" height=\"15\">";
				$browse = "1";
				$raw = "1";
				$image = "0";
				}
			
			############### List the file(s)
			$filename=$basedir.$wdir.$file;
			$fileurl=rawurlencode($wdir.$file);
			if(is_file($file))
			  { 
			    $nom = basename ($file); 
				//echo ">>>>> " .$nom;
			    $lastchanged = filectime($nom);
				$changeddate = date("d-m-Y H:i:s", $lastchanged);
			}
			echo "<TR>";
			echo "<TD align=\"center\" nobreak>";
			
			############### Make the fileicon clickable for quickviewing
			if($raw == "1")
				{
				echo "<A HREF=\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&object=file&browse=$browse&raw=$raw\">";
				}
			
			if($image == "1")
				{
				echo "<A HREF=\"$PHP_SELF?qqqaction=show&wdir=$wdir&file=$fileurl&image=$image&object=file&browse=$browse&raw=$raw\">";
				}
			
			echo "$icon</TD>\n";
			echo "<TD nobreak><font size =\"-1\" face=\"arial, helvetica\">" . htmlspecialchars($file) . "</font></TD>\n";
			echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . display_size($file) . "</font></TD>";
			echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . $changeddate . "</font></TD><TD align=\"right\">";
		
			############### CHMOD file?
			/*if($allow_chmod == "yes")
			{
				echo "<A HREF=\"$PHP_SELF?action=chmod&wdir=$wdir&file=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\" title=\"Change le niveau des permissions du fichier : $file\">";
			}
			*/
			echo "<font size =\"-1\" face=\"arial, helvetica\">";
			if(is_file($file))
			{
				//printf("%o", (fileperms($file)) & 0777);
				echo "000";
			}
			echo "</font>";
	
			if($allow_chmod == "yes")
				{
				echo "</A>";
				}
	
			echo "</TD><TD nobreak>";
			
			if(strlen($wdir) == 1)
			{
				$path = $_SESSION['utilisateur'] ."/" .$file;
			}
			else
			{  
					$tmp = str_replace("\\", "/", $wdir);
					$path = $_SESSION['utilisateur'] .$tmp .$file;
			}
			$_SESSION['passage_chemin'] = $path;
?>
			<img src='images/edit.png'  onClick="confirmation_renomer_fichier('<?php echo $path; ?>');" title='Renomer le fichier <?php echo $file; ?>' style='cursor:pointer;' /> 
<?php
			//echo " <a href='$PHP_SELF?action=move&wdir=$wdir&file=$fileurl'><img src='images/edit.png' title='Renomme le fichier : $file' border='0' width='15' height='15'></a> ";
	
				
			############### Move file?
			if($allow_move == "yes")
			{
				echo " <A HREF=\"$PHP_SELF?action=move&wdir=$wdir&file=$fileurl&object=file&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\"><img src=\"images/move.gif\" title=\"Déplace, renomme ou copie le fichier : $file\" border=\"0\" width=\"15\" height=\"15\"></A> ";
	
				$tmp = str_replace("\\", "/", $wdir);
				$path = $_SESSION['utilisateur'] .$tmp .$file;
?>
				<img src='images/copy.png'  onClick="operation_fichier('<?php echo $path; ?>','copie');" title='Copie le fichier <?php echo $file; ?>' style='cursor:pointer;' /> 
<?php					
		
			}
		
			############### Touch file?
			if($allow_touch == "yes")
			{
				echo " <A HREF=\"$PHP_SELF?action=touch&wdir=$wdir&touchfile=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\"><img src=\"images/touch.gif\" alt=\"Touch $file\" border=\"0\" width=\"12\" height=\"16\"></A> ";
			
			}

			############### Delete file?

				$tmp = str_replace("\\", "/", $wdir);
				$path = $_SESSION['utilisateur'] .$tmp .$file;
			
?>
				<img src='images/delete.gif'  onClick="confirmation_effacer_fichier('<?php echo $path; ?>');" title='Effacer le fichier <?php echo $file; ?>' style='cursor:pointer;' /> 
<?php
	
			############### If the file can be browsed, give it the browse icon
			/*if($browse == "1")
				{
				//$wdir$file
				echo " <A HREF=\"gkgkjgjkkjgkj\"><img src=\"images/browse.gif\" alt=\"Affiche dans le navigateur : $file\" border=\"0\" width=\"16\" height=\"16\"></A> ";
				}
*/
			############### If the file can be edited, give it the edit icon
				if($raw =="1")
				{
					//passer le chemin complet !!!!
					//$fileurl = "acceuil.php";
					//echo " <A HREF=\"$PHP_SELF?wdir=$wdir&action=edit&display=1&file=$fileurl&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\"><img src=\"images/edit.gif\" title=\"Edition du fichier : $file\" border=\"0\" width=\"16\" height=\"16\"></A> ";
					
					//$path = getcwd();
					//$path = $path ."\\" .$file;
					//$icon = '<a href="charge_image.php?image='.$path.'"><img src = "images/image.gif" title= "Visualiser l\'image"></a>';
					$path = getcwd();
					$path = $path ."\\" .$file;
					
					echo " <A HREF=\"$PHP_SELF?action=edit&display=1&file=$path&raw=$raw\"><img src=\"images/edit.gif\" title=\"Edition du fichier : $file\" border=\"0\" width=\"16\" height=\"16\"></A> ";
//					echo " <A HREF=\"$PHP_SELF?action=edit&display=1&file=$fileurl&raw=$raw\"><img src=\"images/edit.gif\" title=\"Edition du fichier : $file\" border=\"0\" width=\"16\" height=\"16\"></A> ";
	
				}
		}
	}
}

### liste des objets (tableau contenant les repertoires ou les fichiers)
function displaydir()
	{
	global $file;
	global $basedir;
	global $wdir;	
	global $allow_create_file;
	global $allow_create_dir;	
	global $allow_upload;
	global $allow_touch;
	global $allow_delete;
	global $allow_move;
	
	global $single;
	
	if(isset($single))
	{
		echo "<TABLE BORDER=\"0\" cellspacing=\"1\" cellpadding=\"1\" align=\"center\">";
	}
	else
	{
		echo "<TABLE BORDER=\"0\" cellspacing=\"1\" cellpadding=\"1\" width=\"100%\">";	
	}
	
	echo "<tr>";
	echo "<th bgcolor=\"#4C4C99\"><font color=\"white\" face=\"arial, helvetica\">Type</font></th>";
	echo "<th bgcolor=\"#4C4C99\"><font color=\"white\" face=\"arial, helvetica\">Nom</font></th>";
	echo "<th bgcolor=\"#4C4C99\"><font color=\"white\" face=\"arial, helvetica\">Taille</font></th>";
	echo "<th bgcolor=\"#4C4C99\"><font color=\"white\" face=\"arial, helvetica\">Modifications</font></th>";
	echo "<th bgcolor=\"#4C4C99\"><font color=\"white\" face=\"arial, helvetica\">Droits</font></th>";
	echo "<th bgcolor=\"#4C4C99\"><font color=\"white\" face=\"arial, helvetica\">Action</font></th>";
	echo "</tr>";
	
	
/*	while(condition)
{
   echo'<tr style="background:'.$couleur[$i].';"><td></td></tr>';
   $i++; if($i>1)$i=0;
}*/
	################## 
	
	if(!isset($single))
	{
		
		chdir($basedir . $wdir);
		
		$handle=opendir(".");
		while ($file = readdir($handle))
		{
			if(is_dir($file)) 
			{
				$dirlist[] = $file;
			}	
		}
		closedir($handle);
			
		if($dirlist)
		{
			asort($dirlist);
			while (list ($key, $file) = each ($dirlist))
			{
				if (!($file == "."))
				{
					$filename=$basedir.$wdir.$file;
					$fileurl=rawurlencode($wdir.$file);
	
					$rep = getcwd();
	
					$lastchanged = filectime($rep);
					$changeddate = date("d-m-Y H:i:s", $lastchanged);
					echo "<TR>";
/*******/
					############### Racine
					if($file == "..")
						{
							$downdir = dirname("$wdir");
							echo $downdir;
							echo "<TD align=\"center\" nobreak><A HREF=\"$PHP_SELF?action=chdr&repertoire=$downdir\"><img src=\"images/parent.gif\" alt=\"Répertoire parent\" border=\"0\" width=\"20\" height=\"16\"></a></TD>\n";
							echo "<TD></TD>\n";
							echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . display_size($filename) . "</font></TD>";
							echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . $changeddate . "</font></TD><TD align=\"right\">";
							printf("%o", (fileperms($file)) & 0777);
							if(is_file($file))
							{
								printf("%o", (fileperms($file)) & 0777);
							}
							echo "</TD><TD nobreak>";
							echo "<A HREF=\"$PHP_SELF?action=chdr&file=$downdir\"><img src=\"images/parent.gif\" alt=\"Répertoire parent\" border=\"0\" width=\"20\" height=\"16\"></A> ";
						}

					############### repertoire
					else
					{
						//echo "****** " .$tmp ."***** ";
						
						
						$lastchanged = filectime($rep);
						echo "<TD align=\"center\" nobreak><A HREF=\"$PHP_SELF?action=chdr&repertoire=$fileurl\"><img src=\"images/folder.gif\" alt=\"Changement de destination : répertoire vers $file\" border=\"0\" width=\"15\" height=\"13\"></a></TD>\n";
						echo "<TD nobreak><font size =\"-1\" face=\"arial, helvetica\">" . htmlspecialchars($file) . "</font></TD>\n";
						echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . display_size($filename) . "</font></TD>";
						echo "<TD align=\"right\" nobreak><font size =\"-1\" face=\"arial, helvetica\">" . $changeddate . "</font></TD><TD align=\"right\">";
						echo "<A HREF=\"$PHP_SELF?action=chmod&file=$filename\" title=\"Change le niveau des permissions du fichier : $file\"><font size =\"-1\" face=\"arial, helvetica\">";
						printf("%o", (fileperms($file)) & 0777);
						if(is_file($file))
						{ echo ">> " .$file ;
						printf("%o", (fileperms($file)) & 0777);
						}
						echo "</A>";
						echo "</font></TD><TD nobreak>";
						
						############### Move directory?
						if($allow_move == "yes")
						{
							echo " <A HREF=\"$PHP_SELF?action=move&wdir=$wdir&file=$fileurl\"><img src=\"images/move.gif\" alt=\"Renomme le fichier : $file\" border=\"0\" width=\"15\" height=\"15\"></A> ";
						}
						
						############### Touch directory?
						/*if($allow_touch == "yes")
							{
							echo " <A HREF=\"$PHP_SELF?action=touch&wdir=$wdir&touchfile=$fileurl\"><img src=\"images/touch.gif\" alt=\"Touch $file\" border=\"0\" width=\"12\" height=\"16\"></A> ";
							}*/

						############### Delete directory?
						if($allow_delete == "yes")
							{
							echo "<A HREF=\"$PHP_SELF?action=del&wdir=$wdir&file=$fileurl\"><img src=\"images/delete.gif\" alt=\"Supprime le fichier : $file\" border=\"0\" width=\"20\" height=\"16\"></A> ";
							}
					}
				}	
			}
		}

		list_files();
		echo "</TD></TR>\n";
		echo "</TABLE>";

		############### Display forms for different actions
		echo "<table border=\"0\" width=\"100%\">";
		echo "<TR><TD colspan=\"2\"><hr></td>";

		############### Upload file
		if($allow_upload  == "yes")
		{
			
			if(strlen($wdir) == 1)
			{
				$_SESSION['upload_repertoire'] = $_SESSION['utilisateur'] ."/";
			}
			else
			{   
				//supprimer le 1 et le dernier caractere
				$tmp = str_replace("/", "", $wdir);
				$tmp = str_replace("\\", "", $tmp);
				$_SESSION['upload_repertoire'] = $_SESSION['utilisateur']."/".$tmp."/" ;
			}
			
?>		
<!--
			</p>
			<div id="fupload">
			<h2>Ajax Image upload</h2>
			<form action="upload_multiple02.php" method="post" enctype="multipart/form-data" name="fileupload" id="fileupload">
			<input onchange="fileread(this)" name="filename[]" id="filename" type="file" multiple />
			<input type="submit" id="submit" value="Upload" />
			</form>
			<div id="progress_status">
				<div id="progressbar" class='progress'></div>
				<div id="status"></div>
			</div>
			<div id="complete"></div>
			<div id="thumb"></div>
			<div id="error"></div>
			</div>
			<p style="text-align: justify;">
-->			
		
			
			<div id="upload_fichier">
			<tr><td>
			<font size ='-1' face='arial, helvetica'>Upload fichier</font></td><td>
			<input name="fichiers_choix[]" id="fichiers_choix" type="file" multiple />
			<input type="button" id="submit" value="Upload" onclick="upload_fichier();" />
			</form>
			</div>
			<div id="upload-result">
			</div>
			<div id='message_patience' style="display: none">
			<img src="loader.gif" name = "image" id="image"> Traitement en cours ...
			</div> 
			</td></tr>
		

<?php
		}
			

		############### création d'un répertoire
		if($allow_create_dir == "yes")
		{
			
			// supprimer le premier element \
			$tmp = substr($wdir,1);
			// remplacer / par \
			$tmp = str_replace("/", "\\", $tmp);
			
			echo "<tr><td>";
			echo "<font size ='-1' face='arial, helvetica'>Créer un répertoire</font></td><td>";
			echo "<input type='hidden' id='base' name='base' value='$basedir'>";
			echo "<input type='hidden' id='chemin' name='chemin' value='$tmp'>";
			echo "<input type ='text' id ='new_dir' name='new_dir' size='40'>";
			echo "<button onclick='creer_repertoire()'>Valider</button>";
			echo "</td></tr>";
	
		}

		############### création d'un fichier
		if($allow_create_file == "yes")
		{
			echo "<tr><td>";
			echo "<font size ='-1' face='arial, helvetica'>Créer un fichier</font></td><td>";
			echo "<input type='hidden' id='base' name='base' value='$basedir'>";
			echo "<input type='hidden' id='chemin' name='chemin' value='$tmp'>";
			echo "<input type ='text' id ='new_file' name='new_file' size='40'>";
			echo "<button onclick='creer_fichier()'>Valider</button>";
			echo "</td></tr>";
			
		}
		
		echo "</TABLE>";
	}

	else
	{
		list_files();
	}

	echo ">>>>> " .$basedir ."  --------  " .$tmp;
	
}


#########################################################################################################
############### The user pressed CANCEL, set the $action to nothing
if($cancel) $action="";

############### User has entered .. as directory. Potential security breach. Deny access.
$regexp="\\.\\.";
if (ereg( $regexp, $file, $regs )| ereg( $regexp, $wdir,$regs ))
{
    $lastaction = "ERROR: Directories may not contain the character \"..\"";
    //html_header();
    exit;
}


#########################################################################################################
############### Begin actions code
switch ($action)
{

#########################################################################################################
############### 	aucune action - affichage initial	
	case "":
		$lastaction = "Résultat de l'action ->>> Contenu du repertoire";
		//html_header();
		displaydir();
		break;

#########################################################################################################
############### change de repertoire 
	case "chdr":
	
		$wdir = $repertoire ."\\";
				
		$test = strcmp($wdir, "\\\\"); 
		if($test == 0)
		{
			// supprimer le premier element \
			$wdir = substr($wdir,1);
		}
		
		// supprimer le premier element \
		//$tmp = substr($wdir,1);
		//$tmp = str_replace("\\", "", $tmp);
		//$path = getcwd();
		
		$lastaction = "Changement de répertoire : $wdir";
		
		//html_header();
		displaydir();
		break;


#########################################################################################################
############### Edit file

	case "edit":
		
		if($display)
		{
			/*if($raw == "1")
			{
				$lastaction = "Edition du fichier : <A HREF=\"$PHP_SELF?action=show&wdir=$wdir&file=$file&browse=$browse&raw=$raw&image=$image&fileurl=$fileurl\" title=\"Voir le contenu du fichier (impossible de modifier)\">$file</a>";
			}
			elseif($image == "1")
			{
				$lastaction = "Edition du fichier : <A HREF=\"$PHP_SELF?action=show&wdir=$wdir&file=$fileurl&image=$image\" title=\"View the image\">$file</a>";
			}
			else
			{
				$lastaction = "Edition du fichier : $file";
			}*/
	
			$lastaction = "Edition du fichier : $file";
	
			//html_header();
		
			$fp=fopen($file,"r");
			$contents=fread($fp,filesize($file));
			
			echo "<input type='hidden' name='fichier' id='fichier' value='$file' />";
			echo "<textarea id = 'contenu' name='contenu' rows='$textrows' cols='$textcols'>";
			echo htmlspecialchars($contents);
			echo "</textarea><br>\n";
			echo "<center>";
			echo "<br>";
			echo "<button onclick='sauver_fichier()'>Sauver</button>";
			echo "<button onclick='retour()'>Retour</button>";
			echo "<center>";
			echo "<br>";
			echo "</center><br>\n";
		}
		
	break;	
	
		
#########################################################################################################
############### Display file

	case "show":
		
		$lastaction = ">>> Visualisation du fichier :" .$basedir.$file;
		//html_header();
			
		$path = $file;
		echo "------------------------ $path -----------------------------";
		$single = "yes";
		echo "TRACE";
		echo"<hr><br>";
		show_source($basedir.$file);
		
	break;

#########################################################################################################
############### Créer répertoire

	case "mkdir":
		
		
		/*if(file_exists($basedir.$wdir.$mkdirfile))
		{
			$lastaction = "Résultat de l'action ->>> Le répertoire $wdir$mkdirfile existe déjà.";
			html_header();
		}

		else
		{
					//$new_rep =$basedir .substr($wdir,1) .$mkdirfile;
				
					echo "</br>";
					//echo $basedir ." ++ " .substr($wdir,1) ." ++ ".$mkdirfile;
					$lastaction = "Résultat de l'action ->>> Création du répertoire $wdir$mkdirfile";
					//html_header();
					//mkdir("../Users/lucien/aqw");
					//mkdir($new_rep);
					//mkdir($basedir.$wdir.$mkdirfile,0750);
		}
					displaydir();
					/*echo " ++ " .$new_rep ." ++ ";*/
		
		echo "Creation du repertoire....";	
		
		
		break;

#########################################################################################################
		
}

echo dirname("$wdir");

?>
				<div id='msg_debug'>  
				</div> 
				
				<div id='demo'>  
				</div> 
				
				<div id="message_creer_repertoire" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Le repertoire a été crée.
				</div>
				
				<div id="message_repertoire_existe" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Erreur: Le repertoire existe dèja !.
				</div>
				
				<div id="message_creer_fichier" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Le fichier a été crée.
				</div>
				
				<div id="message_fichier_existe" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Erreur: Le fichier existe dèja !.
				</div>
				
				<div id="message_confirmation_suppression" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Voulez-vous vraiment effacé ce fichier ?.
				</div>
				
				<div id="message_suppression_fichier" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Le fichier vient d'être effacé.
				</div>

				<div id="message_sauvegarde" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Le fichier a été sauvegardé.
				</p>
				</div>
				
				<div id="message_fichier_renomer" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Le fichier a été renomé.
				</p>
				</div>
				
				<div id="message_fichier_copier" class ="css_message" style="display: none">
				<p>
				<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
				Le fichier a été copié.
				</p>
				</div>
				
							
				
				<div id="message" class ="css_message" style="display: none">
				</div>
				
				<div id="fenetre_renomer"  style="display: none">
				<form>
				<label>Nouveau nom: </label>
				<input type="text" name="nouveau_nom" id="nouveau_nom" />
				<br/>
				<br/>
				</div>
				
				<div id="fenetre_copier"  style="display: none">
				<form>
				<label>Nom du fichier: </label>
				<input type="text" name="nom_copie" id="nom_copie" />
				<br/>
				<br/>
				</div>
   
</form>
</div>
				
				 
				
