1
|
<?php
|
2
|
/*
|
3
|
$Id$
|
4
|
Copyright 2008 Seth Mos
|
5
|
Part of pfSense widgets (https://www.pfsense.org)
|
6
|
originally based on m0n0wall (http://m0n0.ch/wall)
|
7
|
|
8
|
Redistribution and use in source and binary forms, with or without
|
9
|
modification, are permitted provided that the following conditions are met:
|
10
|
|
11
|
1. Redistributions of source code must retain the above copyright notice,
|
12
|
this list of conditions and the following disclaimer.
|
13
|
|
14
|
2. Redistributions in binary form must reproduce the above copyright
|
15
|
notice, this list of conditions and the following disclaimer in the
|
16
|
documentation and/or other materials provided with the distribution.
|
17
|
|
18
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
POSSIBILITY OF SUCH DAMAGE.
|
28
|
*/
|
29
|
|
30
|
$nocsrf = true;
|
31
|
|
32
|
require_once("guiconfig.inc");
|
33
|
require_once("pfsense-utils.inc");
|
34
|
require_once("functions.inc");
|
35
|
require_once("/usr/local/www/widgets/include/gateways.inc");
|
36
|
|
37
|
$a_gateways = return_gateways_array();
|
38
|
$gateways_status = array();
|
39
|
$gateways_status = return_gateways_status(true);
|
40
|
|
41
|
$counter = 1;
|
42
|
|
43
|
?>
|
44
|
|
45
|
<table bgcolor="#990000" width="100%" border="0" cellspacing="0" cellpadding="0" summary="gateway status">
|
46
|
<tr>
|
47
|
<td class="vncellt" width="30%" id="gatewayname">
|
48
|
Name
|
49
|
</td>
|
50
|
<td width="70%" class="listr">
|
51
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout: fixed;" summary="heading">
|
52
|
<tr>
|
53
|
<td width="25%" class="listhdrr ellipsis">RTT</td>
|
54
|
<td width="25%" class="listhdrr ellipsis">Loss</td>
|
55
|
<td width="50%" class="listhdrr ellipsis">Status</td>
|
56
|
</tr>
|
57
|
</table>
|
58
|
</td>
|
59
|
</tr>
|
60
|
<?php foreach ($a_gateways as $gname => $gateway) { ?>
|
61
|
<tr>
|
62
|
<td class="vncellt" width="30%" id="gateway<?php echo $counter; ?>">
|
63
|
<strong>
|
64
|
<?php echo htmlspecialchars($gateway['name']); ?>
|
65
|
</strong>
|
66
|
<?php $counter++; ?>
|
67
|
</td>
|
68
|
<td width="70%" class="listr ellipsis">
|
69
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout: fixed;" summary="address">
|
70
|
<tr>
|
71
|
<td class="vncellt ellipsis" width="100%">
|
72
|
<div id="gateway<?php echo $counter; ?>" style="display:inline">
|
73
|
<?php
|
74
|
$if_gw = '';
|
75
|
if (is_ipaddr($gateway['gateway']))
|
76
|
$if_gw = htmlspecialchars($gateway['gateway']);
|
77
|
else {
|
78
|
if($gateway['ipprotocol'] == "inet")
|
79
|
$if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
|
80
|
if($gateway['ipprotocol'] == "inet6")
|
81
|
$if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
|
82
|
}
|
83
|
echo ($if_gw == '' ? '~' : $if_gw);
|
84
|
unset ($if_gw);
|
85
|
$counter++;
|
86
|
?>
|
87
|
</div>
|
88
|
</td>
|
89
|
</tr>
|
90
|
</table>
|
91
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout: fixed;" summary="statistics">
|
92
|
<tr>
|
93
|
<td width="25%" class="listlr ellipsis" align="center" id="gateway<?php echo $counter; ?>">
|
94
|
<?php
|
95
|
if ($gateways_status[$gname])
|
96
|
echo htmlspecialchars($gateways_status[$gname]['delay']);
|
97
|
else
|
98
|
echo gettext("Pending");
|
99
|
?>
|
100
|
<?php $counter++; ?>
|
101
|
</td>
|
102
|
<td width="25%" class="listr ellipsis" align="center" id="gateway<?php echo $counter; ?>">
|
103
|
<?php
|
104
|
if ($gateways_status[$gname])
|
105
|
echo htmlspecialchars($gateways_status[$gname]['loss']);
|
106
|
else
|
107
|
echo gettext("Pending");
|
108
|
?>
|
109
|
<?php $counter++; ?>
|
110
|
</td>
|
111
|
<td width="50%" class="listr ellipsis" id="gateway<?php echo $counter ?>" >
|
112
|
<table border="0" cellpadding="0" cellspacing="2" style="table-layout: fixed;" summary="status">
|
113
|
<?php
|
114
|
if ($gateways_status[$gname]) {
|
115
|
if (stristr($gateways_status[$gname]['status'], "force_down")) {
|
116
|
$online = "Offline (forced)";
|
117
|
$bgcolor = "#F08080"; // lightcoral
|
118
|
} elseif (stristr($gateways_status[$gname]['status'], "down")) {
|
119
|
$online = "Offline";
|
120
|
$bgcolor = "#F08080"; // lightcoral
|
121
|
} elseif (stristr($gateways_status[$gname]['status'], "loss")) {
|
122
|
$online = "Packetloss";
|
123
|
$bgcolor = "#F0E68C"; // khaki
|
124
|
} elseif (stristr($gateways_status[$gname]['status'], "delay")) {
|
125
|
$online = "Latency";
|
126
|
$bgcolor = "#F0E68C"; // khaki
|
127
|
} elseif ($gateways_status[$gname]['status'] == "none") {
|
128
|
$online = "Online";
|
129
|
$bgcolor = "#90EE90"; // lightgreen
|
130
|
} elseif ($gateways_status[$gname]['status'] == "") {
|
131
|
$online = "Pending";
|
132
|
$bgcolor = "#D3D3D3"; // lightgray
|
133
|
}
|
134
|
} else {
|
135
|
$online = gettext("Unknown");
|
136
|
$bgcolor = "#ADD8E6"; // lightblue
|
137
|
}
|
138
|
echo "<tr><td class=\"ellipsis\" bgcolor=\"$bgcolor\"> $online </td></tr>\n";
|
139
|
$counter++;
|
140
|
?>
|
141
|
</table>
|
142
|
</td>
|
143
|
</tr>
|
144
|
</table>
|
145
|
</td>
|
146
|
</tr>
|
147
|
<?php } // foreach ?>
|
148
|
</table>
|
149
|
|
150
|
|