prepare("SELECT slug, image_ext FROM mods_pending WHERE user = ?"); if (!$statement) { $errorMessage = "An unexpected error occurred while deleting the account."; } else { $statement->bind_param('i', $userData['id']); $statement->execute(); $result = $statement->get_result(); if (!$result) { $errorMessage = "An unexpected error occurred while deleting the account."; } else { $modPendingUploadDirectory = APP_FSROOT . '/img/mods_pending'; $coverDeletionError = false; while ($modDataToDiscard = $result->fetch_assoc()) { $pendingCoverImagePathname = isset($modDataToDiscard['image_ext']) && $modDataToDiscard['image_ext'] ? $modPendingUploadDirectory . '/' . str_replace(['/', '\\'], '', $modDataToDiscard['slug']) . '.' . str_replace(['/', '\\'], '', $modDataToDiscard['image_ext']) : null; if ($pendingCoverImagePathname && file_exists($pendingCoverImagePathname) && !unlink($pendingCoverImagePathname)) { $errorMessage = "An unexpected error occurred while deleting the account."; $coverDeletionError = true; break; } } $statement->close(); if (!$coverDeletionError) { $statement = $connection->prepare("DELETE FROM mods_pending WHERE user = ?"); if (!$statement) { $errorMessage = "An unexpected error occurred while deleting the account."; } else { $statement->bind_param('i', $userData['id']); if (!$statement->execute()) { $errorMessage = "An unexpected error occurred while deleting the account."; $statement->close(); } else { $statement->close(); $statement = $connection->prepare("DELETE FROM reviews WHERE user = ?"); if (!$statement) { $errorMessage = "An unexpected error occurred while deleting the account."; } else { $statement->bind_param('i', $userData['id']); if (!$statement->execute()) { $errorMessage = "An unexpected error occurred while deleting the account."; $statement->close(); } else { $statement->close(); $statement = $connection->prepare("UPDATE users SET email = '', password = '', bio = NULL, is_deleted = 1 WHERE id = ?"); if (!$statement) { $errorMessage = "An unexpected error occurred while deleting the account."; } else { $statement->bind_param('i', $userData['id']); if (!$statement->execute()) { $errorMessage = "An unexpected error occurred while deleting the account."; } else { session_regenerate_id(true); unset($_SESSION['user']); $accountDeleted = true; } $statement->close(); } } } } } } } } } } if (!$accountDeleted) { $pageTitle = "Account deleted"; $pageDescription = "Your account has been deleted."; } else { $pageTitle = "Delete account"; $pageDescription = "Are you sure to delete your account from SVR.JS Mods directory?"; } include 'header.php'; ?>

Account deleted

Your account has been deleted.

Return to home

Delete account

Are you sure to delete your account from SVR.JS Mods directory?

' . htmlspecialchars($errorMessage) . '

'; ?>
$userData['username'], "address" => $userData['email'] ]], 'Your account has been deleted.', "Your account has been deleted. If you did it, you are safe - you can ignore the message. If not, contact the administrator of SVR.JS Mods directory immediately, as your account might be compromised." ); } ?>