-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_delete.php
89 lines (70 loc) · 2.55 KB
/
account_delete.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php require_once 'users/init.php' ?>
<?php require_once 'php/version.php' ?>
<?php if (!securePage($_SERVER['PHP_SELF'])) { die(); } ?>
<?php require_once 'php/db.php' ?>
<html>
<head>
<meta charset="utf-8"/>
<title>Account Delete Request - Ace SMART</title>
<link rel="stylesheet" type="text/css" href="css/a11y.css<?= '?v=' . $smart_version ?>"/>
<link rel="stylesheet" type="text/css" href="css/tabs.css<?= '?v=' . $smart_version ?>"/>
<style>
section {
padding: 2rem;
}
</style>
</head>
<body>
<header>
<h1><span property="dcterms:publisher"><img class="logo" src="images/daisy_high.jpg" alt="DAISY Consortium"/></span> <span property="dcterms:title">Ace <span class="smart_hd">SMART</span></span></h1>
</header>
<main>
<section>
<h2>Account Delete Request</h2>
<?php
if(!empty($_POST)) {
if(!empty($_POST['delete_user'])){
$db = new SMART_DB();
if (!$db->connect()) {
echo '<p>Account deleting is not currently available. Please try again later.</p>';
die();
}
// first remove the evaluation history in case anything goes wrong deleting the account
if (!$db->prepare("DELETE FROM evaluations WHERE username = ?")) {
echo '<p>An error occurred deleting your evaluation history. Please try again.</p>';
die();
}
if (!$db->bind_param("s", array($user->data()->username))) {
echo '<p>An error occurred removing your evaluation history. Please try again. ' . $user->data()->username . '</p>';
die();
}
$db->execute();
// next remove the user account
if (!$db->prepare("DELETE FROM users WHERE id = ?")) {
echo '<p>An error occurred deleting your account. Please try again.</p>';
die();
}
if (!$db->bind_param("i", array($user->data()->id))) {
echo '<p>An error occurred removing your account. Please try again.</p>';
die();
}
$db->execute();
$db->close();
echo '<p>Your account has been successfully deleted. Thank you for trying Ace SMART!</p>';
}
else {
echo '<p>Invalid request. Account deletion requests can only be made from your account profile page.</p>';
}
}
else {
echo '<p>Invalid request. This page can only be accessed by an authorized user.</p>';
}
?>
</section>
</main>
<footer>
<p>Copyright © <span property="dcterms:dateCopyrighted">2017</span> <a target="_blank" href="http://daisy.org">DAISY Consortium</a>. All Rights Reserved.</p>
<p><a target="_blank" href="http://www.github.com/daisy/ace-smart/issues">Report a problem</a> | <a target="_blank" href="http://www.daisy.org/terms-use">Terms of Use</a></p>
</footer>
</body>
</html>