diff options
| author | ilotterytea <iltsu@alright.party> | 2025-05-15 00:07:41 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-05-15 00:07:41 +0500 |
| commit | 29337b30b7071cff678a7be54161507f3eb278be (patch) | |
| tree | f396b5ca362b189064fa52ce5baced4c96412d78 /public/account/delete.php | |
| parent | 3f5765a05536a5b1e524bb4f4ffd290ff23a24af (diff) | |
feat: pfp, banner, badge deletion buttons
Diffstat (limited to 'public/account/delete.php')
| -rw-r--r-- | public/account/delete.php | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/public/account/delete.php b/public/account/delete.php index 99aebe5..ec8c040 100644 --- a/public/account/delete.php +++ b/public/account/delete.php @@ -9,28 +9,42 @@ if (!isset($_SESSION["user_id"])) { exit; } -$id = $_SESSION["user_id"]; - $db = new PDO(DB_URL, DB_USER, DB_PASS); -$db->prepare("DELETE FROM users WHERE id = ?")->execute([$id]); -session_unset(); -session_destroy(); +$id = $_SESSION["user_id"]; -setcookie("secret_key", "", time() - 1000); +$profile = ($_GET["profile"] ?? "false") == "true"; +$pfp = ($_GET["pfp"] ?? "false") == "true"; +$banner = ($_GET["banner"] ?? "false") == "true"; +$badge = ($_GET["badge"] ?? "false") == "true"; + +if ($pfp || $profile) { + $path = "../static/userdata/avatars/$id"; + if (is_dir($path)) { + array_map("unlink", glob("$path/*.*")); + rmdir($path); + } +} -$db = null; +if ($banner || $profile) { + $path = "../static/userdata/banners/$id"; + if (is_dir($path)) { + array_map("unlink", glob("$path/*.*")); + rmdir($path); + } +} -$path = "../static/userdata/avatars/$id"; -if (is_dir($path)) { - array_map("unlink", glob("$path/*.*")); - rmdir($path); +if ($badge || $profile) { + $db->prepare("DELETE FROM user_badges WHERE user_id = ?")->execute([$id]); } -$path = "../static/userdata/banners/$id"; -if (is_dir($path)) { - array_map("unlink", glob("$path/*.*")); - rmdir($path); +if ($profile) { + $db->prepare("DELETE FROM users WHERE id = ?")->execute([$id]); + + session_unset(); + session_destroy(); + + setcookie("secret_key", "", time() - 1000); } header("Location: /account");
\ No newline at end of file |
