Projet

Général

Profil

Télécharger (8,7 ko) Statistiques
| Branche: | Tag: | Révision:

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

1
<?php
2
/* $Id$ */
3
/*
4
    diag_system_pftop.php
5
    Copyright (C) 2008-2009 Scott Ullrich
6
    All rights reserved.
7

    
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

    
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

    
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

    
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
/*
31
	pfSense_MODULE:	filter
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-diagnostics-system-pftop
36
##|*NAME=Diagnostics: pfTop
37
##|*DESCR=Allows access to the 'Diagnostics: pfTop' page
38
##|*MATCH=diag_system_pftop.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42

    
43
$pgtitle = gettext("Diagnostics: pfTop");
44

    
45
$sorttypes = array('age', 'bytes', 'dest', 'dport', 'exp', 'none', 'peak', 'pkt', 'rate', 'size', 'sport', 'src');
46
$viewtypes = array('default', 'label', 'long', 'queue', 'rules', 'size', 'speed', 'state', 'time');
47
$viewall = array('queue', 'label', 'rules');
48
$numstates = array('50', '100', '200', '500', '1000', 'all');
49

    
50
if($_REQUEST['getactivity']) {
51
	if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], $sorttypes)
52
		&& $_REQUEST['viewtype'] && in_array($_REQUEST['viewtype'], $viewtypes)
53
		&& $_REQUEST['states'] && in_array($_REQUEST['states'], $numstates)) {
54
		$viewtype = escapeshellarg($_REQUEST['viewtype']);
55
		if (in_array($_REQUEST['viewtype'], $viewall)) {
56
			$sorttype = "";
57
			$numstate = "-a";
58
		} else {
59
			$sorttype = "-o " . escapeshellarg($_REQUEST['sorttype']);
60
			$numstate = ($_REQUEST['states'] == "all" ? "-a" : escapeshellarg($_REQUEST['states']));
61
		}
62
	} else {
63
		$sorttype = "bytes";
64
		$viewtype = "default";
65
		$numstate = "100";
66
	}
67

    
68
	$text = `pftop -b {$sorttype} -v {$viewtype} {$numstate}`;
69
	echo $text;
70
	exit;
71
}
72

    
73
include("head.inc");
74

    
75
if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], $sorttypes)
76
	&& $_REQUEST['viewtype'] && in_array($_REQUEST['viewtype'], $viewtypes)
77
	&& $_REQUEST['states'] && in_array($_REQUEST['states'], $numstates)) {
78
	$viewtype = escapeshellarg($_REQUEST['viewtype']);
79
	if (in_array($_REQUEST['viewtype'], $viewall)) {
80
		$sorttype = "";
81
		$numstate = "-a";
82
	} else {
83
		$sorttype = "-o " . escapeshellarg($_REQUEST['sorttype']);
84
		$numstate = ($_REQUEST['states'] == "all" ? "-a" : escapeshellarg($_REQUEST['states']));
85
	}
86
} else {
87
	$sorttype = "bytes";
88
	$viewtype = "default";
89
	$numstate = "100";
90
}
91

    
92
?>
93
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
94
<form method="post" action="diag_system_pftop.php">
95
<script type="text/javascript">
96
	function getpftopactivity() {
97
		var url = "/diag_system_pftop.php";
98
		var pars = 'getactivity=yes&sorttype=' + jQuery('#sorttype').val() + '&viewtype=' + jQuery('#viewtype').val() + '&states=' + jQuery('#states').val();
99
		jQuery.ajax(
100
			url,
101
			{
102
				type: 'post',
103
				data: pars,
104
				complete: activitycallback
105
			});
106
	}
107
	function activitycallback(transport) {
108
		jQuery('#pftopactivitydiv').html('<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText  + '</pre></font>');
109
		setTimeout('getpftopactivity()', 2500);
110
	}
111
	setTimeout('getpftopactivity()', 1000);
112
</script>
113
<div id='maincontent'>
114
<?php
115
	include("fbegin.inc"); 
116
	if($savemsg) {
117
		echo "<div id='savemsg'>";
118
		print_info_box($savemsg);
119
		echo "</div>";	
120
	}
121
	if ($input_errors)
122
		print_input_errors($input_errors);
123
?>
124
	<form method="post">
125
		<div id="mainarea" style="padding-bottom: 0px;">
126
		<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
127
			<tr>
128
				<td class="list">
129
					<div id='viewtypediv'><?=gettext("View type:"); ?>
130
						<select name='viewtype' id='viewtype'>
131
							<option value='default' <?php echo ($viewtype == "default") ? "selected" : ""; ?>><?=gettext("Default");?></option>
132
							<option value='label' <?php echo ($viewtype == "label") ? "selected" : ""; ?>><?=gettext("Label");?></option>
133
							<option value='long' <?php echo ($viewtype == "long") ? "selected" : ""; ?>><?=gettext("Long");?></option>
134
							<option value='queue' <?php echo ($viewtype == "queue") ? "selected" : ""; ?>><?=gettext("Queue");?></option>
135
							<option value='rules' <?php echo ($viewtype == "rules") ? "selected" : ""; ?>><?=gettext("Rules");?></option>
136
							<option value='size' <?php echo ($viewtype == "size") ? "selected" : ""; ?>><?=gettext("Size");?></option>
137
							<option value='speed' <?php echo ($viewtype == "speed") ? "selected" : ""; ?>><?=gettext("Speed");?></option>
138
							<option value='state' <?php echo ($viewtype == "state") ? "selected" : ""; ?>><?=gettext("State");?></option>
139
							<option value='time' <?php echo ($viewtype == "time") ? "selected" : ""; ?>><?=gettext("Time");?></option>
140
						</select>
141
					</div>
142
				</td>
143
				<td class="list">
144
					<div id='sorttypediv'><?=gettext("Sort type:"); ?>
145
						<select name='sorttype' id='sorttype'>
146
							<option value='age' <?php echo ($sorttype == "age") ? "selected" : ""; ?>><?=gettext("Age");?></option>
147
							<option value='bytes' <?php echo ($sorttype == "bytes") ? "selected" : ""; ?>><?=gettext("Bytes");?></option>
148
							<option value='dest' <?php echo ($sorttype == "dest") ? "selected" : ""; ?>><?=gettext("Destination Address");?></option>
149
							<option value='dport' <?php echo ($sorttype == "dport") ? "selected" : ""; ?>><?=gettext("Destination Port");?></option>
150
							<option value='exp' <?php echo ($sorttype == "exp") ? "selected" : ""; ?>><?=gettext("Expiry");?></option>
151
							<option value='none' <?php echo ($sorttype == "none") ? "selected" : ""; ?>><?=gettext("None");?></option>
152
							<option value='peak' <?php echo ($sorttype == "peak") ? "selected" : ""; ?>><?=gettext("Peak");?></option>
153
							<option value='pkt' <?php echo ($sorttype == "pkt") ? "selected" : ""; ?>><?=gettext("Packet");?></option>
154
							<option value='rate' <?php echo ($sorttype == "rate") ? "selected" : ""; ?>><?=gettext("Rate");?></option>
155
							<option value='size' <?php echo ($sorttype == "size") ? "selected" : ""; ?>><?=gettext("Size");?></option>
156
							<option value='sport' <?php echo ($sorttype == "sport") ? "selected" : ""; ?>><?=gettext("Source Port");?></option>
157
							<option value='src' <?php echo ($sorttype == "src") ? "selected" : ""; ?>><?=gettext("Source Address");?></option>
158
						</select>
159
					</div>
160
				</td>
161
				<td class="list">
162
					<div id='statesdiv'><?=gettext("Number of States:"); ?>
163
						<select name='states' id='states'>
164
							<option value='50' <?php echo ($numstate == "50") ? "selected" : ""; ?>>50</option>
165
							<option value='100' <?php echo ($numstate == "100") ? "selected" : ""; ?>>100</option>
166
							<option value='200' <?php echo ($numstate == "200") ? "selected" : ""; ?>>200</option>
167
							<option value='500' <?php echo ($numstate == "500") ? "selected" : ""; ?>>500</option>
168
							<option value='1000' <?php echo ($numstate == "1000") ? "selected" : ""; ?>>1000</option>
169
							<option value='all' <?php echo ($numstate == "all") ? "selected" : ""; ?>>all</option>
170
						</select>
171
					</div>
172
				</td>
173
			</tr>
174
			<tr>
175
				<td colspan=3 align=center>
176
					<table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
177
						<tr>
178
							<td>
179
								<center>
180
									<table>
181
										<tr>
182
											<td>
183
												<div name='pftopactivitydiv' id='pftopactivitydiv'><b><?=gettext("Gathering pfTOP activity, please wait...");?></div>
184
											</td>
185
										</tr>
186
									</table>
187
								</center>
188
							</td>
189
						</tr>
190
					</table>
191
				</td>
192
		  </tr>
193
		</table>
194
	</div>
195
</form>
196
<?php include("fend.inc"); ?>
197
<script type="text/javascript">
198
jQuery("#viewtype").change(function() {
199
	var selected = jQuery("#viewtype option:selected");
200
	switch(selected.val()) {
201
		case "queue":
202
		case "label":
203
		case "rules":
204
			jQuery("#sorttype, #sorttypediv, #statesdiv, #states").hide();
205
			break;
206
		default:
207
			jQuery("#sorttype, #sorttypediv, #statesdiv, #states").show();
208
	}
209
});
210
</script>
211
</body>
212
</html>
(48-48/254)