Example #1
0
 public function login()
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->form_validation->set_rules('usuario', 'Usuário', 'required');
     $this->form_validation->set_rules('senha', 'Senha', 'required');
     if ($this->form_validation->run() === FALSE) {
         echo 'false';
         return false;
     } else {
         $busca = (object) array();
         $busca->usuario = $this->input->post('usuario');
         $busca->senha = gerarSenha($this->input->post('senha'));
         $usuario = $this->usuarios_model->listar($busca);
         if (count($usuario) == 1) {
             //pegando o tempo em Segundos desde a Época Unix
             $usuario[0]->tempo = date('U');
             //adicionando usuario na sessao
             $this->native_session->set('userBolado', $usuario[0]);
             echo 'true';
             return true;
         } else {
             echo 'false';
             return false;
         }
     }
     echo 'false';
     return false;
 }
Example #2
0
            $senha .= $consoantes[rand() % strlen($consoantes)];
            $alt = 0;
        } else {
            $senha .= $vogais[rand() % strlen($vogais)];
            $alt = 1;
        }
    }
    return $senha;
}
$email = $_POST['email'];
$stmt1 = $db->prepare("SELECT idUser FROM Users WHERE email = :email");
$stmt1->bindParam(':email', $email);
$stmt1->execute();
$result1 = $stmt1->fetch();
if (!empty($result1)) {
    $pass = gerarSenha();
    $cost = 5;
    $salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');
    $salt = sprintf("\$2a\$%02d\$", $cost) . $salt;
    // $2a$ means that we are using blowfish algorithm
    $hash = crypt($pass, $salt);
    $stmt = $db->prepare('UPDATE Users SET password = :pass , salt =:salt WHERE email = :email1');
    $stmt->bindParam(':email1', $email);
    $stmt->bindParam(':pass', $hash);
    $stmt->bindParam(':salt', $salt);
    $stmt->execute();
    $message = "A sua nova palavra passe é esta:  " . $pass . " tente iniciar sessão com a nova palavra passe.";
    $from = 'From: Manage My Event';
    $to = $email;
    $subject = 'Password Reset';
    $body = "De: Manage my events \n Mensagem:\n {$message}";