<?php
/****************************************************************************************
SMI (Services Maintenance Interventions) est une gestion libre de maintenance et de SAV

Version 0.9.7

Copyright (C) 2006-2007  Sylvain FATOME
This program is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation; 
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program
(in the directory docs); 
if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
Boston, MA  02110-1301, USA.

Contact : galawa@free.fr

Web : http://smitst.homelinux.com
****************************************************************************************/


// Vérification des tentatives de hack
$pos=strpos($_SERVER['PHP_SELF'],"inc.php");
if ($pos===FALSE)
	$ok_inc=TRUE;
else
	$ok_inc=FALSE;
if ($ok_inc==FALSE) header("Location: ../index.php");

include_once("../inc/func.inc.php");
include_once("../inc/fic_fici.inc.php");
Archivelog(@$_SESSION["code_log"]);

$aff_form = TRUE;

if ((@$_GET['name'] <> "") AND ((@$_GET['td'] == 0) OR (@$_GET['td'] == 1)))
{
	$nom_ficdir = @$_GET['name'];
	if ((substr($nom_ficdir, 0, 1) <> '.') AND (substr($nom_ficdir, 0, 2) <> '..') AND (trim($nom_ficdir) <> '.htaccess')) // Contrôle de hack
	{
		$td = @$_GET['td'];

		$chemin_complet = $url_gfc."/".$nom_ficdir;
		
		if ((est_createur_ficdir($chemin_complet,@$_SESSION["code_log"]) == TRUE) OR (@$_SESSION["niv_log"] == 9))
		{
			switch ($td)
			{
				case 0 :
					if (!is_dir($chemin_complet))
						$aff_form = FALSE;
					break;
				case 1 :
					if (!is_file($chemin_complet))
						$aff_form = FALSE;
					break;
				default :
					break;
			}
		}
		else
		{
			$aff_form = FALSE;
			$msg = "Syntaxe incorrecte";
		}
	}
}
else
{
	$aff_form = FALSE;
	$msg = "Syntaxe incorrecte";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMI - ESPACE PRIVE : Renommage fichier/r&eacute;pertoire</title>

<!-- Feuille de style pour les affichages courants -->
<link href="../css/smi.css" rel="stylesheet" type="text/css">

<!-- Feuille de style & Script pour le menu -->

<script language="JavaScript" src="../jscript/coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour fenêtres -->
<script language="JavaScript" src="../jscript/fen.js"></script>

<!-- Scripts Javascript pour contrôle de formulaire -->
<script	type="text/javascript" src="../jscript/vform/vform.js"></script>

<script language="javascript">
var tab1_champ=new Array(
	"nom:desc; format:txt ; req:Y ; txt:Nom à affecter ; lmx:100 ; stok:frmok ; stbad:frmbad",
	"nom:detail; format:txt ; req:N ; txt:Descriptif ;  stok:frmok ; stbad:frmbad");
</script>

</head>

<body>
<?PHP
if ($aff_form == TRUE)
{
	$row= lit_enr_fic($chemin_complet);
	if (is_array($row))
	{
		extract($row);
	}
	else
	{
		$fic_desc="(Pas déclaré)";
		$fic_detail="";
	}
?>
	<p align="center"> <span class="titrepage">RENOMMAGE FICHIER/REPERTOIRE</span></p>
	<br>
	<br>
	<br>
	<!--- Formulaire de renommage des fichiers ou répertoires -->
	<form action="fdren_enr.php" method="POST" enctype="multipart/form-data" name="fdren" id="fdren" onSubmit="javascript:; return (VForm(this,tab1_champ,'',''));">
		<input type="hidden" name="td" id="td" value="<?PHP echo @$_GET['td'] ?>"> 
		<input type="hidden" name="nfic" id="nfic" value="<?PHP echo @$_GET['name'] ?>"> 
		<table width="80%" border="0" cellpadding="0" cellspacing="0" align="center">
		<tr>
			<td nowrap class="rubfrm" align="right" class="annot_std_gras" valign="middle" id="f_chemin">
			Nom : 
			</td>
			<td nowrap valign="middle">
				<input style="margin-left:5px;" name="nom" type="text" id="nom" value="<?PHP echo htmlspecialchars($fic_desc) ?>"  size="80" readonly="1">
				<br>
				<span class="annot_petit_it" style="margin-left:5px;">
				<?PHP
				if ($td == 0)
					echo "(Nota : C'est un répertoire)";
				else
					echo "(Nota : C'est un fichier)";
				?>
				</span>
			</td>
		</tr>
		<tr>
			<td nowrap class="rubfrm" align="right" valign="middle" id="f_desc">
			Nouveau nom :
			</td>
			<td nowrap valign="middle">
				<input style="margin-left:5px;" type="text" name="desc" maxlength="100" size="80" value=""> 
			</td>
		</tr>
		<tr>
			<td nowrap class="rubfrm" align="right" valign="top" id="f_detail">Descriptif : </td>
			<td nowrap align="left">
			<textarea style="margin-left:5px;" name="detail" cols="90" rows="10" id="detail"><?PHP echo htmlspecialchars($fic_detail); ?></textarea>
			</td>
		</tr>						
		</table>
		<p align="center">
		<input name="create" type="submit" class="bton_fmarr_std" id="create" value="Valider">
		<input name="init" type="reset" class="bton_fmarr_std" id="init" value="R&eacute;initialiser">
		<input name="annul" type="button" class="bton_fmarr_std" id="annul" value="Quitter" onclick="javascript:; self.close('fscomp');">
		</p>
	</form>
	<!--- Fin du Formulaire de création de répertoire -->
<?PHP
}
else
{
?>
	<p align="center" class="annot_gras_it"><?PHP echo $msg ?></p>
	<p align="center" class="annot_std_it">Retour à la liste des fichiers dans 5 secondes...</p>
	<!-- Fermeture temporisée -->
	<script type="text/javascript">
		window.opener.location.reload();
		setTimeout("self.close('fscomp');",5000)
	</script>
	<p align="center">Sinon, <a href="javascript:void(0)" onClick="javascript:; window.opener.location.reload(); self.close('fscomp');">cliquez ici</a> </p>
<?PHP
}
?>
</body>
</html>
