Project

General

Profile

Download (3.83 KB) Statistics
| Branch: | Tag: | Revision:
1 0eacb3b2 Scott Ullrich
<?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 13d193c2 Scott Ullrich
/*
33
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat	
34
	pfSense_MODULE:	routing
35
*/
36 6b07c15a Matthew Grooms
##|+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 0eacb3b2 Scott Ullrich
include('guiconfig.inc');
44
45 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Diagnostics"),gettext("Routing tables"));
46 0eacb3b2 Scott Ullrich
47
include('head.inc');
48
49
?>
50
<body link="#000000" vlink="#000000" alink="#000000">
51
<?php include("fbegin.inc"); ?>
52
53
<div id="mainarea">
54
<form action="diag_routes.php" method="post">
55
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
56
57
<tr>
58 f8ec8de4 Renato Botelho
<td class="vncellreq" width="22%"><?=gettext("Name resolution");?></td>
59 505371be Renato Botelho
<td class="vtable" width="78%">
60 f8ec8de4 Renato Botelho
<input type="checkbox" class="formfld" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo 'checked'; ?>><?=gettext("Enable");?></input>
61 0eacb3b2 Scott Ullrich
<br />
62 f8ec8de4 Renato Botelho
<span class="expl"><?=gettext("Enable this to attempt to resolve names when displaying the tables.");?></span>
63 505371be Renato Botelho
</td>
64 0eacb3b2 Scott Ullrich
</tr>
65
66
<tr>
67
<td class="vncellreq" width="22%">&nbsp;</td>
68 505371be Renato Botelho
<td class="vtable" width="78%">
69 0651f092 Carlos Eduardo Ramos
<input type="submit" class="formbtn" name="submit" value="<?=gettext("Show"); ?>" />
70 0eacb3b2 Scott Ullrich
<br />
71
<br />
72 28a9f06f Carlos Eduardo Ramos
<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>
73 0eacb3b2 Scott Ullrich
</td>
74
</tr>
75
76
</table>
77
</form>
78
79
<?php
80 4fa5203f Scott Ullrich
81 0eacb3b2 Scott Ullrich
	$netstat = ($_POST['resolve'] == 'yes' ? 'netstat -rW' : 'netstat -nrW');
82
	list($dummy, $internet, $internet6) = explode("\n\n", shell_exec($netstat));
83
84
	foreach (array(&$internet, &$internet6) as $tabindex => $table) {
85
		$elements = ($tabindex == 0 ? 8 : 8);
86
		$name = ($tabindex == 0 ? 'IPv4' : 'IPv6');
87
?>
88
<table class="tabcont" width="100%" cellspacing="0" cellpadding="6" border="0">
89 03d7297b Warren Baker
<tr><td class="listtopic" colspan="<?=$elements?>"><strong><?=$name;?></strong></font></td></tr>
90 ee9933b6 Renato Botelho
<?php
91 0eacb3b2 Scott Ullrich
		foreach (explode("\n", $table) as $i => $line) {
92
			if ($i == 0) continue;
93
94
			if ($i == 1)
95
				$class = 'listhdrr';
96
			else
97 505371be Renato Botelho
				$class = 'listlr';
98 0eacb3b2 Scott Ullrich
99
			print("<tr>\n");
100
			$j = 0;
101
			foreach (explode(' ', $line) as $entry) {
102
				if ($entry == '') continue;
103 505371be Renato Botelho
				if ($i == 1 && $j == $elements - 1)
104
					$class = 'listhdr';
105 0eacb3b2 Scott Ullrich
				print("<td class=\"$class\">$entry</td>\n");
106 505371be Renato Botelho
				if ($i > 1)
107
					$class = 'listr';
108 0eacb3b2 Scott Ullrich
				$j++;
109
			}
110
			// The 'Expire' field might be blank
111
			if ($j == $elements - 1)
112
				print('<td class="listr">&nbsp;</td>' . "\n");
113
			print("</tr>\n");
114
		}
115
		print("</table>\n");
116
	} 
117 4fa5203f Scott Ullrich
118 0eacb3b2 Scott Ullrich
?>
119
</table>
120
121
</div>
122
123
<?php
124
include('fend.inc');
125
?>