<?php
$sql11='SELECT * FROM privilege';
$reponse11=$bdd-> query($sql11) or die('Erreur SQL !<br />'.$sql11.'<br />'.mysql_error());
while($data11=$reponse11->fetch())
{
	if($data11['lib_privilege']==$chaiz and $data11['position_privilege']=='droite')
	{
		$active=$data11['lib_privilege'];
	}
	elseif($data11['lib_privilege']==$chaiz and $data11['position_privilege']=='parametre')
	{
		$active='parametre';
	}
	elseif($data11['lib_privilege']==$chaiz and $data11['position_privilege']=='visiteur')
	{
		$active='visiteur';
	}
	elseif($data11['lib_privilege']==$chaiz and $data11['position_privilege']=='utilisateur')
	{
		$active='user';
	}
}
$voir_page=0;
$sql11='SELECT * FROM user_privilege, privilege WHERE privilege.id_privilege=user_privilege.id_privilege AND id_user="'.$_SESSION['celest'].'" ORDER BY privilege.id_privilege DESC';
$reponse11=$bdd-> query($sql11) or die('Erreur SQL !<br />'.$sql11.'<br />'.mysql_error());
while($data11=$reponse11->fetch())
{
	if($data11['lib_privilege']==$chaiz)
	{
		$voir_page++;
	}
}

$sql10='SELECT * FROM user WHERE id_user="'.$_SESSION['celest'].'"';
$reponse10=$bdd-> query($sql10) or die('Erreur SQL !<br />'.$sql10.'<br />'.mysql_error());
$data10=$reponse10->fetch();
if($data10['id_type_user']==3)
{
	if($data['id_user']==$_SESSION['celest'])
	{
		$voir_page++;
	}
}


if($voir_page==0)
{
	header('Location: administration.php');
}

$n=0;
$sql8 = 'SHOW TABLES FROM '.$database.'';
$reponse8=$bdd->query($sql8) or die('Erreur SQL !<br />'.$sql8.'<br />'.mysql_error());
while($data8=$reponse8->fetch())
{
    if($chaiz==$data8[0])
    {
        $n++;
    }
}
if($n==0)
{
    header ('Location: administration.php');
}


function generer_mot_de_passe($nb_caractere=10)
{
	$mot_de_passe = "";
	$chaine = "abcdefghjkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ023456789+@!$%?&";
	$longeur_chaine=strlen($chaine);
	for($i=1; $i<=$nb_caractere; $i++)
	{
		$place_aleatoire=mt_rand(0,($longeur_chaine-1));
		$mot_de_passe.=$chaine[$place_aleatoire];
	}
	return $mot_de_passe;   
}
?>