1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_gateway_groups.php
|
5
|
part of pfSense (https://www.pfsense.org)
|
6
|
|
7
|
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
|
8
|
All rights reserved.
|
9
|
|
10
|
Redistribution and use in source and binary forms, with or without
|
11
|
modification, are permitted provided that the following conditions are met:
|
12
|
|
13
|
1. Redistributions of source code must retain the above copyright notice,
|
14
|
this list of conditions and the following disclaimer.
|
15
|
|
16
|
2. Redistributions in binary form must reproduce the above copyright
|
17
|
notice, this list of conditions and the following disclaimer in the
|
18
|
documentation and/or other materials provided with the distribution.
|
19
|
|
20
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
POSSIBILITY OF SUCH DAMAGE.
|
30
|
*/
|
31
|
/*
|
32
|
pfSense_MODULE: routing
|
33
|
*/
|
34
|
|
35
|
##|+PRIV
|
36
|
##|*IDENT=page-status-gatewaygroups
|
37
|
##|*NAME=Status: Gateway Groups page
|
38
|
##|*DESCR=Allow access to the 'Status: Gateway Groups' page.
|
39
|
##|*MATCH=status_gateway_groups.php*
|
40
|
##|-PRIV
|
41
|
|
42
|
require("guiconfig.inc");
|
43
|
|
44
|
if (!is_array($config['gateways']['gateway_group']))
|
45
|
$config['gateways']['gateway_group'] = array();
|
46
|
|
47
|
$a_gateway_groups = &$config['gateways']['gateway_group'];
|
48
|
$changedesc = gettext("Gateway Groups") . ": ";
|
49
|
|
50
|
$gateways_status = return_gateways_status();
|
51
|
|
52
|
$pgtitle = array(gettext("Status"),gettext("Gateway Groups"));
|
53
|
$shortcut_section = "gateway-groups";
|
54
|
include("head.inc");
|
55
|
|
56
|
?>
|
57
|
|
58
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
59
|
<?php include("fbegin.inc"); ?>
|
60
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
61
|
<tr>
|
62
|
<td>
|
63
|
<?php
|
64
|
$tab_array = array();
|
65
|
$tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php");
|
66
|
$tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php");
|
67
|
display_top_tabs($tab_array);
|
68
|
?>
|
69
|
</td></tr>
|
70
|
<tr>
|
71
|
<td>
|
72
|
<div id="mainarea">
|
73
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
74
|
<tr>
|
75
|
<td width="20%" class="listhdrr"><?=gettext("Group Name"); ?></td>
|
76
|
<td width="50%" class="listhdrr"><?=gettext("Gateways"); ?></td>
|
77
|
<td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
|
78
|
</tr>
|
79
|
<?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
|
80
|
<tr>
|
81
|
<td class="listlr">
|
82
|
<?php
|
83
|
echo $gateway_group['name'];
|
84
|
?>
|
85
|
|
86
|
</td>
|
87
|
<td class="listr">
|
88
|
<table border='0'>
|
89
|
<?php
|
90
|
/* process which priorities we have */
|
91
|
$priorities = array();
|
92
|
foreach($gateway_group['item'] as $item) {
|
93
|
$itemsplit = explode("|", $item);
|
94
|
$priorities[$itemsplit[1]] = true;
|
95
|
}
|
96
|
$priority_count = count($priorities);
|
97
|
ksort($priorities);
|
98
|
|
99
|
echo "<tr>";
|
100
|
foreach($priorities as $number => $tier) {
|
101
|
echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>";
|
102
|
}
|
103
|
echo "</tr>\n";
|
104
|
|
105
|
/* inverse gateway group to gateway priority */
|
106
|
$priority_arr = array();
|
107
|
foreach($gateway_group['item'] as $item) {
|
108
|
$itemsplit = explode("|", $item);
|
109
|
$priority_arr[$itemsplit[1]][] = $itemsplit[0];
|
110
|
}
|
111
|
ksort($priority_arr);
|
112
|
$p = 1;
|
113
|
foreach($priority_arr as $number => $tier) {
|
114
|
/* for each priority process the gateways */
|
115
|
foreach($tier as $member) {
|
116
|
/* we always have $priority_count fields */
|
117
|
echo "<tr>";
|
118
|
$c = 1;
|
119
|
while($c <= $priority_count) {
|
120
|
$monitor = lookup_gateway_monitor_ip_by_name($member);
|
121
|
if($p == $c) {
|
122
|
$status = $gateways_status[$monitor]['status'];
|
123
|
if (stristr($status, "down")) {
|
124
|
$online = gettext("Offline");
|
125
|
$bgcolor = "#F08080"; // lightcoral
|
126
|
} elseif (stristr($status, "loss")) {
|
127
|
$online = gettext("Warning, Packetloss");
|
128
|
$bgcolor = "#F0E68C"; // khaki
|
129
|
} elseif (stristr($status, "delay")) {
|
130
|
$online = gettext("Warning, Latency");
|
131
|
$bgcolor = "#F0E68C"; // khaki
|
132
|
} elseif ($status == "none") {
|
133
|
$online = gettext("Online");
|
134
|
$bgcolor = "#90EE90"; // lightgreen
|
135
|
} else {
|
136
|
$online = gettext("Gathering data");
|
137
|
$bgcolor = "#ADD8E6"; // lightblue
|
138
|
}
|
139
|
echo "<td bgcolor='$bgcolor'> ". htmlspecialchars($member) .", $online </td>";
|
140
|
} else {
|
141
|
echo "<td> </td>";
|
142
|
}
|
143
|
$c++;
|
144
|
}
|
145
|
echo "</tr>\n";
|
146
|
}
|
147
|
$p++;
|
148
|
}
|
149
|
?>
|
150
|
</table>
|
151
|
</td>
|
152
|
<td class="listbg">
|
153
|
<?=htmlspecialchars($gateway_group['descr']);?>
|
154
|
</td>
|
155
|
</tr>
|
156
|
<?php $i++; endforeach; ?>
|
157
|
|
158
|
</table>
|
159
|
</div>
|
160
|
</td>
|
161
|
</tr>
|
162
|
</table>
|
163
|
<?php include("fend.inc"); ?>
|
164
|
</body>
|
165
|
</html>
|