diff options
| author | ilotterytea <iltsu@alright.party> | 2025-04-20 10:46:32 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-04-20 10:46:32 +0500 |
| commit | 3b6c6e5774dec41a16da03d1bb8497b448cfa564 (patch) | |
| tree | 4e9c79624c43c92dbcc288a61f5b92b1772d3c5c /public/account/delete.php | |
| parent | 43e46d21c263fe8a8672e8e4b3ce38803b9cd089 (diff) | |
feat: users, account management, authentication system
Diffstat (limited to 'public/account/delete.php')
| -rw-r--r-- | public/account/delete.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/public/account/delete.php b/public/account/delete.php new file mode 100644 index 0000000..af8a093 --- /dev/null +++ b/public/account/delete.php @@ -0,0 +1,39 @@ +<?php +include "../../src/utils.php"; + +session_start(); + +if (!isset($_SESSION["user_id"])) { + header("Location: /account"); + exit; +} + +$id = $_SESSION["user_id"]; + +$db = new SQLite3("../../database.db"); + +$stmt = $db->prepare("UPDATE emotes SET uploaded_by = NULL WHERE uploaded_by = :id"); +$stmt->bindValue(":id", $id); +$stmt->execute(); + +$stmt = $db->prepare("DELETE FROM connections WHERE user_id = :id"); +$stmt->bindValue(":id", $id); +$stmt->execute(); + +$stmt = $db->prepare("DELETE FROM users WHERE id = :id"); +$stmt->bindValue(":id", $id); +$stmt->execute(); + +session_unset(); +session_destroy(); + +setcookie("secret_key", "", time() - 1000); + +$db->close(); + +$path = "../static/userdata/avatars/$id"; +if (is_file($path)) { + unlink($path); +} + +header("Location: /account");
\ No newline at end of file |
