1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| <?php
function PrintLogin($Profil=NULL, $Mot_de_passe=NULL)
{
echo '
<p class="Formulaire">
<form action="index.php" method="post">
Login : <input type="text" name="Profil" value="'.$Profil.'"/><br/>
<br/>
Mot de passe : <input type="password" name="mot_de_passe" value="'.$Mot_de_passe.'"/><br/>
<br/>
<input type="submit" value="Valider"/>
</form>
</p>
';
}
if (isset($_POST['Profil']) AND isset($_POST['mot_de_passe'])) // Si les variables existent
{
if ($_POST['Profil']!=NULL)
{
$Formulaire=TRUE;
$Profil=$_POST['Profil'];
}
if ($_POST['mot_de_passe']!=NULL)
{
$Formulaire=TRUE;
$Mot_de_passe=md5($_POST['mot_de_passe']);
}
if ($Formulaire)
{
$LoginXML='AubinFamily.xml';
if (!file_exists($LoginXML))
{
echo 'Erreur ! Le fichier : '.$LoginXML.' n\'existe pas !<br/>';
}
else
{
$ObjectLogin = simplexml_load_file($LoginXML);
foreach($ObjectLogin->Profil as $Profil)
{
if ($Profil->Login == $_POST['Profil'])
{
$ProfilXML='Profil/'.$Profil->IdProfil.'/'.'Profil.xml';
if (!file_exists($ProfilXML))
{
echo 'Erreur ! Le fichier : '.$ProfilXML.' n\'existe pas !<br/>';
}
else
{
$ObjectProfil = simplexml_load_file($ProfilXML);
foreach($ObjectProfil->Personne as $Personne)
{
if (isset($Personne->Login))
{
if ($Personne->Login==$Profil->Login)
{
if ($Mot_de_passe==$Personne->MDP)
{
$MotDePasse=true;
$_SESSION['Login']=$Personne->Login;
$_SESSION['IdProfil']=$Personne->MDP;
}
else
{
$MotDePasse=false;
}
}
}
}
}
}
}
}
if ($MotDePasse==false)
{
echo '
Mot de Passe invalide<br/>
';
PrintLogin($Profil);
}
}
}
else
{
PrintLogin();
}
?> |
Partager