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 (is_ipaddr($gateway['gateway']))
|
75
|
echo htmlspecialchars($gateway['gateway']);
|
76
|
else {
|
77
|
if($gateway['ipprotocol'] == "inet")
|
78
|
echo htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
|
79
|
if($gateway['ipprotocol'] == "inet6")
|
80
|
echo htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
|
81
|
if( (htmlspecialchars(get_interface_gateway($gateway['friendlyiface'])) == '') && (htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface'])) == '') )
|
82
|
echo '~';
|
83
|
}
|
84
|
$counter++;
|
85
|
?>
|
86
|
</div>
|
87
|
</td>
|
88
|
</tr>
|
89
|
</table>
|
90
|
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="table-layout: fixed;" summary="statistics">
|
91
|
<tr>
|
92
|
<td width="25%" class="listlr ellipsis" align="center" id="gateway<?php echo $counter; ?>">
|
93
|
<?php
|
94
|
if ($gateways_status[$gname])
|
95
|
echo htmlspecialchars($gateways_status[$gname]['delay']);
|
96
|
else
|
97
|
echo gettext("Pending");
|
98
|
?>
|
99
|
<?php $counter++; ?>
|
100
|
</td>
|
101
|
<td width="25%" class="listr ellipsis" align="center" id="gateway<?php echo $counter; ?>">
|
102
|
<?php
|
103
|
if ($gateways_status[$gname])
|
104
|
echo htmlspecialchars($gateways_status[$gname]['loss']);
|
105
|
else
|
106
|
echo gettext("Pending");
|
107
|
?>
|
108
|
<?php $counter++; ?>
|
109
|
</td>
|
110
|
<td width="50%" class="listr ellipsis" id="gateway<?php echo $counter ?>" >
|
111
|
<table border="0" cellpadding="0" cellspacing="2" style="table-layout: fixed;" summary="status">
|
112
|
<?php
|
113
|
if ($gateways_status[$gname]) {
|
114
|
if (stristr($gateways_status[$gname]['status'], "force_down")) {
|
115
|
$online = "Offline (forced)";
|
116
|
$bgcolor = "#F08080"; // lightcoral
|
117
|
} elseif (stristr($gateways_status[$gname]['status'], "down")) {
|
118
|
$online = "Offline";
|
119
|
$bgcolor = "#F08080"; // lightcoral
|
120
|
} elseif (stristr($gateways_status[$gname]['status'], "loss")) {
|
121
|
$online = "Packetloss";
|
122
|
$bgcolor = "#F0E68C"; // khaki
|
123
|
} elseif (stristr($gateways_status[$gname]['status'], "delay")) {
|
124
|
$online = "Latency";
|
125
|
$bgcolor = "#F0E68C"; // khaki
|
126
|
} elseif ($gateways_status[$gname]['status'] == "none") {
|
127
|
$online = "Online";
|
128
|
$bgcolor = "#90EE90"; // lightgreen
|
129
|
} elseif ($gateways_status[$gname]['status'] == "") {
|
130
|
$online = "Pending";
|
131
|
$bgcolor = "#D3D3D3"; // lightgray
|
132
|
}
|
133
|
} else {
|
134
|
$online = gettext("Unknown");
|
135
|
$bgcolor = "#ADD8E6"; // lightblue
|
136
|
}
|
137
|
echo "<tr><td class=\"ellipsis\" bgcolor=\"$bgcolor\"> $online </td></tr>\n";
|
138
|
$counter++;
|
139
|
?>
|
140
|
</table>
|
141
|
</td>
|
142
|
</tr>
|
143
|
</table>
|
144
|
</td>
|
145
|
</tr>
|
146
|
<?php } // foreach ?>
|
147
|
</table>
|
148
|
|
149
|
|