/** * Delete an existing user */ public function deleteUser($password) { if ($this->store->listUsers() > 1) { if (Tools::encodeString($password . $this->user->getUsername()) == $this->store->getUserPassword($this->user->getId())) { $username = $this->user->getUsername(); $this->store->deleteUserConfig($this->user->getId()); Tools::logm('The configuration for user ' . $username . ' has been deleted !'); $this->store->deleteTagsEntriesAndEntries($this->user->getId()); Tools::logm('The entries for user ' . $username . ' has been deleted !'); $this->store->deleteUser($this->user->getId()); Tools::logm('User ' . $username . ' has been completely deleted !'); Session::logout(); Tools::logm('logout'); Tools::redirect(); $this->messages->add('s', sprintf(_('User %s has been successfully deleted !'), $username)); } else { Tools::logm('Bad password !'); $this->messages->add('e', _('Error : The password is wrong !')); } } else { Tools::logm('Only user !'); $this->messages->add('e', _('Error : You are the only user, you cannot delete your account !')); } }
<?php include_once "../clases/Database.php"; include_once "../clases/Query.php"; $idUser = $_GET['id']; $db = new Database(); $db->deleteUser($idUser); echo "<script>window.location='list_user.php';</script>";