Project

General

Profile

Download (6.9 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / diag_routes.php @ a1b66bec

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
if (isset($_REQUEST['isAjax'])) {
46
	$netstat = "/usr/bin/netstat -rW";
47
	if (isset($_REQUEST['IPv6'])) {
48
		$netstat .= " -f inet6";
49
		echo "IPv6\n";
50
	} else {
51
		$netstat .= " -f inet";
52
		echo "IPv4\n";
53
	}
54
	if (!isset($_REQUEST['resolve']))
55
		$netstat .= " -n";
56

    
57
	if (!empty($_REQUEST['filter']))
58
		$netstat .= " | /usr/bin/sed -e '1,3d; 5,\$ { /" . escapeshellarg(htmlspecialchars($_REQUEST['filter'])) . "/!d; };'";
59
	else
60
		$netstat .= " | /usr/bin/sed -e '1,3d'";
61

    
62
	if (is_numeric($_REQUEST['limit']) && $_REQUEST['limit'] > 0)
63
		$netstat .= " | /usr/bin/head -n {$_REQUEST['limit']}";
64

    
65
	echo htmlspecialchars_decode(shell_exec($netstat));
66

    
67
	exit;
68
}
69

    
70
$pgtitle = array(gettext("Diagnostics"),gettext("Routing tables"));
71
$shortcut_section = "routing";
72

    
73
include('head.inc');
74

    
75
?>
76
<body link="#000000" vlink="#000000" alink="#000000">
77

    
78
<?php include("fbegin.inc"); ?>
79

    
80
<script type="text/javascript">
81
//<![CDATA[
82

    
83
	function update_routes(section) {
84
		var url = "diag_routes.php";
85
		var limit = jQuery('#limit option:selected').text();
86
		var filter = jQuery('#filter').val();
87
		var params = "isAjax=true&limit=" + limit + "&filter=" + filter;
88
		if (jQuery('#resolve').is(':checked'))
89
			params += "&resolve=true";
90
		if (section == "IPv6")
91
			params += "&IPv6=true";
92
		var myAjax = new Ajax.Request(
93
			url,
94
			{
95
				method: 'post',
96
				parameters: params,
97
				onComplete: update_routes_callback
98
			});
99
	}
100

    
101
	function update_routes_callback(transport) {
102
		// First line contains section
103
		var responseTextArr = transport.responseText.split("\n");
104
		var section = responseTextArr.shift();
105
		var tbody = '';
106
		var field = '';
107
		var elements = 8;
108
		var tr_class = '';
109

    
110
		var thead = '<tr><td class="listtopic" colspan="' + elements + '"><strong>' + section + '<\/strong><\/td><\/tr>' + "\n";
111
		for (var i = 0; i < responseTextArr.length; i++) {
112
			if (responseTextArr[i] == "")
113
				continue;
114
			var tmp = '';
115
			if (i == 0) {
116
				tr_class = 'listhdrr';
117
				tmp += '<tr class="sortableHeaderRowIdentifier">' + "\n";
118
			} else {
119
				tr_class = 'listlr';
120
				tmp += '<tr>' + "\n";
121
			}
122
			var j = 0;
123
			var entry = responseTextArr[i].split(" ");
124
			for (var k = 0; k < entry.length; k++) {
125
				if (entry[k] == "")
126
					continue;
127
				if (i == 0 && j == (elements - 1))
128
					tr_class = 'listhdr';
129
				tmp += '<td class="' + tr_class + '">' + entry[k] + '<\/td>' + "\n";
130
				if (i > 0)
131
					tr_class = 'listr';
132
				j++;
133
			}
134
			// The 'Expire' field might be blank
135
			if (j == (elements - 1))
136
				tmp += '<td class="listr">&nbsp;<\/td>' + "\n";
137
			tmp += '<\/tr>' + "\n";
138
			if (i == 0)
139
				thead += tmp;
140
			else
141
				tbody += tmp;
142
		}
143
		jQuery('#' + section + ' > thead').html(thead);
144
		jQuery('#' + section + ' > tbody').html(tbody);
145
	}
146

    
147
//]]>
148
</script>
149

    
150
<script type="text/javascript">
151
//<![CDATA[
152

    
153
	function update_all_routes() {
154
		update_routes("IPv4");
155
		update_routes("IPv6");
156
	}
157

    
158
	jQuery(document).ready(function(){setTimeout('update_all_routes()', 5000);});
159

    
160
//]]>
161
</script>
162

    
163
<div id="mainarea">
164
<form action="diag_routes.php" method="post">
165
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="diag routes">
166

    
167
<tr>
168
<td class="vncellreq" width="22%"><?=gettext("Name resolution");?></td>
169
<td class="vtable" width="78%">
170
<input type="checkbox" class="formfld" id="resolve" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo "checked=\"checked\""; ?> /><?=gettext("Enable");?>
171
<br />
172
<span class="expl"><?=gettext("Enable this to attempt to resolve names when displaying the tables.");?></span>
173
</td>
174
</tr>
175

    
176
<tr>
177
<td class="vncellreq" width="22%"><?=gettext("Number of rows");?></td>
178
<td class="vtable" width="78%">
179
<select id="limit" name="limit">
180
<?php
181
	foreach (array("10", "50", "100", "200", "500", "1000", gettext("all")) as $item) {
182
		echo "<option value=\"{$item}\" " . ($item == "100" ? "selected=\"selected\"" : "") . ">{$item}</option>\n";
183
	}
184
?>
185
</select>
186
<br />
187
<span class="expl"><?=gettext("Select how many rows to display.");?></span>
188
</td>
189
</tr>
190

    
191
<tr>
192
<td class="vncellreq" width="22%"><?=gettext("Filter expression");?></td>
193
<td class="vtable" width="78%">
194
<input type="text" class="formfld search" name="filter" id="filter" />
195
<br />
196
<span class="expl"><?=gettext("Use a regular expression to filter IP address or hostnames.");?></span>
197
</td>
198
</tr>
199

    
200
<tr>
201
<td class="vncellreq" width="22%">&nbsp;</td>
202
<td class="vtable" width="78%">
203
<input type="button" class="formbtn" name="update" onclick="update_all_routes();" value="<?=gettext("Update"); ?>" />
204
<br />
205
<br />
206
<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>
207
</td>
208
</tr>
209

    
210
</table>
211
</form>
212

    
213
<table class="tabcont sortable" width="100%" cellspacing="0" cellpadding="6" border="0" id="IPv4" summary="ipv4 routes">
214
	<thead>
215
		<tr><td class="listtopic"><strong>IPv4</strong></td></tr>
216
	</thead>
217
	<tbody>
218
		<tr><td class="listhdrr"><?=gettext("Gathering data, please wait...");?></td></tr>
219
	</tbody>
220
</table>
221
<table class="tabcont sortable" width="100%" cellspacing="0" cellpadding="6" border="0" id="IPv6" summary="ipv6 routes">
222
	<thead>
223
		<tr><td class="listtopic"><strong>IPv6</strong></td></tr>
224
	</thead>
225
	<tbody>
226
		<tr><td class="listhdrr"><?=gettext("Gathering data, please wait...");?></td></tr>
227
	</tbody>
228
</table>
229

    
230
</div>
231

    
232
<?php
233
include('fend.inc');
234
?>
235

    
236
</body>
237
</html>
(45-45/256)