Project

General

Profile

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