<?php
require "control_auth";

/*			Programme :		admin_parapetres.php
			Description:	Permet d'administrer les paramètres généraux du site.
							Une partie formulaire pour mettre à jour les information
							Une partie pour exécuter les requêtes.
*/
require "codbfile";
require "fonctions";
$action=$_GET['action'];

switch ($action)
{
	case "form":
	{
		//On récupère les données
		$sql="select * from parametres where profile_site='site_par_defaut'";

		$result=mysql_query($sql)
					or die ("Impossible de récupérer les données.");
		$ligne=mysql_fetch_array($result);
		extract($ligne);

		//On affiche un formulaire pour renseigner les paramètres généraux du site
		echo "
		<div align='center'><h1>Administration des paramètres généraux du site</h1></div><hr>\n
		<table align='center' width='80%'>
		<form action='admin_parametres.php?action=sql' method='post'>
		<input type='hidden' name='profile_site' value='site_par_defaut'>\n
		<tr><td>Chemin photos cd :</td><td><input type='text' name='path_photo_cd' value='$path_photo_cd'></td></tr>\n
		<tr><td>Chemin photos compositeur :</td><td><input type='text' name='path_photo_compositeur' value='$path_photo_compositeur'></td></tr>\n
		<tr><td>Chemin photos marque :</td><td><input type='text' name='path_photo_marque' value='$path_photo_marque'></td></tr>\n
		<tr><td>Chemin photos marque basse résolution:</td><td><input type='text' name='path_photo_marque_small' value='$path_photo_marque_small'></td></tr>\n
		<tr><td>Chemin photos interprete :</td><td><input type='text' name='path_photo_interprete' value='$path_photo_interprete'></td></tr>\n
		<tr><td>Chemin photos récompense :</td><td><input type='text' name='path_photo_recompense' value='$path_photo_recompense'></td></tr>\n
		<tr><td>Chemin photos récompense basse résolution:</td><td><input type='text' name='path_photo_recompense_small' value='$path_photo_recompense_small'></td></tr>\n
		<tr><td>Chemin fichiers liés aux oeuvres:</td><td><input type='text' name='path_fichier_oeuvre' value='$path_fichier_oeuvre'></td></tr>\n
		<tr><td>Chemin fichiers musique:</td><td><input type='text' name='path_fichier_musique' value='$path_fichier_musique'></td></tr>\n
		<tr><td>Couleur de fond ligne impaire :</td><td><input type='text' name='bgcolor_impaire' value='$bgcolor_impaire'></td></tr>\n
		<tr><td>Couleur de fond ligne paire :</td><td><input type='text' name='bgcolor_paire' value='$bgcolor_paire'></td></tr>\n
		<tr><td>Couleur de fond de la frame :</td><td><input type='text' name='bgcolor_frame' value='$bgcolor_frame'></td></tr>\n
		<tr><td>Adresse du lien e-mail :</td><td><input type='text' name='adresse_lien_mail' value='$adresse_lien_mail'></td></tr>\n
		<tr><td colspan='2' align='center'><input type='submit' value='sauvegarder'</td></td></tr>\n
		</form>
		</table>
		</body>
		</html>";
		break;
	}//Fin du case form

	case "sql":
	{
		//On met à jour les paramètres
		$profile_site=$_POST['profile_site'];
		$path_photo_cd=$_POST['path_photo_cd'];
		$path_photo_compositeur=$_POST['path_photo_compositeur'];
		$path_photo_marque=$_POST['path_photo_marque'];
		$path_photo_marque_small=$_POST['path_photo_marque_small'];
		$path_photo_interprete=$_POST['path_photo_interprete'];
		$path_photo_recompense=$_POST['path_photo_recompense'];
		$path_photo_recompense_small=$_POST['path_photo_recompense_small'];
		$path_fichier_oeuvre=$_POST['path_fichier_oeuvre'];
		$bgcolor_impaire=$_POST['bgcolor_impaire'];
		$bgcolor_paire=$_POST['bgcolor_paire'];
		$bgcolor_frame=$_POST['bgcolor_frame'];
		$adresse_lien_mail=$_POST['adresse_lien_mail'];


		$sql="update parametres set
		    path_photo_cd='$path_photo_cd'
		, path_photo_compositeur='$path_photo_compositeur'
		, path_photo_marque='$path_photo_marque'
		, path_photo_marque_small='$path_photo_marque_small'
		, path_photo_interprete='$path_photo_interprete'
		, path_photo_recompense='$path_photo_recompense'
		, path_photo_recompense_small='$path_photo_recompense_small'
		, path_fichier_oeuvre='$path_fichier_oeuvre'
		, bgcolor_impaire='$bgcolor_impaire'
		, bgcolor_paire='$bgcolor_paire'
		, bgcolor_frame='$bgcolor_frame'
		, adresse_lien_mail='$adresse_lien_mail'
		where profile_site='$profile_site'";

		$result=mysql_query($sql)
				or die ("Impossible de mettre à jour les données.");

		redirection ("index_admin.php");
		break;
	}//Fin du case sql

	default:
	{
		redirection ("admin_parametres.php?action=form");
	}



}//Fin du switch
