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
|
|
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
|
<td class="vncellreq" width="22%"><?=gettext("Name resolution");?></td>
|
59
|
<td class="vtable" width="78%">
|
60
|
<input type="checkbox" class="formfld" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo 'checked'; ?>><?=gettext("Enable");?></input>
|
61
|
<br />
|
62
|
<span class="expl"><?=gettext("Enable this to attempt to resolve names when displaying the tables.");?></span>
|
63
|
</td>
|
64
|
</tr>
|
65
|
|
66
|
<tr>
|
67
|
<td class="vncellreq" width="22%"> </td>
|
68
|
<td class="vtable" width="78%">
|
69
|
<input type="submit" class="formbtn" name="submit" value="Show" />
|
70
|
<br />
|
71
|
<br />
|
72
|
<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
|
</td>
|
74
|
</tr>
|
75
|
|
76
|
</table>
|
77
|
</form>
|
78
|
|
79
|
<?php
|
80
|
|
81
|
$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
|
<tr><td class="listbg" colspan="<?=$elements?>"><strong><?=$name;?></strong></font></td></tr>
|
90
|
<?
|
91
|
foreach (explode("\n", $table) as $i => $line) {
|
92
|
if ($i == 0) continue;
|
93
|
|
94
|
if ($i == 1)
|
95
|
$class = 'listhdrr';
|
96
|
else
|
97
|
$class = 'listlr';
|
98
|
|
99
|
print("<tr>\n");
|
100
|
$j = 0;
|
101
|
foreach (explode(' ', $line) as $entry) {
|
102
|
if ($entry == '') continue;
|
103
|
if ($i == 1 && $j == $elements - 1)
|
104
|
$class = 'listhdr';
|
105
|
print("<td class=\"$class\">$entry</td>\n");
|
106
|
if ($i > 1)
|
107
|
$class = 'listr';
|
108
|
$j++;
|
109
|
}
|
110
|
// The 'Expire' field might be blank
|
111
|
if ($j == $elements - 1)
|
112
|
print('<td class="listr"> </td>' . "\n");
|
113
|
print("</tr>\n");
|
114
|
}
|
115
|
print("</table>\n");
|
116
|
}
|
117
|
|
118
|
?>
|
119
|
</table>
|
120
|
|
121
|
</div>
|
122
|
|
123
|
<?php
|
124
|
include('fend.inc');
|
125
|
?>
|