blob: ec8c040dbd21f51563b4770d9b90366c2e3e81be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
<?php
include "../../src/utils.php";
include_once "../../src/config.php";
session_start();
if (!isset($_SESSION["user_id"])) {
header("Location: /account");
exit;
}
$db = new PDO(DB_URL, DB_USER, DB_PASS);
$id = $_SESSION["user_id"];
$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);
}
}
if ($banner || $profile) {
$path = "../static/userdata/banners/$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]);
}
if ($profile) {
$db->prepare("DELETE FROM users WHERE id = ?")->execute([$id]);
session_unset();
session_destroy();
setcookie("secret_key", "", time() - 1000);
}
header("Location: /account");
|