<?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");

if (!isset($_SESSION["lng"])) $_SESSION["lng"]="fr";
include_once("../lng/".$_SESSION["lng"].".inc.php"); // Paramètres de language
include_once("../inc/config.inc.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_log.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("../inc/mail.inc.php");
include_once("../classes/ephpu/upload_class.php");
Archivelog(@$_SESSION["code_log"]);

$td = strip_tags(trim(@$_POST['td']));

// Téléchargement uniquement pour l'administrateur
if (@$_SESSION["niv_log"] == 9)
{
	$max_size = $taille_maxi_admin; // Taille maximum autorisée pour téléchargement
		
	$my_upload = new file_upload;
	
	// Définition du chemin de stockage
	$my_upload->upload_dir = $root.REP."/logos/";
	$my_upload->extensions = array(".png",".gif"); // specify the allowed extensions here
	$my_upload->language = "fr"; // use this to switch the messages into an other language (translate first!!!)
	$my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
	$my_upload->rename_file = true;
			
	if(@$_POST['ok'] == "Envoyer")
	{
		$codeuser = @$_SESSION["code_log"];
		
		$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
		$infos_img = @getimagesize($my_upload->the_temp_file); 
		$largeurDestination = $infos_img[0];
		$hauteurDestination = $infos_img[1];
		if (($largeurDestination>=195) AND ($hauteurDestination>=36))
		{
			$my_upload->the_file = $_FILES['upload']['name'];
			$my_upload->http_error = $_FILES['upload']['error'];
			$my_upload->replace = (isset($_POST['replace'])) ? $_POST['replace'] : "n"; // because only a checked checkboxes is true
			$my_upload->do_filename_check = (isset($_POST['check'])) ? $_POST['check'] : "n"; // use this boolean to check for a valid filename
			switch ($td)
			{
				case "cge" :
					$new_name = "logcge";
					break;
				case "age" :
					$new_name = "log".strtolower(str_escape(trim($_POST['codeage'])));
					break;
				case "do" :
					$new_name = "log".strtolower(str_escape(trim($_POST['codedo'])));
					break;
				case "st" :
					$new_name = "log".strtolower(str_escape(trim($_POST['codest'])));
					break;
				default :
					break;
			}
			if ($my_upload->upload($new_name))
			{ // new name is an additional filename information, use this to rename the uploaded file
	
				$msg = "Téléchargement réussi";
				$retourliste = TRUE;
			}
			else
			{
				$retourliste = FALSE;
				$msg = $my_upload->show_error_string();
			}
		}
		else
		{
			$msg = "Mauvaises dimensions";
			$retourliste = FALSE;
		}
	}
}
else
{
	$retourliste = FALSE;
	$msg = "Vous n'avez pas le droit de télécharger des logos.";
}
?>
<!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; ?> : T&eacute;l&eacute;chargement Logo</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>

<?php 
include_once("../inc/entete.inc.php"); 
?>
<p align="center"><span class="titrepage">TELECHARGEMENT DE LOGO</span></p>
<p align="center">&nbsp;</p>
<p align="center"><?php echo $msg; ?></p>
<?PHP
if ($retourliste == FALSE) { 
	aff_ret_idx_man($td,"","",FALSE);
} else { ?>
<script type="text/javascript">
<!--
window.setTimeout("location=('logo_maj.php?td=<?PHP echo $td ?>');",2000)
//-->
</script>
<p align="center" class="annot_std_it">Merci de patienter  2 secondes...</p>
<?PHP 
}
include_once("pied.php");
?>
