1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
status_gateway_groups.php
|
5
|
part of pfSense (http://pfsense.com)
|
6
|
|
7
|
Copyright (C) 2007 Seth Mos <seth.mos@xs4all.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
|
##|+PRIV
|
33
|
##|*IDENT=page-status-gatewaygroups
|
34
|
##|*NAME=Status: Gateway Groups page
|
35
|
##|*DESCR=Allow access to the 'Status: Gateway Groups' page.
|
36
|
##|*MATCH=status_gateway_groups.php*
|
37
|
##|-PRIV
|
38
|
|
39
|
|
40
|
require("guiconfig.inc");
|
41
|
|
42
|
if (!is_array($config['gateways']['gateway_group']))
|
43
|
$config['gateways']['gateway_group'] = array();
|
44
|
|
45
|
if (!is_array($config['gateways']['gateway_item']))
|
46
|
$config['gateways']['gateway_item'] = array();
|
47
|
|
48
|
$a_gateway_groups = &$config['gateways']['gateway_group'];
|
49
|
$a_gateways = &$config['gateways']['gateway_item'];
|
50
|
$changedesc = "Gateway Groups: ";
|
51
|
|
52
|
$gateways_status = array();
|
53
|
$gateways_status = return_gateways_status();
|
54
|
|
55
|
if ($_POST) {
|
56
|
|
57
|
$pconfig = $_POST;
|
58
|
|
59
|
if ($_POST['apply']) {
|
60
|
|
61
|
$retval = 0;
|
62
|
|
63
|
$retval = system_routing_configure();
|
64
|
$retval |= filter_configure();
|
65
|
|
66
|
$savemsg = get_std_save_message($retval);
|
67
|
if ($retval == 0) {
|
68
|
if (file_exists($d_staticroutesdirty_path)) {
|
69
|
config_lock();
|
70
|
unlink($d_staticroutesdirty_path);
|
71
|
config_unlock();
|
72
|
}
|
73
|
}
|
74
|
}
|
75
|
}
|
76
|
|
77
|
if ($_GET['act'] == "del") {
|
78
|
if ($a_gateway_groups[$_GET['id']]) {
|
79
|
$changedesc .= "removed gateway group {$_GET['id']}";
|
80
|
unset($a_gateway_groups[$_GET['id']]);
|
81
|
write_config($changedesc);
|
82
|
touch($d_staticroutesdirty_path);
|
83
|
header("Location: system_gateway_groups.php");
|
84
|
exit;
|
85
|
}
|
86
|
}
|
87
|
|
88
|
$pgtitle = array("Status","Gateway Groups");
|
89
|
include("head.inc");
|
90
|
|
91
|
?>
|
92
|
|
93
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
94
|
<?php include("fbegin.inc"); ?>
|
95
|
<form action="system_gateway_groups.php" method="post">
|
96
|
<input type="hidden" name="y1" value="1">
|
97
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
98
|
<?php if (file_exists($d_staticroutesdirty_path)): ?><p>
|
99
|
<?php print_info_box_np("The gateway configuration has been changed.<br>You must apply the changes in order for them to take
|
100
|
effect.");?><br>
|
101
|
<?php endif; ?>
|
102
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
103
|
<tr>
|
104
|
<td>
|
105
|
<?php
|
106
|
$tab_array = array();
|
107
|
$tab_array[0] = array("Gateways", false, "status_gateways.php");
|
108
|
$tab_array[1] = array("Groups", true, "status_gateway_groups.php");
|
109
|
display_top_tabs($tab_array);
|
110
|
?>
|
111
|
</td></tr>
|
112
|
<tr>
|
113
|
<td>
|
114
|
<div id="mainarea">
|
115
|
<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
|
116
|
<tr>
|
117
|
<td width="20%" class="listhdrr">Group Name</td>
|
118
|
<td width="50%" class="listhdrr">Gateways</td>
|
119
|
<td width="30%" class="listhdr">Description</td>
|
120
|
</tr>
|
121
|
<?php $i = 0; foreach ($a_gateway_groups as $gateway_group): ?>
|
122
|
<tr>
|
123
|
<td class="listlr">
|
124
|
<?php
|
125
|
echo $gateway_group['name'];
|
126
|
?>
|
127
|
|
128
|
</td>
|
129
|
<td class="listr">
|
130
|
<table border='0'>
|
131
|
<?php
|
132
|
/* process which priorities we have */
|
133
|
$priorities = array();
|
134
|
foreach($gateway_group['item'] as $item) {
|
135
|
$itemsplit = explode("|", $item);
|
136
|
$priorities[$itemsplit[1]] = true;
|
137
|
}
|
138
|
$priority_count = count($priorities);
|
139
|
|
140
|
echo "<tr>";
|
141
|
foreach($priorities as $number => $tier) {
|
142
|
echo "<td width='120'>Tier $number</td>";
|
143
|
}
|
144
|
echo "</tr>\n";
|
145
|
|
146
|
/* inverse gateway group to gateway priority */
|
147
|
$priority_arr = array();
|
148
|
foreach($gateway_group['item'] as $item) {
|
149
|
$itemsplit = explode("|", $item);
|
150
|
$priority_arr[$itemsplit[1]][] = $itemsplit[0];
|
151
|
}
|
152
|
|
153
|
// echo print_r($priority_arr, true);
|
154
|
$p = 1;
|
155
|
foreach($priority_arr as $number => $tier) {
|
156
|
/* for each priority process the gateways */
|
157
|
foreach($tier as $member) {
|
158
|
/* we always have $priority_count fields */
|
159
|
echo "<tr>";
|
160
|
$c = 1;
|
161
|
while($c <= $priority_count) {
|
162
|
if($p == $c) {
|
163
|
$monitor = lookup_gateway_monitor_ip_by_name($member);
|
164
|
switch($gateways_status[$monitor]['status']) {
|
165
|
case "None":
|
166
|
$online = "Online";
|
167
|
$bgcolor = "lightgreen";
|
168
|
break;
|
169
|
case "\"down\"":
|
170
|
$online = "Offline";
|
171
|
$bgcolor = "lightcoral";
|
172
|
break;
|
173
|
case "\"delay\"":
|
174
|
$online = "Warning, Latency";
|
175
|
$bgcolor = "khaki";
|
176
|
break;
|
177
|
case "\"loss\"":
|
178
|
$online = "Warning, Packetloss";
|
179
|
$bgcolor = "khaki";
|
180
|
break;
|
181
|
}
|
182
|
echo "<td bgcolor='$bgcolor'>". htmlspecialchars($member) ."</td>";
|
183
|
} else {
|
184
|
echo "<td> </td>";
|
185
|
}
|
186
|
$c++;
|
187
|
}
|
188
|
echo "</tr>\n";
|
189
|
}
|
190
|
$p++;
|
191
|
}
|
192
|
?>
|
193
|
</table>
|
194
|
</td>
|
195
|
<td class="listbg">
|
196
|
<font color="#FFFFFF"><?=htmlspecialchars($gateway_group['descr']);?>
|
197
|
</td>
|
198
|
</tr>
|
199
|
<?php $i++; endforeach; ?>
|
200
|
|
201
|
</table>
|
202
|
</div>
|
203
|
</td>
|
204
|
</tr>
|
205
|
</table>
|
206
|
</form>
|
207
|
<?php include("fend.inc"); ?>
|
208
|
</body>
|
209
|
</html>
|