Project

General

Profile

Download (4.03 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
##|+PRIV
37
##|*IDENT=page-diagnostics-routingtables
38
##|*NAME=Diagnostics: Routing tables page
39
##|*DESCR=Allow access to the 'Diagnostics: Routing tables' page.
40
##|*MATCH=diag_routes.php*
41
##|-PRIV
42

    
43
include('guiconfig.inc');
44

    
45
$pgtitle = array(gettext("Diagnostics"),gettext("Routing tables"));
46
$shortcut_section = "routing";
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%"><?=gettext("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'; ?>><?=gettext("Enable");?></input>
62
<br />
63
<span class="expl"><?=gettext("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="<?=gettext("Show"); ?>" />
71
<br />
72
<br />
73
<span class="vexpl"><span class="red"><strong><?=gettext("Note:")?></strong></span> <?=gettext("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 sortable" width="100%" cellspacing="0" cellpadding="6" border="0">
90
<thead>
91
<tr><td class="listtopic" colspan="<?=$elements?>"><strong><?=$name;?></strong></font></td></tr>
92
<?php
93
		foreach (explode("\n", $table) as $i => $line) {
94
			if ($i == 0) continue;
95
			if ($line == "") continue;
96

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

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

    
127
?>
128
</table>
129

    
130
</div>
131

    
132
<?php
133
include('fend.inc');
134
?>
(43-43/249)