Project

General

Profile

Download (5.02 KB) Statistics
| Branch: | Tag: | Revision:
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
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9
	All rights reserved.
10

    
11
	Redistribution and use in source and binary forms, with or without
12
	modification, are permitted provided that the following conditions are met:
13

    
14
	1. Redistributions of source code must retain the above copyright notice,
15
	   this list of conditions and the following disclaimer.
16

    
17
	2. Redistributions in binary form must reproduce the above copyright
18
	   notice, this list of conditions and the following disclaimer in the
19
	   documentation and/or other materials provided with the distribution.
20

    
21
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
25
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
	POSSIBILITY OF SUCH DAMAGE.
31
*/
32
/*
33
	pfSense_MODULE:	routing
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-status-gatewaygroups
38
##|*NAME=Status: Gateway Groups page
39
##|*DESCR=Allow access to the 'Status: Gateway Groups' page.
40
##|*MATCH=status_gateway_groups.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if (!is_array($config['gateways']['gateway_group'])) {
46
	$config['gateways']['gateway_group'] = array();
47
}
48

    
49
$a_gateway_groups = &$config['gateways']['gateway_group'];
50
$changedesc = gettext("Gateway Groups") . ": ";
51

    
52
$gateways_status = return_gateways_status();
53

    
54
$pgtitle = array(gettext("Status"),gettext("Gateway Groups"));
55
$shortcut_section = "gateway-groups";
56
include("head.inc");
57

    
58
?>
59

    
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
61
<?php include("fbegin.inc"); ?>
62
<table width="100%" border="0" cellpadding="0" cellspacing="0">
63
	<tr>
64
		<td>
65
<?php
66
			$tab_array = array();
67
			$tab_array[0] = array(gettext("Gateways"), false, "status_gateways.php");
68
			$tab_array[1] = array(gettext("Gateway Groups"), true, "status_gateway_groups.php");
69
			display_top_tabs($tab_array);
70
?>
71
		</td>
72
	</tr>
73
	<tr>
74
		<td>
75
			<div id="mainarea">
76
				<table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
77
					<tr>
78
						<td width="20%" class="listhdrr"><?=gettext("Group Name"); ?></td>
79
						<td width="50%" class="listhdrr"><?=gettext("Gateways"); ?></td>
80
						<td width="30%" class="listhdr"><?=gettext("Description"); ?></td>
81
					</tr>
82
<?php
83
	$i = 0;
84
	foreach ($a_gateway_groups as $gateway_group):
85
?>
86
					<tr>
87
						<td class="listlr">
88
<?php
89
		echo $gateway_group['name'];
90
?>
91
						</td>
92
						<td class="listr">
93
							<table border='0'>
94
<?php
95
		/* process which priorities we have */
96
		$priorities = array();
97
		foreach ($gateway_group['item'] as $item) {
98
			$itemsplit = explode("|", $item);
99
			$priorities[$itemsplit[1]] = true;
100
		}
101
		$priority_count = count($priorities);
102
		ksort($priorities);
103

    
104
		echo "<tr>";
105
		foreach ($priorities as $number => $tier) {
106
			echo "<td width='120'>" . sprintf(gettext("Tier %s"), $number) . "</td>";
107
		}
108
		echo "</tr>\n";
109

    
110
		/* inverse gateway group to gateway priority */
111
		$priority_arr = array();
112
		foreach ($gateway_group['item'] as $item) {
113
			$itemsplit = explode("|", $item);
114
			$priority_arr[$itemsplit[1]][] = $itemsplit[0];
115
		}
116
		ksort($priority_arr);
117
		$p = 1;
118
		foreach ($priority_arr as $number => $tier) {
119
			/* for each priority process the gateways */
120
			foreach ($tier as $member) {
121
				/* we always have $priority_count fields */
122
				echo "<tr>";
123
				$c = 1;
124
				while ($c <= $priority_count) {
125
					$monitor = lookup_gateway_monitor_ip_by_name($member);
126
					if ($p == $c) {
127
						$status = $gateways_status[$monitor]['status'];
128
						if (stristr($status, "down")) {
129
							$online = gettext("Offline");
130
							$bgcolor = "#F08080";  // lightcoral
131
						} elseif (stristr($status, "loss")) {
132
							$online = gettext("Warning, Packetloss");
133
							$bgcolor = "#F0E68C";  // khaki
134
						} elseif (stristr($status, "delay")) {
135
							$online = gettext("Warning, Latency");
136
							$bgcolor = "#F0E68C";  // khaki
137
						} elseif ($status == "none") {
138
							$online = gettext("Online");
139
							$bgcolor = "#90EE90";  // lightgreen
140
						} else {
141
							$online = gettext("Gathering data");
142
							$bgcolor = "#ADD8E6";  // lightblue
143
						}
144
						echo "<td bgcolor='$bgcolor'>&nbsp;". htmlspecialchars($member) .", $online&nbsp;</td>";
145
					} else {
146
						echo "<td>&nbsp;</td>";
147
					}
148
					$c++;
149
				}
150
				echo "</tr>\n";
151
			}
152
			$p++;
153
		}
154
?>
155
							</table>
156
						</td>
157
						<td class="listbg">
158
							<?=htmlspecialchars($gateway_group['descr']);?>&nbsp;
159
						</td>
160
					</tr>
161
<?php
162
		$i++;
163
	endforeach;
164
?>
165

    
166
				</table>
167
			</div>
168
		</td>
169
	</tr>
170
</table>
171
<?php include("fend.inc"); ?>
172
</body>
173
</html>
(184-184/252)