forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteaccount.php
131 lines (113 loc) · 3 KB
/
deleteaccount.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?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();
}
?>
<!-- #################### deleteaccount.php start #################### -->
<tr>
<td width="10"> </td>
<td valign="top">
<?php
if ($authorized){
if (empty($_GET['confirmed'])){
?>
<h3>
<?php print _("Delete an Account from the System");?>
</h3>
<h3>
<?php print _("Do you really want to delete the user ");?>
<span style="color: red;">
<?php echo $_GET['username'];?>
</span>
<?php print _("with all its defined Emailadresses");?>
</h3>
<form action="index.php">
<input type="hidden"
name="action"
value="deleteaccount">
<input type="hidden"
name="confirmed"
value="true">
<input type="hidden"
name="domain"
value="<?php print $_GET['domain'];?>">
<input
type="hidden"
name="username"
value="<?php print $_GET['username'];?>">
<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");
include WC_BASE . "/browseaccounts.php";
?>
</h3>
<?php
} else {
$cyr_conn = new cyradm;
$error = $cyr_conn->imap_login();
if ($error != 0){
die ("Error: " . $error);
}
$query ="DELETE FROM virtual WHERE username='".$_GET['username']."'";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
// Removing forwards
$query = "DELETE FROM virtual WHERE alias='".$_GET['username']."' AND username=''";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
$query = "DELETE FROM accountuser WHERE username='".$_GET['username']."'";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
$query = "DELETE FROM log WHERE user='".$_GET['username']."'";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
if ($DOMAIN_AS_PREFIX) {
print $cyr_conn->deletemb("user/".$_GET['username']);
} else {
print $cyr_conn->deletemb("user.".$_GET['username']);
}
?>
<h3>
<?php print _("User deleted");?>:
<span style="color: red;">
<?php echo $_GET['username'];?>
</span>
</h3>
<?php
include WC_BASE . "/browseaccounts.php";
}
} else {
?>
<h3>
<?php print $err_msg;?>
</h3>
<a href="index.php?action=accounts&domain=<?php echo $_GET['domain'];?>"><?php print _("Back");?></a>
<?php
}
?>
</td>
</tr>
<!-- #################### deleteaccount.php end #################### -->