forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editaccount.php
175 lines (157 loc) · 5.06 KB
/
editaccount.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<?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();
}
?>
<!-- #################### editaccount.php start #################### -->
<tr>
<td width="10"> </td>
<td valign="top">
<?php
if ($authorized) {
include_once WC_BASE . '/lib/sieve-php.lib.php';
include_once WC_BASE . '/lib/sieve_strs.php';
$daemon = new sieve($CYRUS['HOST'],"2000", $CYRUS['ADMIN'], $CYRUS['PASS'], $_GET['username']);
$cyr_conn = new cyradm;
$cyr_conn->imap_login();
?>
<h3>
<?php print _("Email addresses defined for user");?>
<span style="color: red;">
<?php echo $_GET['username'];?>
</span>
</h3>
<?php
$query = "SELECT * FROM `virtual` WHERE username='".$_GET['username']."'"; # AND alias != '$username'";
$result = $handle->query($query);
$cnt = $result->numRows();
?>
<table cellspacing="2" cellpadding="0">
<tr>
<td class="navi">
<a class="navilink" href="index.php?action=newemail&domain=<?php echo $_GET['domain'];?>&username=<?php echo $_GET['username'];?>"><?php
print _("New email address");?></a>
</td>
</tr>
</table>
<table border="0">
<tr>
<th colspan="4">
<?php print _("action");?>
</th>
<th>
<?php print _("Email address");?>
</th>
<th>
<?php print _("Forward");?>
</th>
<!--
<th>
<?php print _("Username");?>
</th>
-->
<th>
<?php print _("Quota used");?>
</th>
</tr>
<?php
for ($c=0; $c < $cnt; $c++) {
if ($c%2==0){
$cssrow="row1";
} else {
$cssrow="row2";
}
$row = $result->fetchRow(DB_FETCHMODE_ASSOC, $c);
$alias = $row['alias'];
?>
<tr class="<?php echo $cssrow;?>">
<?php
$_cols = array(
'editemail' => _("Edit Emailadress"),
'forwardalias' => _("Forward"),
'vacation' => _("Vacation"),
'deleteemail' => _("Delete Emailadress")
);
foreach ($_cols as $_action => $_txt){
?>
<td align="center" valign="middle">
<a href="<?php printf("index.php?action=%s&domain=%s&alias=%s&username=%s", $_action, $_GET['domain'], $alias, $_GET['username']); ?>"><?php echo $_txt;?></a>
</td>
<?php
}
?>
<td valign="middle">
<?php echo $alias;?>
</td>
<td valign="middle">
<?php
if ($daemon->sieve_login()){
$sieve_str = new sieve_strs;
$old_script = $sieve_str->get_old_script($daemon);
if (preg_match("/redirect \".*$/siU", $old_script, $matches)){
$forwards_script = $matches[0];
$forwards_text = '';
while (preg_match ("/(redirect \")(.*)(\";)(.*$)/siU", $forwards_script, $matches)){
$forwards_text .= $matches[2].'<br>';
$forwards_script = $matches[4];
}
$forwards_text = rtrim ($forwards_text, ', ');
if (preg_match ("/keep;/i", $forwards_script, $matches)){
$forwards_text .= "<b>" . $username . "</b>";
}
} else {
$forwards_text ='';
$keep = '';
}
} else {
$forwards_text = '';
}
print $forwards_text;
?>
</td>
<?php
if ($c == 0) {
?>
<td valign="middle" rowspan="<?php echo $cnt;?>">
<?php
if ($DOMAIN_AS_PREFIX){
$quota = $cyr_conn->getquota("user/" . $_GET['username']);
} else {
$quota = $cyr_conn->getquota("user." . $_GET['username']);
}
if ($quota['used'] != 'NOT-SET'){
$q_used = $quota['used'];
$q_total = $quota['qmax'];
$q_percent = 100 * $q_used / $q_total;
printf ("%d MB %s %d MB (%.2f%%)",
$quota['used']/1024, _("out of"),
$quota['qmax']/1024, $q_percent);
} else {
print _("Quota not set");
}
?>
</td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
<?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>
<!-- #################### editaccount.php end #################### -->