Project

General

Profile

Download (3.71 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2

    
3
/* $Id$ */
4
/*
5
	diag_routes.php
6
	Copyright (C) 2006 Fernando Lamos
7
	All rights reserved.
8

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

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

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

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

    
30
*/
31

    
32
/*
33
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat	
34
	pfSense_MODULE:	routing
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-diagnostics-routingtables
39
##|*NAME=Diagnostics: Routing tables page
40
##|*DESCR=Allow access to the 'Diagnostics: Routing tables' page.
41
##|*MATCH=diag_routes.php*
42
##|-PRIV
43

    
44
include('guiconfig.inc');
45

    
46
$pgtitle = array("Diagnostics","Routing tables");
47

    
48
include('head.inc');
49

    
50
?>
51
<body link="#000000" vlink="#000000" alink="#000000">
52
<?php include("fbegin.inc"); ?>
53

    
54
<div id="mainarea">
55
<form action="diag_routes.php" method="post">
56
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
57

    
58
<tr>
59
<td class="vncellreq" width="22%">Name resolution</td>
60
<td class="vtable" width="78%">
61
<input type="checkbox" class="formfld" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo 'checked'; ?>> Enable</input>
62
<br />
63
<span class="expl">Enable this to attempt to resolve names when displaying the tables.</span>
64
</td>
65
</tr>
66

    
67
<tr>
68
<td class="vncellreq" width="22%">&nbsp;</td>
69
<td class="vtable" width="78%">
70
<input type="submit" class="formbtn" name="submit" value="Show" />
71
<br />
72
<br />
73
<span class="vexpl"><span class="red"><strong>Note:</strong></span> By enabling name resolution, the query should take a bit longer. You can stop it at any time by clicking the Stop button in your browser.</span>
74
</td>
75
</tr>
76

    
77
</table>
78
</form>
79

    
80
<?php
81

    
82
	$netstat = ($_POST['resolve'] == 'yes' ? 'netstat -rW' : 'netstat -nrW');
83
	list($dummy, $internet, $internet6) = explode("\n\n", shell_exec($netstat));
84

    
85
	foreach (array(&$internet, &$internet6) as $tabindex => $table) {
86
		$elements = ($tabindex == 0 ? 8 : 8);
87
		$name = ($tabindex == 0 ? 'IPv4' : 'IPv6');
88
?>
89
<table class="tabcont" width="100%" cellspacing="0" cellpadding="6" border="0">
90
<tr><td class="listbg" colspan="<?=$elements?>"><strong><?=$name;?></strong></font></td></tr>
91
<? 
92
		foreach (explode("\n", $table) as $i => $line) {
93
			if ($i == 0) continue;
94

    
95
			if ($i == 1)
96
				$class = 'listhdrr';
97
			else
98
				$class = 'listlr';
99

    
100
			print("<tr>\n");
101
			$j = 0;
102
			foreach (explode(' ', $line) as $entry) {
103
				if ($entry == '') continue;
104
				if ($i == 1 && $j == $elements - 1)
105
					$class = 'listhdr';
106
				print("<td class=\"$class\">$entry</td>\n");
107
				if ($i > 1)
108
					$class = 'listr';
109
				$j++;
110
			}
111
			// The 'Expire' field might be blank
112
			if ($j == $elements - 1)
113
				print('<td class="listr">&nbsp;</td>' . "\n");
114
			print("</tr>\n");
115
		}
116
		print("</table>\n");
117
	} 
118

    
119
?>
120
</table>
121

    
122
</div>
123

    
124
<?php
125
include('fend.inc');
126
?>
(33-33/218)