forked from web-cyradm/web-cyradm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliases.php
103 lines (96 loc) · 3.05 KB
/
aliases.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
<?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 aliases.php ################################# -->
<tr>
<td width="10"> </td>
<td valign="top">
<h3><?php print _("Browse aliases for domain")?> <font color=red><?php print( $_GET['domain'] ); ?></font></h3>
<?php
if ($authorized) {
$query = "SELECT COUNT(DISTINCT(alias)) FROM virtual WHERE username = '".$_GET['domain']."'";
$alias_count = $handle->getOne($query);
$row_pos = (empty($_GET['row_pos']))?(0):($_GET['row_pos']);
$prev = $row_pos -10;
$next = $row_pos +10;
if ($row_pos<10) {
$prev_url = "#";
} else {
$prev_url = "index.php?action=aliases&domain=".$_GET['domain']."&row_pos=".$prev;
}
if ($next >= $alias_count) {
$next_url = "#";
} else {
$next_url = "index.php?action=aliases&domain=".$_GET['domain']."&row_pos=".$next;
}
print _("Total aliases").":".$alias_count;
?><P>
<table cellspacing="2" cellpadding="0">
<tr>
<td class="navi"><a class="navilink" href="index.php?action=newalias&domain=<?php print $_GET['domain']; ?>">
<?php print _("Add new alias");?></a></td>
<td class="navi"><a class="navilink" href="<?php print($prev_url); ?>"><?php print _("Previous 10 entries");?></a></td>
<td class="navi"><a class="navilink" href="<?php print($next_url); ?>"><?php print _("Next 10 entries");?></a></td>
</tr>
</table>
<p>
<table border="0">
<tbody>
<tr>
<th colspan="2"><?php print _("action");?></th>
<th><?php print _("Email address"); ?></th>
<th><?php print _("Destination"); ?></th>
</tr>
<?php
$query = "SELECT DISTINCT(alias) FROM virtual WHERE username = '".$_GET['domain']."'";
$result = $handle->limitQuery($query,$row_pos,10);
$num_alias = $result->numRows();
$b = 0;
for($c = 0;$c < $num_alias;$c++) {
if ($c%2==0){
$cssrow = "row1";
} else {
$cssrow = "row2";
}
$row = $result->fetchRow(DB_FETCHMODE_ASSOC,$c);
$alias = $row['alias'];
?>
<tr class="<?php print($cssrow); ?>">
<td><a href="index.php?action=editalias&alias=<?php print($alias); ?>&domain=<?php print($_GET['domain']); ?>"><?php print _("Edit Alias"); ?></a></td>
<td><a href="index.php?action=deletealias&alias=<?php print($alias); ?>&domain=<?php print($_GET['domain']); ?>"><?php print _("Delete Alias"); ?></a></td>
<td><?php print($alias); ?></td>
<td>
<?php
$query1 = "SELECT dest FROM virtual WHERE alias = '".$alias."'";
#$result1 = $handle->query($query1);
$result1 = $handle->Query($query1);
$cnt = $result1->numRows();
$num_dest = ($cnt<3)?($cnt):(3);
for($d = 0;$d < $num_dest;$d++) {
$row2 = $result1->fetchRow(DB_FETCHMODE_ASSOC,$d);
if($d != 0) {
print ", ";
}
print($row2['dest']);
}
if ($cnt > 3) {
print ", ... ";
}
?>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
?>
</td>
</tr>
<!-- ##################################### End aliases.php #################################### -->