Ejemplo n.º 1
0
 public function restitution_mdp($tab)
 {
     if ($tab['categ'] == 'infirmier') {
         $statement = 'SELECT * FROM INFIRMIER WHERE EMAIL=:email';
     } elseif ($tab['categ'] == 'admin') {
         $statement = 'SELECT * FROM ADMIN WHERE EMAIL=:email';
     } elseif ($tab['categ'] == 'patient') {
         $statement = 'SELECT * FROM PATIENT WHERE EMAIL=:email';
     } else {
         return false;
         //si le type n'est pas correct on renvoit faux
     }
     $sth = $this->connexion->prepare($statement);
     $sth->bindParam(':email', $tab['email'], PDO::PARAM_STR);
     if ($sth->execute() && $sth->rowCount() > 0) {
         $user = $sth->fetchObject();
         $statement = 'INSERT INTO JETON (LIEN) VALUES("lien_a_inserer")';
         $sth = $this->connexion->prepare($statement);
         if ($sth->execute() && $sth->rowCount() > 0) {
             $idjeton = $this->connexion->lastInsertId();
             $date = new DateTime();
             $date->setTimestamp(time());
             $datetime = $date->format('Y-m-d H:i:s');
             $jeton = 'utype=' . $tab['categ'] . '&user='******'&jeton=' . $idjeton . '&date=' . $datetime;
             $jeton_crypte = Cryptage::mc_encrypt($jeton);
             $lien = 'http://' . $_SERVER['HTTP_HOST'] . '/Liemie/restitution_mdp.php?jeton=' . $jeton_crypte;
             $hash_jeton = md5($user->EMAIL . '' . $idjeton . '' . $tab['categ'] . '' . $datetime);
             $statement = 'UPDATE JETON SET LIEN=:lien, DATE_JETON=:date WHERE ID_JETON=:idjeton';
             $sth = $this->connexion->prepare($statement);
             $sth->bindParam(':idjeton', $idjeton, PDO::PARAM_INT);
             $sth->bindParam(':lien', $hash_jeton, PDO::PARAM_STR);
             $sth->bindParam(':date', $datetime, PDO::PARAM_STR);
             if ($sth->execute() && $sth->rowCount() > 0) {
                 $corps = 'Pour récupérer votre mot de passe, veuillez suivre le lien suivant : <a href="' . $lien . '">Réinitialiser le mot de passe</a> !';
                 $unmail = new MyMailer('*****@*****.**', $user->EMAIL, 'Kaliémie : Récupération de votre mot de passe.', $corps, '*****@*****.**', 'siocarcouet', 'ssl://smtp.gmail.com', 465);
                 if ($unmail->envoyerMail()) {
                     return true;
                 } else {
                     //echo $unmail->getErreur();
                 }
             }
         }
     }
     return false;
 }
Ejemplo n.º 2
0
//Si l'utilisateur est déjà connecté à un compte on le renvoit sur la page d'accueil
if (isset($_SESSION['email']) && isset($_SESSION['type'])) {
    if (isset($_SESSION['type'])) {
        echo '<script>document.location.href="index.php"; </script>';
    }
} else {
    /*
     * Si l'utilisateur n'est pas connecté on crée
     * le formulaire de connexion modal
     */
    $site->modal_login = $controleur->retourne_formulaire_login();
}
if (isset($_GET['jeton'])) {
    $jeton = $_GET['jeton'];
    $jeton = str_replace(' ', '+', $jeton);
    $jeton_decrypt = Cryptage::mc_decrypt($jeton);
    $parametres = array();
    //echo 'JETON - '.$jeton.'<br>';
    //echo 'JETON_DECRYPT - '.$jeton_decrypt;
    foreach (explode('&', $jeton_decrypt) as $chunk) {
        $param = explode("=", $chunk);
        if ($param) {
            $parametres[urldecode($param[0])] = urldecode($param[1]);
        }
    }
    $idjeton = $parametres['jeton'];
    $user = $parametres['user'];
    $categ = $parametres['utype'];
    $date = $parametres['date'];
    $site->left_sidebar = $controleur->retourne_formulaire_reinit_mdp($idjeton, $user, $categ, $date);
} else {