Project

General

Profile

Download (4.85 KB) Statistics
| Branch: | Tag: | Revision:
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" summary="heading">
52
			<tr>
53
			<td width="25%" class="listhdrr">RTT</td>
54
			<td width="25%" class="listhdrr">Loss</td>
55
			<td width="50%" class="listhdrr">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">
69
		<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="address">
70
			<tr>
71
			<td class="vncellt" 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
						}
82
						$counter++;
83
					?>
84
				</div>
85
			</td>
86
			</tr>
87
		</table>
88
		<table width="100%" border="0" cellspacing="0" cellpadding="0" summary="statistics">
89
			<tr>
90
			<td width="25%" class="listlr" align="center" id="gateway<?php echo $counter; ?>">
91
			<?php
92
				if ($gateways_status[$gname])
93
					echo htmlspecialchars($gateways_status[$gname]['delay']);
94
				else
95
					echo gettext("Pending");
96
			?>
97
			<?php $counter++; ?>
98
			</td>
99
			<td width="25%" class="listr" align="center" id="gateway<?php echo $counter; ?>">
100
			<?php
101
				if ($gateways_status[$gname])
102
					echo htmlspecialchars($gateways_status[$gname]['loss']);
103
				else
104
					echo gettext("Pending");
105
			?>
106
			<?php $counter++; ?>
107
			</td>
108
			<td width="50%" class="listr" id="gateway<?php echo $counter ?>" >
109
			<table border="0" cellpadding="0" cellspacing="2" summary="status">
110
			<?php
111
				if ($gateways_status[$gname]) {
112
					if (stristr($gateways_status[$gname]['status'], "down")) {
113
						$online = "Offline";
114
						$bgcolor = "#F08080";  // lightcoral
115
					} elseif (stristr($gateways_status[$gname]['status'], "loss")) {
116
						$online = "Packetloss";
117
						$bgcolor = "#F0E68C";  // khaki
118
					} elseif (stristr($gateways_status[$gname]['status'], "delay")) {
119
						$online = "Latency";
120
						$bgcolor = "#F0E68C";  // khaki
121
					} elseif ($gateways_status[$gname]['status'] == "none") {
122
						$online = "Online";
123
						$bgcolor = "#90EE90";  // lightgreen
124
					} elseif ($gateways_status[$gname]['status'] == "") {
125
						$online = "Pending";
126
						$bgcolor = "#D3D3D3";  // lightgray
127
					}
128
				} else {
129
					$online = gettext("Unknown");
130
					$bgcolor = "#ADD8E6";  // lightblue
131
				}
132
				echo "<tr><td bgcolor=\"$bgcolor\">&nbsp;$online&nbsp;</td></tr>\n";
133
				$counter++;
134
			?>
135
			</table>
136
			</td>
137
			</tr>
138
		</table>
139
	</td>
140
	</tr>
141
	<?php } // foreach ?>
142
</table>
(4-4/20)