コード例 #1
0
ファイル: passwordLib.php プロジェクト: Dragonethan/The-Blag
 function password_get_info($hash)
 {
     $crypt = new Antnee\PhpPasswordLib\PhpPasswordLib();
     return $crypt->getInfo($hash);
 }
コード例 #2
0
ファイル: user.class.php プロジェクト: bdmihai/vmm
 public function update()
 {
     global $app;
     // check for empty user email
     if (empty($this->email)) {
         $app->err->add($app->txt->tr('txt_empty_user_email'));
         return false;
     }
     // check for invalid user email
     if (!filter_var($this->email, FILTER_VALIDATE_EMAIL) || !$this->is_valid_user_email($this->email)) {
         $app->err->add($app->txt->tr('txt_invalid_user_email'));
         return false;
     }
     // check for invalid user password
     if (!empty($this->password)) {
         if (!$this->is_valid_user_password($this->password)) {
             $app->err->add($app->txt->tr('txt_invalid_user_password'));
             return false;
         }
     }
     // check for existing user email
     $sql = "SELECT count(*) FROM virtual_users WHERE id={$this->id}";
     if ($app->db->select_first_value($sql) == 0) {
         $app->err->add($app->txt->tr('txt_non_existing_user_email'));
         return false;
     }
     // encrypt
     if (!empty($this->password)) {
         $crypt = new Antnee\PhpPasswordLib\PhpPasswordLib();
         $crypt->setAlgorithm(PASSWORD_SHA256);
         $this->password = $crypt->generateCryptPassword($this->password, array('cost' => 10));
     }
     // update user
     if (!empty($this->password)) {
         $sql = "UPDATE virtual_users SET email='{$this->email}',password='******' WHERE id={$this->id}";
     } else {
         $sql = "UPDATE virtual_users SET email='{$this->email}' WHERE id={$this->id}";
     }
     if ($app->db->update($sql) == 0) {
         return false;
     }
     // set administrator
     $sql = "DELETE FROM virtual_admins WHERE user_id={$this->id}";
     $app->db->delete($sql);
     if ($this->is_admin) {
         $sql = "INSERT INTO virtual_admins (user_id) VALUES ({$this->id})";
         $app->db->insert($sql);
     }
     return true;
 }