forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowse.php
250 lines (221 loc) · 8.42 KB
/
browse.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<?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();
}
?>
<!-- ############################## Start browse.php ###################################### -->
<tr>
<td width="10"> </td>
<td valign="top">
<h3>
<?php print _("Browse domains");?>
</h3>
<?php
if (isset($_GET['row_pos'])) $_SESSION['domain_row_pos'] = $_GET['row_pos'];
// $_SESSION['domain_row_pos'] = $row_pos;
if (isset($_GET['orderby'])) {
if ($_SESSION['domain_orderby'] == $_GET['orderby']) {
if ($_SESSION['domain_orderby_desc']=="asc") {
$_SESSION['domain_orderby_desc'] = "desc";
} else {
$_SESSION['domain_orderby_desc'] = "asc";
}
} else {
$_SESSION['domain_orderby_desc'] = "asc";
}
$_SESSION['domain_orderby'] = $_GET['orderby'];
}
// $_SESSION['domain_orderby'] = $orderby;
?>
<!-- <table border="1" width="98%"> -->
<?php
if (! isset($_SESSION['allowed_domains'])) {
#$query = "SELECT * FROM domain ORDER BY domain_name";
$query = "SELECT * FROM domain ORDER BY ".$_SESSION['domain_orderby']." ".$_SESSION['domain_orderby_desc'];
} else {
$domains = '';
foreach ($_SESSION['allowed_domains'] as $allowed_domain) {
$domains .= $allowed_domain."' OR domain_name='";
}
$query = "SELECT * FROM domain WHERE domain_name='$domains' ORDER BY ".$_SESSION['domain_orderby']." ".$_SESSION['domain_orderby_desc'];
}
$result = $handle->query($query);
if (DB::isError($result)) {
die (_("Database error"));
}
// $result = $handle->limitQuery($query,$row_pos,$_SESSION['maxdisplay']);
$cnt = $result->numRows($result);
print _("Total Domains:")." ".$cnt;
print "<br>"._("Displaying from position:")." ".($_SESSION['domain_row_pos']+1);
?>
<!-- </table> -->
<table cellspacing="2" cellpadding="0">
<tr>
<?php
if ($_SESSION['admintype']==0){
?>
<td class="navi">
<a class="navilink" href="index.php?action=newdomain&domain=new"><?php print _("Add new domain");?></a>
</td>
<td width="20"> </td>
<?php
}
$prev = $_SESSION['domain_row_pos'] - $_SESSION['maxdisplay'];
if ($prev < 0 ) $prev = 0;
$next = $_SESSION['domain_row_pos'] + $_SESSION['maxdisplay'];
$last = $cnt - $_SESSION['maxdisplay'];
if ($_SESSION['domain_row_pos'] <= 0){
print "<td class=\"navi\"><a class=\"navilink\">"._("First entry") ."</a></td>";
print "<td class=\"navi\"><a class=\"navilink\">"._("Previous entries")."</a></td>";
} else {
print "<td class=\"navi\"><a class=\"navilink\" href=\"index.php?action=browse&row_pos=0\">"._("First entry") ."</a></td>";
print "<td class=\"navi\"><a class=\"navilink\" href=\"index.php?action=browse&row_pos=$prev\">"._("Previous entries") ."</a></td>";
}
if ($next>=$cnt){
print "<td class=\"navi\"><a>"._("Next entries")."</a></td>";
print "<td class=\"navi\"><a class=\"navilink\">"._("Last entry") ."</a></td>";
} else {
print "<td class=\"navi\"><a class=\"navilink\" href=\"index.php?action=browse&row_pos=$next\">". _("Next entries")."</a></td>";
print "<td class=\"navi\"><a class=\"navilink\" href=\"index.php?action=browse&row_pos=$last\">"._("Last entry") ."</a></td>";
}
?>
</tr>
</table>
<table width="99%">
<tbody>
<tr>
<?php
print ($_SESSION['admintype']==0)?"<th colspan=\"4\">":"<th colspan=\"2\">";
print _("action");
?>
</th>
<th>
<!-- <?php print _("domainname");?> -->
<?php
print "<a class=\"th_a\" href=\"index.php?action=browse&orderby=domain_name\">"._("domainname")."</a>";
if ($_SESSION['domain_orderby'] == 'domain_name') print "<img src=\"images/arrow_sort_".$_SESSION['domain_orderby_desc'].".png\" border=\"0\">";
?>
</th>
<?php
if (! $DOMAIN_AS_PREFIX){
?>
<th>
<?php print "<a class=\"th_a\" href=\"index.php?action=browse&orderby=prefix\">"._("prefix")."</a>";
if ($_SESSION['domain_orderby'] == 'prefix') print "<img src=\"images/arrow_sort_".$_SESSION['domain_orderby_desc'].".png\" border=\"0\">";
?>
</th>
<?php
}
?>
<th>
<?php print "<a class=\"th_a\" href=\"index.php?action=browse&orderby=maxaccounts\">"._("max Accounts")."</a>";
if ($_SESSION['domain_orderby'] == 'maxaccounts') print "<img src=\"images/arrow_sort_".$_SESSION['domain_orderby_desc'].".png\" border=\"0\">";
?>
</th>
<th>
<!-- <?php print _("Domain quota");?> -->
<?php print "<a class=\"th_a\" href=\"index.php?action=browse&orderby=domainquota\">"._("Domain quota")."</a>";
if ($_SESSION['domain_orderby'] == 'domainquota') print "<img src=\"images/arrow_sort_".$_SESSION['domain_orderby_desc'].".png\" border=\"0\">";
?>
</th>
<th>
<!-- <?php print _("default quota per user");?> -->
<?php print "<a class=\"th_a\" href=\"index.php?action=browse&orderby=quota\">"._("default quota per user")."</a>";
if ($_SESSION['domain_orderby'] == 'quota') print "<img src=\"images/arrow_sort_".$_SESSION['domain_orderby_desc'].".png\" border=\"0\">";
?>
</th>
</tr>
<?php
for ($c=$_SESSION['domain_row_pos']; $c < (($next>$cnt)?($cnt):($next)); $c++){
if ($c%2==0){
$cssrow="row1";
} else {
$cssrow="row2";
}
$row = $result->fetchRow(DB_FETCHMODE_ASSOC,$c);
?>
<tr class="<?php echo $cssrow;?>">
<?php
if ($_SESSION['admintype']==0) {
$_cols = array(
'editdomain' => _("Edit Domain"),
'deletedomain' => _("Delete Domain"),
);
foreach ($_cols as $_action => $_txt){
?>
<td>
<?php
printf ('<a href="index.php?action=%s&domain=%s">%s</a>',
$_action, $row['domain_name'], $_txt);
?>
</td>
<?php
}
}
?>
<td>
<?php
if ($row['transport'] == 'cyrus') {
echo "<a href=\"index.php?action=accounts&domain=".$row['domain_name']."\">";
print _("accounts");
echo "</a>";
} else {
print _("accounts");
}
?>
</td>
<td>
<?php
if ($row['transport'] == 'cyrus') {
echo "<a href=\"index.php?action=aliases&domain=".$row['domain_name']."\">";
print _("Aliases");
echo "</a>";
} else {
print _("Aliases");
}
?>
</td>
<td>
<?php echo $row['domain_name'];?>
</td>
<?php
if (! $DOMAIN_AS_PREFIX){
# Print the prefix
echo "<td>";
echo $row['prefix'];
echo "</td>";
}
?>
<td align="right">
<!-- Max Account -->
<?php
echo $row['maxaccounts'];
?>
</td>
<td align="right">
<!-- Max Domain Quota -->
<?php
if (! $row['domainquota'] == 0) {
echo $row['domainquota'];
} else {
print _("Quota not set");
}
?>
</td>
<td align="right">
<!-- Default Account Quota -->
<?php
echo $row['quota'];
?>
</td>
</tr>
<?php
} // End of for
?>
</tbody>
</table>
<p>
<!-- ############################### End browse.php ############################################# -->