Project

General

Profile

« Previous | Next » 

Revision 5f601060

Added by Phil Davis over 10 years ago

Code style usr-local-www diag

View differences:

usr/local/www/diag_routes.php
31 31
*/
32 32

  
33 33
/*
34
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat	
34
	pfSense_BUILDER_BINARIES:	/usr/bin/netstat
35 35
	pfSense_MODULE:	routing
36 36
*/
37 37
##|+PRIV
......
52 52
		$netstat .= " -f inet";
53 53
		echo "IPv4\n";
54 54
	}
55
	if (!isset($_REQUEST['resolve']))
55
	if (!isset($_REQUEST['resolve'])) {
56 56
		$netstat .= " -n";
57
	}
57 58

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

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

  
66 69
	echo htmlspecialchars_decode(shell_exec($netstat));
67 70

  
......
86 89
		var limit = jQuery('#limit option:selected').text();
87 90
		var filter = jQuery('#filter').val();
88 91
		var params = "isAjax=true&limit=" + limit + "&filter=" + filter;
89
		if (jQuery('#resolve').is(':checked'))
92
		if (jQuery('#resolve').is(':checked')) {
90 93
			params += "&resolve=true";
91
		if (section == "IPv6")
94
		}
95
		if (section == "IPv6") {
92 96
			params += "&IPv6=true";
97
		}
93 98
		var myAjax = new Ajax.Request(
94 99
			url,
95 100
			{
......
110 115

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

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

  
161 172
//]]>
162 173
</script>
......
164 175
<div id="mainarea">
165 176
<form action="diag_routes.php" method="post">
166 177
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="6" summary="diag routes">
167

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

  
177
<tr>
178
<td class="vncellreq" width="22%"><?=gettext("Number of rows");?></td>
179
<td class="vtable" width="78%">
180
<select id="limit" name="limit">
178
	<tr>
179
		<td class="vncellreq" width="22%"><?=gettext("Name resolution");?></td>
180
		<td class="vtable" width="78%">
181
			<input type="checkbox" class="formfld" id="resolve" name="resolve" value="yes" <?php if ($_POST['resolve'] == 'yes') echo "checked=\"checked\""; ?> /><?=gettext("Enable");?>
182
			<br />
183
			<span class="expl"><?=gettext("Enable this to attempt to resolve names when displaying the tables.");?></span>
184
		</td>
185
	</tr>
186

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

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

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

  
196
			</select>
197
			<br />
198
			<span class="expl"><?=gettext("Select how many rows to display.");?></span>
199
		</td>
200
	</tr>
201

  
202
	<tr>
203
		<td class="vncellreq" width="22%"><?=gettext("Filter expression");?></td>
204
		<td class="vtable" width="78%">
205
			<input type="text" class="formfld search" name="filter" id="filter" />
206
			<br />
207
			<span class="expl"><?=gettext("Use a regular expression to filter IP address or hostnames.");?></span>
208
		</td>
209
	</tr>
210

  
211
	<tr>
212
		<td class="vncellreq" width="22%">&nbsp;</td>
213
		<td class="vtable" width="78%">
214
			<input type="button" class="formbtn" name="update" onclick="update_all_routes();" value="<?=gettext("Update"); ?>" />
215
			<br />
216
			<br />
217
			<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>
218
		</td>
219
	</tr>
211 220
</table>
212 221
</form>
213 222

  

Also available in: Unified diff