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

Version 0.9.6
Copyright (C) 2006  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
****************************************************************************************/

session_start(); 
?>
<?php if ((@$HTTP_SESSION_VARS["etat_log"] <> "connecte") or ((@$HTTP_SESSION_VARS["niv_log"] <> 9) AND (@$HTTP_SESSION_VARS["niv_log"] <> 5))) header("Location: ../index.php") ?>
<?php include ("../inc/config.inc.php") ?>
<?php include ("../inc/func.inc.php") ?>
<?php include ("../inc/func_log.inc.php") ?>
<?php require ("../inc/func_txt.inc.php") ?>
<?PHP
	Archivelog(@$HTTP_SESSION_VARS["code_log"]);
?>

<!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 : Liste des Ic&ocirc;nes</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 -->
<link href="../inc/menu.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../coolmenus/coolmenus4.js"></script>

<!-- Scripts Javascript pour affichages -->
<script language="JavaScript" src="../inc/aff.js"></script>

</head>

<body>

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

<p align="center"><span class="titrepage">LISTE DES ICONES</span></p>
<p align="center" class="annot_gras_it">Veuillez choisir votre s&eacute;rie d'ic&ocirc;nes pour la cr&eacute;ation du statut</p>
<form action="ico_lst.php" method="get" name="frmico" id="frmico">
  <span class="annot_gras_it">Choisir votre cat&eacute;gorie</span>  
  <select name="ico" id="ico">
	  <?PHP
			
			// Création de la liste des catégories icônes
			
			asort ($liste_ico);
			reset ($liste_ico);
			
			foreach ($liste_ico as $rep_ico => $cat_ico)
			{
				if (strip_tags(trim($_GET['ico'])) == $rep_ico)
				{
					echo '<option value="'.$rep_ico.'" selected>'.$cat_ico.'</option>';
				}
				else
				{
					echo '<option value="'.$rep_ico.'">'.$cat_ico.'</option>';
				}
			}
		?>
  </select>
  <input type="submit" name="Submit" value="OK">
</form>

<?php

if (strip_tags(trim($_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 ="statut_maj.php?typ=add&code=&is=".$url_img;			// URL pour affecter au statut

					$icoused = FALSE;
					
					// Vérifie si l'icône est déjà utilisée (Si oui, on ne l'affiche pas)
					
					$connico = mysql_connect(DBHOST, DBUSER, DBPASS);
					mysql_select_db(DBNAME);
					$rechico = "SELECT * FROM " .TBSTA. " WHERE statut_img = '$url_img'";
					$rsico = mysql_query($rechico) or die(mysql_error());
					if (mysql_num_rows($rsico) == 0)
					{
						echo "<a href=\"".$url_lien."\">";
						echo "<img src=\"".$url_img."\" width=\"".$hl_vign."\" height=\"".$hl_vign."\" border =\"0\">";
						echo " </a>";
					}
					mysql_free_result($rsico);
					mysql_close($connico);
				}
			}
		}
	   closedir($dossier);
	   }
	   else
	   {
			echo "Le répertoire spécifié n'existe pas";
	   }
}

?>
<?php 
	include_once ("pied.php")
?>
