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

session_start(); 
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/func_log.inc.php");
if (CheckURLLog(FALSE)==FALSE) header("Location: ../index.php");
if (CheckNivLog("5-9")==FALSE) header("Location: ../index.php");
include_once("../inc/fic.inc.php");
include_once("../inc/func.inc.php");
include_once("../inc/func_geo.inc.php");
include_once("../inc/func_txt.inc.php");
Archivelog(@$_SESSION["code_log"]);

$pbm_ico=FALSE;

?>
<!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; ?> : <?PHP echo $title_icodosta_lst; ?></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 divers -->
<script language="JavaScript" src="../jscript/divers.js"></script>

</head>

<body onLoad="metFocus();">

<?php 
include_once("../inc/entete.inc.php"); 

if ($pbm_ico==FALSE)
{
?>
<p align="center"><span class="titrepage"><?PHP echo $titlein_ico_lst; ?></span></p>
<p align="center" class="annot_gras_it"><?PHP echo $txt_div_chxicodosta; ?></p>
<form action="icodosta_lst.php" method="get" name="frmico" id="frmico">
  <span class="annot_gras_it"><?PHP echo $txt_chp_chxser; ?></span>  
  <select name="ico" id="ico" onChange="document.getElementById('frmico').submit();">
	  <?PHP
			
			if (strip_tags(trim(@$_GET['ico'])) <> "")
				echo '<option value="">'.$sel_lst_ico_chx.'</option>';
			else
				echo '<option value="" selected>'.$sel_lst_ico_chx.'</option>';

			// Création de la liste des catégories icônes
			
			$dossier = opendir($chemin_icones);
			
			while ($Fichier = readdir($dossier))
			{
				if ( ($Fichier != ".") && ($Fichier != "..") && ($Fichier != ".htaccess") )
				{
					if (is_dir($chemin_icones."/".$Fichier) == TRUE)
					{
						if (strip_tags(trim(@$_GET['ico'])) == $Fichier)
						{
							echo '<option value="'.$Fichier.'" selected>'.$Fichier.'</option>';
						}
						else
						{
							echo '<option value="'.$Fichier.'">'.$Fichier.'</option>';
						}
					}
				}
			}
		?>
  </select>
</form>
<br>
<br>
<?php
}

if (isset($_GET['ico']))
{
	$chemin = $chemin_icones."/".strip_tags(trim($_GET['ico']));
	if (is_dir($chemin))
	{
		$dossier = opendir($chemin);
		while ($Fichier = readdir($dossier))
		{
			if ($Fichier != "." AND $Fichier != "..")
			{
			   $ext_fic = strtolower(substr( strrchr( $Fichier,  "." ), 1 ));  
			   if (($ext_fic == "gif") OR ($ext_fic == "jpg") OR ($ext_fic == "jpeg") OR ($ext_fic == "png"))
			   {
					$taille = @getimagesize($chemin."/".$Fichier);
					$reduc = floor(($hl_vign*100)/($taille[1]));
					$l_vign = floor(($taille[0]*$reduc)/100);
					
					$url_img_mysql = strip_tags(trim($_GET['ico']))."/".$Fichier;	// URL stockée dans la base MySQL
					$url_img = $chemin."/".$Fichier;								// URL complète vers l'image
					$url_lien ="dosta_maj.php?td=add&code=&is=".$url_img;			// URL pour affecter au statut

					// Affichage icônes non utilisées
					lst_icon_not_used($url_img,$url_lien);
				}
			}
		}
	   closedir($dossier);
	   }
	   else
	   		$pbm_ico=TRUE;
}

if ($pbm_ico==TRUE)
{
?>
	<script type="text/javascript">
	<!--
	setTimeout("self.location.href=('ico_lst.php');",2000)
	//-->
	</script>
<?php 
}
include_once("pied.php")
?>
