Project

General

Profile

Download (6.97 KB) Statistics
| Branch: | Tag: | Revision:
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-diag-system-activity
36
##|*NAME=Diagnostics: System Activity
37
##|*DESCR=Allows access to the 'Diagnostics: System Activity' page
38
##|*MATCH=diag_system_pftop.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42

    
43
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
44

    
45
$pgtitle = gettext("Diagnostics: pfTop");
46

    
47
$sorttypes = array('age', 'bytes', 'dest', 'dport', 'exp', 'none', 'peak', 'pkt', 'rate', 'size', 'sport', 'src');
48
$viewtypes = array('default', 'label', 'long', 'queue', 'rules', 'size', 'speed', 'state', 'time');
49

    
50
if($_REQUEST['getactivity']) {
51
	if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], array_keys($sorttypes))
52
		 && $_REQUEST['viewtype'] && in_array($_REQUEST['viewtype'], array_keys($viewtypes))) {
53
		$sorttype = escapeshellarg($_REQUEST['sorttype']);
54
		$viewtype = escapeshellarg($_REQUEST['viewtype']);
55
	} else {
56
		$sorttype = "bytes";
57
		$viewtype = "default";
58
	}
59

    
60
	$text = `pftop -b -a -o {$sorttype} -v {$viewtype}`;
61
	echo $text;
62
	exit;
63
}
64

    
65
include("head.inc");
66

    
67
if($_REQUEST['sorttype'] && in_array($_REQUEST['sorttype'], array_keys($sorttypes))
68
	&& $_REQUEST['viewtype'] && in_array($_REQUEST['viewtype'], array_keys($viewtypes))) {
69
	$sorttype = htmlentities($_REQUEST['sorttype']);
70
	$viewtype = htmlentities($_REQUEST['viewtype']);
71
} else {
72
	$sorttype = "bytes";
73
	$viewtype = "default";
74
}
75

    
76
?>
77
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
78
<form method="post" action="diag_system_pftop.php">
79
<script type="text/javascript">
80
	function getpftopactivity() {
81
		var url = "/diag_system_pftop.php";
82
		var pars = 'getactivity=yes&sorttype=' + jQuery('#sorttype').val() + '&viewtype=' + jQuery('#viewtype').val();
83
		jQuery.ajax(
84
			url,
85
			{
86
				type: 'post',
87
				data: pars,
88
				complete: activitycallback
89
			});
90
	}
91
	function activitycallback(transport) {
92
		jQuery('#pftopactivitydiv').html('<font face="Courier"><font size="2"><b><pre style="text-align:left;">' + transport.responseText  + '</pre></font>');
93
		setTimeout('getpftopactivity()', 2500);
94
	}
95
	setTimeout('getpftopactivity()', 1000);
96
</script>
97
<div id='maincontent'>
98
<?php
99
	include("fbegin.inc"); 
100
	if(strstr($pfSversion, "1.2")) 
101
		echo "<p class=\"pgtitle\">{$pgtitle}</p>";
102
	if($savemsg) {
103
		echo "<div id='savemsg'>";
104
		print_info_box($savemsg);
105
		echo "</div>";	
106
	}
107
	if ($input_errors)
108
		print_input_errors($input_errors);
109
?>
110
	<form method="post">
111
	<?=gettext("View type:"); ?>
112
	<select name='viewtype' id='viewtype'>
113
		<option value='default' <?php echo ($viewtype == "default") ? "selected" : ""; ?>><?=gettext("Default");?></option>
114
		<option value='label' <?php echo ($viewtype == "label") ? "selected" : ""; ?>><?=gettext("Label");?></option>
115
		<option value='long' <?php echo ($viewtype == "long") ? "selected" : ""; ?>><?=gettext("Long");?></option>
116
		<option value='queue' <?php echo ($viewtype == "queue") ? "selected" : ""; ?>><?=gettext("Queue");?></option>
117
		<option value='rules' <?php echo ($viewtype == "rules") ? "selected" : ""; ?>><?=gettext("Rules");?></option>
118
		<option value='size' <?php echo ($viewtype == "size") ? "selected" : ""; ?>><?=gettext("Size");?></option>
119
		<option value='speed' <?php echo ($viewtype == "speed") ? "selected" : ""; ?>><?=gettext("Speed");?></option>
120
		<option value='state' <?php echo ($viewtype == "state") ? "selected" : ""; ?>><?=gettext("State");?></option>
121
		<option value='time' <?php echo ($viewtype == "time") ? "selected" : ""; ?>><?=gettext("Time");?></option>
122
	</select>
123
	<?=gettext("Sort type:"); ?>
124
	<select name='sorttype' id='sorttype'>
125
		<option value='age' <?php echo ($sorttype == "age") ? "selected" : ""; ?>><?=gettext("Age");?></option>
126
		<option value='bytes' <?php echo ($sorttype == "bytes") ? "selected" : ""; ?>><?=gettext("Bytes");?></option>
127
		<option value='dest' <?php echo ($sorttype == "dest") ? "selected" : ""; ?>><?=gettext("Destination Address");?></option>
128
		<option value='dport' <?php echo ($sorttype == "dport") ? "selected" : ""; ?>><?=gettext("Destination Port");?></option>
129
		<option value='exp' <?php echo ($sorttype == "exp") ? "selected" : ""; ?>><?=gettext("Expiry");?></option>
130
		<option value='none' <?php echo ($sorttype == "none") ? "selected" : ""; ?>><?=gettext("None");?></option>
131
		<option value='peak' <?php echo ($sorttype == "peak") ? "selected" : ""; ?>><?=gettext("Peak");?></option>
132
		<option value='pkt' <?php echo ($sorttype == "pkt") ? "selected" : ""; ?>><?=gettext("Packet");?></option>
133
		<option value='rate' <?php echo ($sorttype == "rate") ? "selected" : ""; ?>><?=gettext("Rate");?></option>
134
		<option value='size' <?php echo ($sorttype == "size") ? "selected" : ""; ?>><?=gettext("Size");?></option>
135
		<option value='sport' <?php echo ($sorttype == "sport") ? "selected" : ""; ?>><?=gettext("Source Port");?></option>
136
		<option value='src' <?php echo ($sorttype == "src") ? "selected" : ""; ?>><?=gettext("Source Address");?></option>
137
	</select>
138
	<p/>
139
<table width="100%" border="0" cellpadding="0" cellspacing="0">  
140
  <tr>
141
    <td>
142
	<table id="backuptable" class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
143
		<tr>
144
			<td>
145
				<center>
146
				<table>
147
					<tr><td>
148
						<div name='pftopactivitydiv' id='pftopactivitydiv'>
149
							<b><?=gettext("Gathering pfTOP activity, please wait...");?>
150
						</div>
151
					</td></tr>
152
				</table>
153
			</td>
154
		</tr>
155
	</table>
156
	</div>
157
    </td>
158
  </tr>
159
</table>
160
</form>
161
<?php include("fend.inc"); ?>
162
<script language="JavaScript">
163
jQuery("#viewtype").change(function() {
164
	var selected = jQuery("#viewtype option:selected");
165
	switch(selected.val()) {
166
		case "queue":
167
		case "label":
168
		case "rules":
169
			jQuery("#sorttype").hide();
170
			break;
171
		default:
172
			jQuery("#sorttype").show();
173
	}
174
});
175
</script>
176
</body>
177
</html>
(48-48/247)