예제 #1
0
 /**
  * traitement du formulaire de reinisialisation de mot de passe
  */
 public function reinisialiserPass()
 {
     if (isset($_POST["changePassword"])) {
         $data = array();
         $errors = null;
         $data['post'] = $_POST;
         if (!empty($_POST["newpass"])) {
             $newpass = $_POST["newpass"];
             if (!Validator::validPassword($newpass)) {
                 $errors['newpass'] = "******";
             }
             if (!empty($_POST["confirmPass"])) {
                 $confirmPass = $_POST["confirmPass"];
                 if ($newpass !== $confirmPass) {
                     $errors['confirmPass'] = "******";
                 }
             } else {
                 $errors['confirmPass'] = '******';
             }
         } else {
             $errors['newpass'] = '******';
         }
         $id = $_POST['id'];
         $token = $_POST['token'];
         if (sizeof($errors) !== 0) {
             $data['errors'] = $errors;
             $data['post'] = $_POST;
             $this->redirect("index.php?p=changePassword&id=" . $id . "&token=" . $token, $data);
         } else {
             //verifier s'il existe un utilisateur avec le meme id
             $res = $this->TableUtilisateur->verifTokenPassword($id, $token);
             if ($res) {
                 $req = "UPDATE utilisateur SET password=? ,token=null where id=" . $id;
                 $password = password_hash($newpass, PASSWORD_BCRYPT);
                 $resup = $this->TableUtilisateur->updateTableUser($req, [$password]);
                 $data['success'] = "Mot de passe reinisialise";
                 unset($_SESSION['post']);
                 unset($data['post']);
                 $this->redirect("index.php?p=changePassword&id=" . $id . "&token=" . $token, $data);
             } else {
                 $this->redirect("index.php?p=changePassword");
             }
         }
         $this->redirect("index.php?p=changePassword&id=" . $id . "&token=" . $token, $data);
     } else {
         $this->redirect();
     }
 }
