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 |
b32dd0a6
|
jim-p
|
$shortcut_section = "routing";
|
47 |
0eacb3b2
|
Scott Ullrich
|
|
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 |
f8ec8de4
|
Renato Botelho
|
<td class="vncellreq" width="22%"><?=gettext("Name resolution");?></td>
|
60 |
505371be
|
Renato Botelho
|
<td class="vtable" width="78%">
|
61 |
f8ec8de4
|
Renato Botelho
|
<input type="checkbox" class="formfld" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo 'checked'; ?>><?=gettext("Enable");?></input>
|
62 |
0eacb3b2
|
Scott Ullrich
|
<br />
|
63 |
f8ec8de4
|
Renato Botelho
|
<span class="expl"><?=gettext("Enable this to attempt to resolve names when displaying the tables.");?></span>
|
64 |
505371be
|
Renato Botelho
|
</td>
|
65 |
0eacb3b2
|
Scott Ullrich
|
</tr>
|
66 |
|
|
|
67 |
|
|
<tr>
|
68 |
|
|
<td class="vncellreq" width="22%"> </td>
|
69 |
505371be
|
Renato Botelho
|
<td class="vtable" width="78%">
|
70 |
0651f092
|
Carlos Eduardo Ramos
|
<input type="submit" class="formbtn" name="submit" value="<?=gettext("Show"); ?>" />
|
71 |
0eacb3b2
|
Scott Ullrich
|
<br />
|
72 |
|
|
<br />
|
73 |
f122c1a3
|
Erik Fonnesbeck
|
<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 |
0eacb3b2
|
Scott Ullrich
|
</td>
|
75 |
|
|
</tr>
|
76 |
|
|
|
77 |
|
|
</table>
|
78 |
|
|
</form>
|
79 |
|
|
|
80 |
|
|
<?php
|
81 |
4fa5203f
|
Scott Ullrich
|
|
82 |
0eacb3b2
|
Scott Ullrich
|
$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 |
f06f7cc0
|
PiBa-NL
|
<table class="tabcont sortable" width="100%" cellspacing="0" cellpadding="6" border="0">
|
90 |
|
|
<thead>
|
91 |
03d7297b
|
Warren Baker
|
<tr><td class="listtopic" colspan="<?=$elements?>"><strong><?=$name;?></strong></font></td></tr>
|
92 |
ee9933b6
|
Renato Botelho
|
<?php
|
93 |
0eacb3b2
|
Scott Ullrich
|
foreach (explode("\n", $table) as $i => $line) {
|
94 |
|
|
if ($i == 0) continue;
|
95 |
f06f7cc0
|
PiBa-NL
|
if ($line == "") continue;
|
96 |
0eacb3b2
|
Scott Ullrich
|
|
97 |
|
|
if ($i == 1)
|
98 |
|
|
$class = 'listhdrr';
|
99 |
|
|
else
|
100 |
505371be
|
Renato Botelho
|
$class = 'listlr';
|
101 |
0eacb3b2
|
Scott Ullrich
|
|
102 |
f06f7cc0
|
PiBa-NL
|
if ($i == 1)
|
103 |
|
|
print("<tr class=\"sortableHeaderRowIdentifier\">\n");
|
104 |
|
|
else
|
105 |
|
|
print("<tr>\n");
|
106 |
|
|
|
107 |
0eacb3b2
|
Scott Ullrich
|
$j = 0;
|
108 |
|
|
foreach (explode(' ', $line) as $entry) {
|
109 |
|
|
if ($entry == '') continue;
|
110 |
505371be
|
Renato Botelho
|
if ($i == 1 && $j == $elements - 1)
|
111 |
|
|
$class = 'listhdr';
|
112 |
0eacb3b2
|
Scott Ullrich
|
print("<td class=\"$class\">$entry</td>\n");
|
113 |
505371be
|
Renato Botelho
|
if ($i > 1)
|
114 |
|
|
$class = 'listr';
|
115 |
0eacb3b2
|
Scott Ullrich
|
$j++;
|
116 |
|
|
}
|
117 |
|
|
// The 'Expire' field might be blank
|
118 |
|
|
if ($j == $elements - 1)
|
119 |
|
|
print('<td class="listr"> </td>' . "\n");
|
120 |
|
|
print("</tr>\n");
|
121 |
f06f7cc0
|
PiBa-NL
|
if ($i == 1)
|
122 |
|
|
print("</thead>\n");
|
123 |
0eacb3b2
|
Scott Ullrich
|
}
|
124 |
|
|
print("</table>\n");
|
125 |
|
|
}
|
126 |
4fa5203f
|
Scott Ullrich
|
|
127 |
0eacb3b2
|
Scott Ullrich
|
?>
|
128 |
|
|
</table>
|
129 |
|
|
|
130 |
|
|
</div>
|
131 |
|
|
|
132 |
|
|
<?php
|
133 |
|
|
include('fend.inc');
|
134 |
|
|
?>
|