Esempio n. 1
0
 public function add_user($username, $password, $email)
 {
     $activate_key = $this->generate_key();
     try {
         if (!empty($email)) {
             $username = Validate::validate_string($username);
             $_password = Validate::validate_string($password);
             $password = Hash::hash_password($_password);
             $email = Validate::validate_email($email);
             if (!$this->check_if_registered($email)) {
                 $sql = "INSERT INTO users(username, password, email, " . "activation) VALUES (?, ?, ?, ?)";
                 $this->_setSql($sql);
                 $this->add_record(array($username, $password, $email, $activate_key));
                 $this->send_activation_email($email, $activate_key);
             }
             //end of check if registered block
         }
         // end of if email value empty block
     } catch (Exception $e) {
         echo 'Error: ' . $e->getMessage();
     }
     //end of try/catch block
 }
Esempio n. 2
0
 public function create_new_password($new_password)
 {
     Session::clear_error_output();
     $password = Hash::hash_password($new_password);
     $email = Session::get('email');
     $sql = "UPDATE users SET password=? WHERE email = ? " . "LIMIT 1";
     Session::clear_error_output();
     $this->_setSql($sql);
     $this->update_record(array($password, $email));
     if ($this->num_rows > 0) {
         return TRUE;
     } else {
         Session::set_error_output('unable to set new password, email address ' . Session::get('email') . ' is not valid');
         return FALSE;
     }
 }