예제 #2
0
파일: test.php 프로젝트: samira2016/bourse
var_dump(strlen($chaine));
//-----------test date-----------
$date = new \DateTime();
var_dump($date);
var_dump(NOW());
//test -------get_object_vars
$user = new Bourse\Models\Entitys\Utilisateur('login', 'passwoed');
var_dump($user);
var_dump(get_object_vars($user));
//------------test password
$password = "******";
$password1 = password_hash($password, PASSWORD_BCRYPT);
var_dump($password1);
var_dump(password_verify($password, $password1));
//test regex
$result = Validator::validPassword("dddZ44");
//var_dump($result);
$res25 = Validator::validEmail(1);
var_dump($res25);
$rule = "#^(?=.*\\d)(?=.*[A-Z]).{6,12}\$#";
echo "result--->>>><hr>";
if (preg_match($rule, "aZ1sss")) {
    echo "yesssssssssss";
} else {
    echo "noooooooooooo";
}
echo '<hr>';
//test class form
/**********todoo
$form=new Form('post'); 
echo $form;
예제 #3
0
 public function ajouterUser()
 {
     $errors = [];
     if (isset($_POST['adminAddUser'])) {
         //recuperer le niveau d'access
         if (!empty($_POST['level'])) {
             $level = $_POST['level'];
         } else {
             $level = '0';
             // $errors['level'] = 'Veillez selectionner un level';
         }
         //------------ nom
         //
         if (!empty($_POST['nom'])) {
             $nom = $_POST['nom'];
             if (!Validator::validName($nom)) {
                 $errors['nom'] = "nom invalide";
             }
         } else {
             $errors['nom'] = 'Le nom est obligatoire';
         }
         //------------ prenom
         //
         if (!empty($_POST['prenom'])) {
             $prenom = $_POST['prenom'];
             if (!Validator::validName($prenom)) {
                 $errors['prenom'] = "prenom invalide";
             }
         } else {
             $errors['prenom'] = 'Le prenom est obligatoire';
         }
         //------------login
         if (!empty($_POST['login'])) {
             $login = $_POST['login'];
             if (!Validator::validLogin($login)) {
                 $errors['login'] = "******";
             }
         } else {
             $errors['login'] = '******';
         }
         //------------password
         if (!empty($_POST['password'])) {
             $password = $_POST['password'];
             if (!Validator::validPassword($password)) {
                 $errors['password'] = "******";
             }
         } else {
             $errors['password'] = '******';
         }
         //------------email
         if (!empty($_POST['email'])) {
             $email = $_POST['email'];
             if (!Validator::validEmail($email)) {
                 $errors['email'] = "email  invalide";
             }
         } else {
             $errors['email'] = 'L\'adresse email est obligatoire';
         }
         $data = array();
         $data['errors'] = $errors;
         $data['post'] = $_POST;
         if (sizeof($errors) !== 0) {
             $this->redirect("index.php?p=addUser", $data, 'admin');
         } else {
             //tous les champs sont validés insertion base de donnée
             //
             $data['errors'] = null;
             $password = password_hash($password, PASSWORD_BCRYPT);
             //niveau access=0 l'inscription doit etre valider par l'adminstrareur et change leniveauAccess vers statut 1
             $user = new Utilisateur($nom, $prenom, $login, $password, $email, $level);
             $res = $this->TableUtilisateur->inscrire($user);
             if (is_array($res)) {
                 //login existe deja ou niveau invalide
                 foreach ($res as $key => $value) {
                     $errors[$key] = $value;
                 }
                 $data['errors'] = $errors;
             } else {
                 if ($res === true) {
                     //si retour d'insertion est true
                     $data = null;
                     //detruire les variables de session erreur et formulaire
                     unset($_SESSION["post"]);
                     unset($_SESSION["errors"]);
                     $data['success'] = "inscription effectué";
                 } else {
                     //$res==false
                     $errors['Errorinscription'] = "Probleme d'ajout  veuillez reesayer une autre fois ";
                     $data['errors'] = $errors;
                 }
             }
             //envoi du message
             $this->redirect("index.php?p=addUser", $data, 'admin');
         }
     } else {
         $this->redirect();
     }
 }
예제 #4
0
 /**
  * Verifie les champs de formualire d'inscription et renvoi les message d'erreur
  * @param type $post le formulaire
  * @return array un tableau d'erreur ou null
  */
 public function validateFormInscription($post)
 {
     $errors = null;
     $forms = array();
     if (isset($post)) {
         if (!empty($_POST['nom'])) {
             $forms['nom'] = $_POST['nom'];
             if (!Validator::validName($_POST['nom'])) {
                 $errors['nom'] = "nom invalide";
             }
         } else {
             $errors['nom'] = 'Le nom est obligatoire';
         }
         //------------ prenom
         //
         if (!empty($_POST['prenom'])) {
             $forms['prenom'] = $_POST['prenom'];
             if (!Validator::validName($_POST['prenom'])) {
                 $errors['prenom'] = "prenom invalide";
             }
         } else {
             $errors['prenom'] = 'Le prenom est obligatoire';
         }
         //------------login
         if (!empty($_POST['login'])) {
             $forms['login'] = $_POST['login'];
             if (!Validator::validLogin($_POST['login'])) {
                 $errors['login'] = "******";
             }
         } else {
             $errors['login'] = '******';
         }
         //------------password
         if (!empty($_POST['password'])) {
             $forms['password'] = $_POST['password'];
             if (!Validator::validPassword($_POST['password'])) {
                 $errors['password'] = "******";
             }
         } else {
             $errors['password'] = '******';
         }
         //------------email
         if (!empty($_POST['email'])) {
             $forms['email'] = $_POST['email'];
             if (!Validator::validEmail($_POST['email'])) {
                 $errors['email'] = "email  invalide";
             }
         } else {
             $errors['email'] = 'L\'adresse email est obligatoire';
         }
     }
     return array('errors' => $errors, 'forms' => $forms);
 }