1 |
7afae53f
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
diag_overload_tables.php
|
4 |
|
|
Copyright (C) 2010 Jim Pingle
|
5 |
|
|
|
6 |
|
|
Portions borrowed from diag_dump_states.php:
|
7 |
|
|
Copyright (C) 2010 Scott Ullrich
|
8 |
|
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
/*
|
33 |
|
|
pfSense_BUILDER_BINARIES: /sbin/pfctl
|
34 |
|
|
pfSense_MODULE: filter
|
35 |
|
|
*/
|
36 |
|
|
|
37 |
|
|
##|+PRIV
|
38 |
|
|
##|*IDENT=page-diagnostics-tables
|
39 |
|
|
##|*NAME=Diagnostics: States Summary page
|
40 |
|
|
##|*DESCR=Allow access to the 'Diagnostics: States Summary' page.
|
41 |
|
|
##|*MATCH=diag_overload_tables.php*
|
42 |
|
|
##|-PRIV
|
43 |
|
|
|
44 |
|
|
$pgtitle = array("Diagnostics", "Overload tables");
|
45 |
|
|
|
46 |
|
|
require_once("guiconfig.inc");
|
47 |
|
|
|
48 |
|
|
// Set default table
|
49 |
|
|
$tablename = "sshlockout";
|
50 |
|
|
|
51 |
|
|
if($_REQUEST['type'] == "sshlockout")
|
52 |
|
|
$tablename = "sshlockout";
|
53 |
|
|
|
54 |
|
|
if($_REQUEST['type'] == "virusprot")
|
55 |
|
|
$tablename = "virusprot";
|
56 |
|
|
|
57 |
|
|
if($_REQUEST['delete']) {
|
58 |
|
|
if(is_ipaddr($_REQUEST['delete'])) {
|
59 |
|
|
exec("/sbin/pfctl -t " . escapeshellarg($_REQUEST['type']) . " -T delete " . escapeshellarg($_REQUEST['delete']), $delete);
|
60 |
|
|
echo htmlentities($_REQUEST['delete']);
|
61 |
|
|
}
|
62 |
|
|
exit;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
if($_REQUEST['deleteall']) {
|
66 |
|
|
exec("/sbin/pfctl -t $tablename -T show", $entries);
|
67 |
|
|
if(is_array($entries)) {
|
68 |
|
|
foreach($entries as $entryA) {
|
69 |
|
|
$entry = trim($entryA);
|
70 |
|
|
exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T delete " . escapeshellarg($entry), $delete);
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
exec("/sbin/pfctl -t $tablename -T show", $entries);
|
76 |
|
|
|
77 |
|
|
include("head.inc");
|
78 |
|
|
include("fbegin.inc");
|
79 |
|
|
|
80 |
|
|
?>
|
81 |
|
|
|
82 |
|
|
<form method='post'>
|
83 |
|
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
|
84 |
|
|
|
85 |
|
|
<script language="javascript">
|
86 |
|
|
function method_change(entrytype) {
|
87 |
|
|
window.location='diag_overload_tables.php?type=' + entrytype;
|
88 |
|
|
}
|
89 |
|
|
function del_entry(entry) {
|
90 |
|
|
new Ajax.Request("diag_overload_tables.php?type=<?php echo $tablename;?>&delete=" + entry, {
|
91 |
|
|
onComplete: function(response) {
|
92 |
|
|
if (200 == response.status)
|
93 |
|
|
new Effect.Fade($(response.responseText), { duration: 1.0 } );
|
94 |
|
|
}
|
95 |
|
|
});
|
96 |
|
|
}
|
97 |
|
|
</script>
|
98 |
|
|
|
99 |
|
|
Table:
|
100 |
|
|
<select id='type' onChange='method_change($F("type"));' name='type'>
|
101 |
|
|
<option name='<?=$tablename?>' value='<?=$tablename?>'><?=$tablename?></option>
|
102 |
|
|
<option name='virusprot' value='virusprot'>virusprot</option>
|
103 |
|
|
<option name='sshlockout' value='sshlockout'>sshlockout</option>
|
104 |
|
|
</select>
|
105 |
|
|
|
106 |
|
|
<p/>
|
107 |
|
|
|
108 |
|
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
|
109 |
|
|
<tr>
|
110 |
|
|
<td class="listhdrr">IP Address</td>
|
111 |
|
|
</tr>
|
112 |
|
|
<?php $count = 0; foreach($entries as $entryA): ?>
|
113 |
|
|
<?php $entry = trim($entryA); ?>
|
114 |
|
|
<tr id='<?=$entry?>'>
|
115 |
|
|
<td>
|
116 |
|
|
<?php echo $entry; ?>
|
117 |
|
|
</td>
|
118 |
|
|
<td>
|
119 |
|
|
<a onClick='del_entry("<?=$entry?>");'>
|
120 |
|
|
<img img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif">
|
121 |
|
|
</a>
|
122 |
|
|
</td>
|
123 |
|
|
</tr>
|
124 |
|
|
<?php $count++; endforeach; ?>
|
125 |
|
|
<?php
|
126 |
|
|
if($count == 0)
|
127 |
|
|
echo "<tr><td>No entries exist in this table.</td></tr>";
|
128 |
|
|
?>
|
129 |
|
|
|
130 |
|
|
</table>
|
131 |
|
|
|
132 |
|
|
<?php
|
133 |
|
|
if($count > 0)
|
134 |
|
|
echo "<p/>Delete <a href='diag_overload_tables.php?deleteall=true&type={$tablename}'>all</a> entries in this table;"
|
135 |
|
|
|
136 |
|
|
?>
|
137 |
|
|
|
138 |
|
|
<?php include("fend.inc"); ?>
|