forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteadminuser.php
110 lines (98 loc) · 2.58 KB
/
deleteadminuser.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
if (!defined('WC_BASE')) define('WC_BASE', dirname(__FILE__));
$ref=WC_BASE."/index.php";
if ($ref!=$_SERVER['SCRIPT_FILENAME']){
header("Location: index.php");
exit();
}
?>
<!-- #################### deleteadminuser.php start #################### -->
<tr>
<td width="10"> </td>
<td valign="top">
<?php
if ($authorized){
if (empty($_GET['confirmed'])){
?>
<h3>
<?php print _("Delete an Admin account from the System");?>
</h3>
<h3>
<?php print _("Do you really want to delete the Domain supervisor");?>
<span style="color: red;">
<?php echo $_GET['username'];?>
</span>
</h3>
<form action="index.php" method="get">
<input
type="hidden"
name="action"
value="deleteadminuser"
>
<input
type="hidden"
name="confirmed"
value="true"
>
<input
type="hidden"
name="username"
value="<?php echo $_GET['username']; ?>"
>
<input
type="hidden"
name="domain"
value="<?php echo $_GET['domain']; ?>"
>
<input class="button" type="submit" name="confirmed" value="<?php print _("Yes, delete"); ?>">
<input class="button" type="submit" name="cancel" value="<?php print _("Cancel"); ?>" >
</form>
<?php
} elseif (!empty($_GET['cancel'])){
?>
<h3>
<?php print _("Action cancelled, nothing deleted");?>
</h3>
<?php
include WC_BASE . "/adminuser.php";
} else {
$query = "DELETE FROM adminuser WHERE username='".$_GET['username']."'";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
# The admin also needs to be deleted from the assigment table
$query = "DELETE FROM domainadmin WHERE adminuser='".$_GET['username']."'";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
# The admin also needs to be deleted from the settings table
$query = "DELETE FROM settings WHERE username='".$_GET['username']."'";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
?>
<h3>
<?php print _("Admin user deleted");?>
:
<span style="color: red;">
<?php echo $_GET['username'];?>
</span>
</h3>
<?php
include WC_BASE . "/adminuser.php";
}
} else {
?>
<h3>
<?php print $err_msg;?>
</h3>
<a href="index.php?action=adminuser&domain=<?php echo $_GET['domain'];?>"><?php print _("Back");?></a>
<?php
}
?>
</td>
</tr>
<!-- #################### deleteadminuser.php end #################### -->