Project

General

Profile

Download (3.52 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 6b07c15a Matthew Grooms
##|+PRIV
33
##|*IDENT=page-diagnostics-routingtables
34
##|*NAME=Diagnostics: Routing tables page
35
##|*DESCR=Allow access to the 'Diagnostics: Routing tables' page.
36
##|*MATCH=diag_routes.php*
37
##|-PRIV
38
39
40 0eacb3b2 Scott Ullrich
include('guiconfig.inc');
41
42 d88c6a9f Scott Ullrich
$pgtitle = array("Diagnostics","Routing tables");
43 0eacb3b2 Scott Ullrich
44
include('head.inc');
45
46
?>
47
<body link="#000000" vlink="#000000" alink="#000000">
48
<?php include("fbegin.inc"); ?>
49
50
<div id="mainarea">
51
<form action="diag_routes.php" method="post">
52
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6">
53
54
<tr>
55
<td class="vncellreq" width="22%">Name resolution</td>
56
<td class="listr" width="78%">
57 7a3a352a Scott Ullrich
<input type="checkbox" class="formfld" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo 'checked'; ?>> Enable</input>
58 0eacb3b2 Scott Ullrich
<br />
59
<span class="expl">Enable this to attempt to resolve names when displaying the tables.</span>
60
</tr>
61
62
<tr>
63
<td class="vncellreq" width="22%">&nbsp;</td>
64
<td class="listr" width="78%">
65
<input type="submit" class="formbtn" name="submit" value="Show" />
66
<br />
67
<br />
68 df0e0188 Scott Ullrich
<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>
69 0eacb3b2 Scott Ullrich
</td>
70
</tr>
71
72
</table>
73
</form>
74
75
<?php
76 4fa5203f Scott Ullrich
77 0eacb3b2 Scott Ullrich
	$netstat = ($_POST['resolve'] == 'yes' ? 'netstat -rW' : 'netstat -nrW');
78
	list($dummy, $internet, $internet6) = explode("\n\n", shell_exec($netstat));
79
80
	foreach (array(&$internet, &$internet6) as $tabindex => $table) {
81
		$elements = ($tabindex == 0 ? 8 : 8);
82
		$name = ($tabindex == 0 ? 'IPv4' : 'IPv6');
83
?>
84
<table class="tabcont" width="100%" cellspacing="0" cellpadding="6" border="0">
85 0e1dce26 Scott Ullrich
<tr><td class="listbg" colspan="<?=$elements?>"><strong><?=$name;?></strong></font></td></tr>
86 0eacb3b2 Scott Ullrich
<? 
87
		foreach (explode("\n", $table) as $i => $line) {
88
			if ($i == 0) continue;
89
90
			if ($i == 1)
91
				$class = 'listhdrr';
92
			else
93
				$class = 'listr';
94
95
			print("<tr>\n");
96
			$j = 0;
97
			foreach (explode(' ', $line) as $entry) {
98
				if ($entry == '') continue;
99
				print("<td class=\"$class\">$entry</td>\n");
100
				$j++;
101
			}
102
			// The 'Expire' field might be blank
103
			if ($j == $elements - 1)
104
				print('<td class="listr">&nbsp;</td>' . "\n");
105
			print("</tr>\n");
106
		}
107
		print("</table>\n");
108
	} 
109 4fa5203f Scott Ullrich
110 0eacb3b2 Scott Ullrich
?>
111
</table>
112
113
</div>
114
115
<?php
116
include('fend.inc');
117
?>