forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatchall.php
137 lines (121 loc) · 3.7 KB
/
catchall.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
131
132
133
134
135
136
<?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();
}
?>
<!-- #################### catchall.php start #################### -->
<tr>
<td width="10"> </td>
<td valign="top">
<h3>
<?php print _("Define a Account for receiving undefined adresses for domain");?>
<span style="color: red;">
<?php echo $_GET['domain'];?>
</span>
</h3>
<?php
if ($authorized) {
if (empty($_GET['confirmed'])){
$query = "SELECT * FROM virtual WHERE alias='@".$_GET['domain']."'";
$result = $handle->query($query);
$cnt = $result->numRows();
$row = $result->fetchRow(DB_FETCHMODE_ASSOC, 0);
$current_username=$row['username'];
if (empty($cnt) OR $current_username != $username){
?>
<h3>
<?php print _("Do you really want to define the user");?>
<span style="color: red;">
<?php echo $username;?>
</span>
<?php print _("to receive all undefined emailadresses");
print "?";
print "</h3>";
if ($cnt==1){
print _("The currently defined user")." ".$current_username." "._("will not receiving any undefined emailadresses anymore");
}
?>
<form action="index.php" method="get">
<input type="hidden" name="action"
value="catch">
<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 $username; ?>">
<input class="button" type="submit"
name="confirmed"
value="<?php print _("Yes"); ?>">
<input class="button" type="submit"
name="cancel"
value="<?php print _("Cancel"); ?>">
</form>
<?php
}
else if ($cnt==1 AND $current_username==$username){
print _("The user")." ".$current_username." "._("is allready defined to receive all undefined Emails.");
print "<h3>";
print _("Do you want to remove the function \"catch all\" for the account");
print " ".$current_username;
print "?";
print "</h3>";
?>
<form action="index.php" method="get">
<input type="hidden" name="action"
value="delete_catchall">
<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 $username; ?>">
<input class="button" type="submit"
name="confirmed"
value="<?php print _("Yes"); ?>">
<input class="button" type="submit"
name="cancel"
value="<?php print _("Cancel"); ?>">
</form>
<?php
}
} elseif (!empty($_GET['confirmed']) && empty($_GET['cancel'])){
# First Delete the entry from the database
$query = "DELETE FROM virtual WHERE alias='@".$_GET['domain']."'";
$result = $handle->query($query);
# And then add the new one
$query = "INSERT INTO virtual (alias, dest, username, status) values ('@".$_GET['domain']."' , '$username' , '$username' , '1')";
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
} else {
?>
<h3>
<?php print _("successfully added to Database");?>
</h3>
<?php
include WC_BASE . "/browseaccounts.php";
}
} elseif (!empty($_GET['cancel'])){
?>
<h3>
<?php print _("Cancelled");?>
</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>
<!-- #################### catchall.php end #################### -->