Project

General

Profile

Download (3.88 KB) Statistics
| Branch: | Tag: | Revision:
1 92cc7528 Scott Ullrich
<?php
2
/*
3
    diag_dump_states.php
4 ca77763b Scott Ullrich
    Copyright (C) 2005 Scott Ullrich, Colin Smith
5 92cc7528 Scott Ullrich
    All rights reserved.
6
7
    Redistribution and use in source and binary forms, with or without
8
    modification, are permitted provided that the following conditions are met:
9
10
    1. Redistributions of source code must retain the above copyright notice,
11
       this list of conditions and the following disclaimer.
12
13
    2. Redistributions in binary form must reproduce the above copyright
14
       notice, this list of conditions and the following disclaimer in the
15
       documentation and/or other materials provided with the distribution.
16
17
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
    POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
require_once("guiconfig.inc");
30
31 73033954 Scott Ullrich
$pgtitle = "Diagnostics: Show States";
32 92cc7528 Scott Ullrich
include("head.inc");
33 ca77763b Scott Ullrich
34
/* get our states */
35
if($_GET['filter']) {
36
	exec("/sbin/pfctl -ss | grep {$_GET['filter']}", $states);
37
} else {
38
	exec("/sbin/pfctl -ss", $states);
39
}
40 92cc7528 Scott Ullrich
41
?>
42
43
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
44 ba6d49ff Scott Ullrich
<script src="/javascript/sorttable.js"></script>
45 ca77763b Scott Ullrich
<?php include("fbegin.inc"); ?>
46 92cc7528 Scott Ullrich
<p class="pgtitle"><?=$pgtitle?></p>
47
<table width="100%" border="0" cellpadding="0" cellspacing="0">
48 15953ad5 Scott Ullrich
<tr><td>
49
<?php
50
	$tab_array = array();
51
	$tab_array[0] = array("States", true, "diag_dump_states.php");
52
	$tab_array[1] = array("Reset States", false, "diag_resetstate.php");
53
	display_top_tabs($tab_array);
54
?>
55
</td></tr>
56 ca77763b Scott Ullrich
57 19a7916a Bill Marquette
<tr><td>
58
        <div id="mainarea">
59 ba6d49ff Scott Ullrich
				<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
60
					<tr>
61
						<td colspan="9">
62
							<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
63
								<tr>
64
									<td style="font-weight:bold;" width="50" align="right">Filter:&nbsp;
65
										
66
										<input name="filter" type="text" id="" value="<?=$_GET['filter'];?>" size="30" style="font-size:11px;">
67
										<input type="submit" class="formbtn" value="Filter">
68
										</form>
69
									<td>
70
								</tr>
71
							</table>
72
						</td>
73
					</tr>
74
				<tr><td>
75
				<table id="sortabletable" name="sortabletable" class="sortable" width="100%" border="0" cellspacing="0" cellpadding="0">
76
				<tr>
77
					<td class="listhdrr" width="10%">Proto</td>
78
					<td class="listhdrr" width="65">Source -> Router -> Destination</td>
79
					<td class="listhdr" width="15%">State</td>
80
					<td class="list" width="1%"></td>
81
				</tr>
82 92cc7528 Scott Ullrich
<?php
83 ca77763b Scott Ullrich
$state_counter = 0;
84
if(count($states) > 0) {
85
	foreach($states as $line) {
86
		$state_counter++;
87
		if($state_counter > 1000)
88
			break;
89
	
90
		$line_split = preg_split("/\s+/", $line);
91
		$state = array_pop($line_split);
92
		$type = array_shift($line_split);
93
		$proto = array_shift($line_split);
94
		$info = implode(" ", $line_split);
95
96
		$towrite = <<<EOD
97
		<tr valign="top">
98
		<td class="listlr">{$proto}</td>
99 17bb57e6 Scott Ullrich
		<td class="listr">{$info}</td>
100
		<td class="listr">{$state}</td>
101 ca77763b Scott Ullrich
		</tr>
102 29fa93aa Scott Ullrich
EOD;
103 ca77763b Scott Ullrich
		print $towrite;
104 92cc7528 Scott Ullrich
	}
105 ca77763b Scott Ullrich
} else {
106
	print '<tr><td colspan="4"><center>No states were found.</center></td></tr>';
107 92cc7528 Scott Ullrich
}
108
109
?>
110 ba6d49ff Scott Ullrich
</td></tr></table>
111 92cc7528 Scott Ullrich
</table>
112 64957cc4 Erik Kristensen
</div>
113 92cc7528 Scott Ullrich
</center>
114
</td></tr>
115
</table>
116
<?php include("fend.inc"); ?>
117 1f97829e Scott Ullrich
<?php if($_GET['filter']): ?>
118
<meta http-equiv="refresh" content="60;url=diag_dump_states.php?filter=<?php echo $_GET['filter']; ?>">
119
<?php else: ?>
120 ca77763b Scott Ullrich
<meta http-equiv="refresh" content="60;url=diag_dump_states.php">
121 1f97829e Scott Ullrich
<?php endif; ?>
122
123 92cc7528 Scott Ullrich
</body>
124
</html>