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

Version 0.9.9

Copyright (C) 2006-2009  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/fic_age.inc.php");
include_once("../inc/fic_cli.inc.php");
include_once("../inc/fic_fici.inc.php");
include_once("../inc/fic_txt.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_date.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_mail.inc.php");
include_once("../inc/func_txt.inc.php");
include_once("../inc/func_txtcm.inc.php");
include_once("../classes/phpmailer/class.phpmailer.php");
include_once("mail.inc.php");
Archivelog(@$_SESSION["code_log"]);
if (@$_POST['ndir'] <> "")
	{
		$dir = strtolower(@$_POST['dir']);
		if ((substr($dir, 0, 1) <> '.') AND (substr($dir, 0, 2) <> '..')) // Contrôle de hack
		{
			$nouv_dir = str_upload(@$_POST['ndir']);
			if (ereg("^[a-z0-9_]+$", $nouv_dir))
			{
				if (trim(@$_POST['dir'])<>"")
					$chemin_complet = $url_gfc."/".@$_POST['dir']."/".$nouv_dir;
				else
					$chemin_complet = $url_gfc."/".$nouv_dir;
	
				if (!is_dir($chemin_complet))
				{
					$cree_rep=mkdir($chemin_complet, 0755);
					if ($cree_rep)
					{
						$codeuser = @$_SESSION["code_log"];
			
						$desc = str_escape(trim($_POST['desc']));
						$detail = str_escape(trim($_POST['detail']));
						
						$conn = mysql_connect(DBHOST, DBUSER, DBPASS);
						mysql_select_db(DBNAME);
						$rech = "INSERT INTO " .TBFIC;
						$rech .= " (fic_nom,fic_type,fic_desc,fic_detail,fic_datecrea,fic_codecrea,fic_nbtel) VALUES";
						$rech .= " ('$chemin_complet','0','$desc','$detail','$datea','$codeuser','')";
						$rs = mysql_query($rech) or die(mysql_error());
						mysql_close($conn);
		
						// Envoi d'email vers l'administrateur
						envoi_mailwm($chemin_complet,"Création de répertoire","dir","cre","xxx","wm",$chemin_complet,"","",FALSE);
		
						$msg = "R&eacute;pertoire cr&eacute;&eacute;";
					}
					else
						$msg = "Impossible de cr&eacute;aer le r&eacute;pertoire";
				}
				else
					$msg = "Ce r&eacute;pertoire existe d&eacute;j&agrave; !";
				
			}
			else
				$msg = "Nom de r&eacute;pertoire incorrect";
		}
		else
			$msg = "Nom de r&eacute;pertoire incorrect";
	}
	else
	{
		$msg = "Nom de r&eacute;pertoire incorrect";
	}
?>

<!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 - <?PHP echo $title_esp_prive; ?> : Cr&eacute;ation 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>

</head>
<body>

<p align="center"><span class="titrepage">CREATION DE REPERTOIRE</span></p>
<p align="center">&nbsp;</p>
<p align="center">
<?PHP if ($retourliste==FALSE)
	echo '<span class="alerte1">';
else
	echo '<span class="annot_std_gras">';
?>
<?PHP echo $msg ?>
</span>
</p>

<?PHP
if ($retourliste == TRUE)
{
?>
	<p align="center" class="annot_std_it"><?PHP echo $txt_lnk_ret_liste.", ".$txt_patience; ?></p>
	<!-- Fermeture temporisée -->
	<script type="text/javascript">
	<!--
		window.opener.location.reload();
		setTimeout("self.close('fscomp');",2000)
	//-->
	</script>
<?PHP
}
else
{
?>
	<p align="center" class="annot_std_it"><?PHP echo $txt_lnk_ret_liste.", ".$txt_patience; ?></p>
	<!-- Fermeture temporisée -->
	<script type="text/javascript">
	<!--
		window.opener.location.reload();
		setTimeout("self.close('fscomp');",2000)
	//-->
	</script>
<?PHP
}
?>
<p align="center"><?PHP echo $txt_div_sinon; ?>, <a href="javascript:void(0)" onClick="javascript:; window.opener.location.reload(); self.close('fscomp');"><?PHP echo $txt_lnk_clic_ici; ?></a> </p>

</body>
</html>
