1
|
<?php
|
2
|
/*
|
3
|
diag_dump_states.php
|
4
|
Copyright (C) 2005 Scott Ullrich, Colin Smith
|
5
|
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
|
$pgtitle = "Diagnostics: Show States";
|
32
|
include("head.inc");
|
33
|
|
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
|
|
41
|
?>
|
42
|
|
43
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
44
|
<?php include("fbegin.inc"); ?>
|
45
|
<p class="pgtitle"><?=$pgtitle?></p>
|
46
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
47
|
<tr><td>
|
48
|
<?php
|
49
|
$tab_array = array();
|
50
|
$tab_array[0] = array("States", true, "diag_dump_states.php");
|
51
|
$tab_array[1] = array("Reset States", false, "diag_resetstate.php");
|
52
|
display_top_tabs($tab_array);
|
53
|
?>
|
54
|
</td></tr>
|
55
|
|
56
|
<tr><td>
|
57
|
<div id="mainarea">
|
58
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
59
|
<tr>
|
60
|
<td colspan="10">
|
61
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
62
|
<form action="diag_dump_states.php" method="get" id="search">
|
63
|
<tr>
|
64
|
<td style="font-weight:bold;" width="50" align="right">Filter:
|
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
|
|
75
|
<tr>
|
76
|
<td class="listhdrr" width="10%">Proto</td>
|
77
|
<td class="listhdrr" width="65">Source -> Router -> Destination</td>
|
78
|
<td class="listhdr" width="25%">State</td>
|
79
|
</tr>
|
80
|
<?php
|
81
|
$state_counter = 0;
|
82
|
if(count($states) > 0) {
|
83
|
foreach($states as $line) {
|
84
|
$state_counter++;
|
85
|
if($state_counter > 1000)
|
86
|
break;
|
87
|
|
88
|
$line_split = preg_split("/\s+/", $line);
|
89
|
$state = array_pop($line_split);
|
90
|
$type = array_shift($line_split);
|
91
|
$proto = array_shift($line_split);
|
92
|
$info = implode(" ", $line_split);
|
93
|
|
94
|
$towrite = <<<EOD
|
95
|
<tr valign="top">
|
96
|
<td class="listlr">{$proto}</td>
|
97
|
<td class="listr">{$info}</td>
|
98
|
<td class="listr">{$state}</td>
|
99
|
</tr>
|
100
|
EOD;
|
101
|
print $towrite;
|
102
|
}
|
103
|
} else {
|
104
|
print '<tr><td colspan="4"><center>No states were found.</center></td></tr>';
|
105
|
}
|
106
|
|
107
|
?>
|
108
|
</table>
|
109
|
</div>
|
110
|
</center>
|
111
|
</td></tr>
|
112
|
</table>
|
113
|
<?php include("fend.inc"); ?>
|
114
|
<?php if($_GET['filter']): ?>
|
115
|
<meta http-equiv="refresh" content="60;url=diag_dump_states.php?filter=<?php echo $_GET['filter']; ?>">
|
116
|
<?php else: ?>
|
117
|
<meta http-equiv="refresh" content="60;url=diag_dump_states.php">
|
118
|
<?php endif; ?>
|
119
|
|
120
|
</body>
|
121
|
</html>
|