Projet

Général

Profil

Télécharger (6,79 ko) Statistiques
| Branche: | Tag: | Révision:

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

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
<script type="text/javascript">
79
//<![CDATA[
80

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

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

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

    
145
//]]>
146
</script>
147

    
148
<?php include("fbegin.inc"); ?>
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">
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'; ?> /><?=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" : "") . ">{$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">
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">
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
?>
(43-43/254)