Projet

Général

Profil

Télécharger (4,61 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / widgets / widgets / gateways.widget.php @ 3877b513

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="listhdrr" id="gatewayname" align="center">Name</td>
48
		<td class="listhdrr" align="center">RTT</td>
49
		<td class="listhdrr" align="center">Loss</td>
50
		<td class="listhdrr" align="center">Status</td>
51
	</tr>
52
	<?php foreach ($a_gateways as $gname => $gateway) { ?>
53
	<tr>
54
	<td class="listhdrr" id="gateway<?php echo $counter; ?>" rowspan="2" align="center">
55
		<strong>
56
		<?php echo htmlspecialchars($gateway['name']); ?>
57
		</strong>
58
		<?php $counter++; ?>
59
	</td>
60
	<td colspan="3" class="listr ellipsis" summary="address" align="center">
61
				<div id="gateway<?php echo $counter; ?>" style="display:inline"><b>
62
					<?php
63
						$if_gw = '';
64
						if (is_ipaddr($gateway['gateway']))
65
							$if_gw = htmlspecialchars($gateway['gateway']);
66
						else {
67
							if($gateway['ipprotocol'] == "inet")
68
								$if_gw = htmlspecialchars(get_interface_gateway($gateway['friendlyiface']));
69
							if($gateway['ipprotocol'] == "inet6")
70
								$if_gw = htmlspecialchars(get_interface_gateway_v6($gateway['friendlyiface']));
71
						}
72
						echo ($if_gw == '' ? '~' : $if_gw);
73
						unset ($if_gw);
74
						$counter++;
75
					?>
76
				</b></div>
77
			</td>
78
	</tr>
79
	<tr>
80
			<td class="listr ellipsis" align="center" id="gateway<?php echo $counter; ?>">
81
			<?php
82
				if ($gateways_status[$gname])
83
					echo htmlspecialchars($gateways_status[$gname]['delay']);
84
				else
85
					echo gettext("Pending");
86
			?>
87
			<?php $counter++; ?>
88
			</td>
89
			<td class="listr ellipsis" align="center" id="gateway<?php echo $counter; ?>">
90
			<?php
91
				if ($gateways_status[$gname])
92
					echo htmlspecialchars($gateways_status[$gname]['loss']);
93
				else
94
					echo gettext("Pending");
95
			?>
96
			<?php $counter++; ?>
97
			</td>
98
			<?php
99
				if ($gateways_status[$gname]) {
100
					if (stristr($gateways_status[$gname]['status'], "force_down")) {
101
						$online = "Offline (forced)";
102
						$bgcolor = "#F08080";  // lightcoral
103
					} elseif (stristr($gateways_status[$gname]['status'], "down")) {
104
						$online = "Offline";
105
						$bgcolor = "#F08080";  // lightcoral
106
					} elseif (stristr($gateways_status[$gname]['status'], "loss")) {
107
						$online = "Packetloss";
108
						$bgcolor = "#F0E68C";  // khaki
109
					} elseif (stristr($gateways_status[$gname]['status'], "delay")) {
110
						$online = "Latency";
111
						$bgcolor = "#F0E68C";  // khaki
112
					} elseif ($gateways_status[$gname]['status'] == "none") {
113
						$online = "Online";
114
						$bgcolor = "#90EE90";  // lightgreen
115
					} elseif ($gateways_status[$gname]['status'] == "") {
116
						$online = "Pending";
117
						$bgcolor = "#D3D3D3";  // lightgray
118
					}
119
				} else {
120
					$online = gettext("Unknown");
121
					$bgcolor = "#ADD8E6";  // lightblue
122
				}
123
				echo "<td class=\"ellipsis\" bgcolor=\"$bgcolor\" align=\"center\">$online</td>\n";
124
				$counter++;
125
			?>
126
	</tr>
127
	<?php } // foreach ?>
128
</table>
129

    
130

    
(4-4/21)