1 |
7afae53f
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c07b05e0
|
Scott Ullrich
|
diag_tables.php
|
4 |
6317d31d
|
Phil Davis
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
5 |
7afae53f
|
Scott Ullrich
|
Copyright (C) 2010 Jim Pingle
|
6 |
|
|
|
7 |
|
|
Portions borrowed from diag_dump_states.php:
|
8 |
|
|
Copyright (C) 2010 Scott Ullrich
|
9 |
|
|
All rights reserved.
|
10 |
|
|
|
11 |
|
|
Redistribution and use in source and binary forms, with or without
|
12 |
|
|
modification, are permitted provided that the following conditions are met:
|
13 |
|
|
|
14 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
15 |
|
|
this list of conditions and the following disclaimer.
|
16 |
|
|
|
17 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
18 |
|
|
notice, this list of conditions and the following disclaimer in the
|
19 |
|
|
documentation and/or other materials provided with the distribution.
|
20 |
|
|
|
21 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
31 |
|
|
*/
|
32 |
|
|
|
33 |
|
|
/*
|
34 |
|
|
pfSense_BUILDER_BINARIES: /sbin/pfctl
|
35 |
|
|
pfSense_MODULE: filter
|
36 |
|
|
*/
|
37 |
|
|
|
38 |
|
|
##|+PRIV
|
39 |
c07b05e0
|
Scott Ullrich
|
##|*IDENT=page-diagnostics-tables
|
40 |
|
|
##|*NAME=Diagnostics: PF Table IP addresses
|
41 |
|
|
##|*DESCR=Allow access to the 'Diagnostics: Tables' page.
|
42 |
|
|
##|*MATCH=diag_tables.php*
|
43 |
7afae53f
|
Scott Ullrich
|
##|-PRIV
|
44 |
|
|
|
45 |
c07b05e0
|
Scott Ullrich
|
$pgtitle = array(gettext("Diagnostics"), gettext("Tables"));
|
46 |
d71fc5d3
|
jim-p
|
$shortcut_section = "aliases";
|
47 |
7afae53f
|
Scott Ullrich
|
|
48 |
|
|
require_once("guiconfig.inc");
|
49 |
|
|
|
50 |
|
|
// Set default table
|
51 |
|
|
$tablename = "sshlockout";
|
52 |
e166769c
|
Renato Botelho
|
|
53 |
|
|
if($_REQUEST['type'])
|
54 |
34525fef
|
Ermal
|
$tablename = $_REQUEST['type'];
|
55 |
e166769c
|
Renato Botelho
|
|
56 |
7afae53f
|
Scott Ullrich
|
if($_REQUEST['delete']) {
|
57 |
e26e0eac
|
jim-p
|
if(is_ipaddr($_REQUEST['delete']) || is_subnet($_REQUEST['delete'])) {
|
58 |
7afae53f
|
Scott Ullrich
|
exec("/sbin/pfctl -t " . escapeshellarg($_REQUEST['type']) . " -T delete " . escapeshellarg($_REQUEST['delete']), $delete);
|
59 |
|
|
echo htmlentities($_REQUEST['delete']);
|
60 |
|
|
}
|
61 |
e166769c
|
Renato Botelho
|
exit;
|
62 |
7afae53f
|
Scott Ullrich
|
}
|
63 |
|
|
|
64 |
|
|
if($_REQUEST['deleteall']) {
|
65 |
e26e0eac
|
jim-p
|
exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T show", $entries);
|
66 |
7afae53f
|
Scott Ullrich
|
if(is_array($entries)) {
|
67 |
|
|
foreach($entries as $entryA) {
|
68 |
|
|
$entry = trim($entryA);
|
69 |
|
|
exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T delete " . escapeshellarg($entry), $delete);
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
|
74 |
909e7d0d
|
N0YB
|
if((($tablename == "bogons") || ($tablename == "bogonsv6")) && ($_POST['Download'])) {
|
75 |
6c474eb8
|
Warren Baker
|
mwexec_bg("/etc/rc.update_bogons.sh now");
|
76 |
|
|
$maxtimetowait = 0;
|
77 |
|
|
$loading = true;
|
78 |
|
|
while($loading == true) {
|
79 |
|
|
$isrunning = `/bin/ps awwwux | /usr/bin/grep -v grep | /usr/bin/grep bogons`;
|
80 |
|
|
if($isrunning == "")
|
81 |
|
|
$loading = false;
|
82 |
|
|
$maxtimetowait++;
|
83 |
|
|
if($maxtimetowait > 89)
|
84 |
|
|
$loading = false;
|
85 |
|
|
sleep(1);
|
86 |
|
|
}
|
87 |
|
|
if($maxtimetowait < 90)
|
88 |
|
|
$savemsg = gettext("The bogons database has been updated.");
|
89 |
|
|
}
|
90 |
|
|
|
91 |
e26e0eac
|
jim-p
|
exec("/sbin/pfctl -t " . escapeshellarg($tablename) . " -T show", $entries);
|
92 |
34525fef
|
Ermal
|
exec("/sbin/pfctl -sT", $tables);
|
93 |
7afae53f
|
Scott Ullrich
|
|
94 |
|
|
include("head.inc");
|
95 |
|
|
?>
|
96 |
7786daaa
|
Colin Fleming
|
<body>
|
97 |
|
|
<?php include("fbegin.inc"); ?>
|
98 |
7afae53f
|
Scott Ullrich
|
|
99 |
1c9ed80d
|
Warren Baker
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
100 |
7786daaa
|
Colin Fleming
|
<form method="post" action="diag_tables.php">
|
101 |
7afae53f
|
Scott Ullrich
|
|
102 |
91f026b0
|
ayvis
|
<script type="text/javascript">
|
103 |
7786daaa
|
Colin Fleming
|
//<![CDATA[
|
104 |
7afae53f
|
Scott Ullrich
|
function method_change(entrytype) {
|
105 |
c07b05e0
|
Scott Ullrich
|
window.location='diag_tables.php?type=' + entrytype;
|
106 |
7afae53f
|
Scott Ullrich
|
}
|
107 |
|
|
function del_entry(entry) {
|
108 |
e26e0eac
|
jim-p
|
jQuery.ajax("diag_tables.php?type=<?php echo htmlspecialchars($tablename);?>&delete=" + entry, {
|
109 |
ebfc87d6
|
Vinicius Coque
|
complete: function(response) {
|
110 |
|
|
if (200 == response.status) {
|
111 |
|
|
// Escape all dots to not confuse jQuery selectors
|
112 |
|
|
name = response.responseText.replace(/\./g,'\\.');
|
113 |
763afdaf
|
N0YB
|
name = name.replace(/\//g,'\\-');
|
114 |
|
|
name = "entry_" + name;
|
115 |
ebfc87d6
|
Vinicius Coque
|
jQuery('#' + name).fadeOut(1000);
|
116 |
|
|
}
|
117 |
7afae53f
|
Scott Ullrich
|
}
|
118 |
|
|
});
|
119 |
|
|
}
|
120 |
7786daaa
|
Colin Fleming
|
//]]>
|
121 |
7afae53f
|
Scott Ullrich
|
</script>
|
122 |
e166769c
|
Renato Botelho
|
|
123 |
|
|
<?=gettext("Table:");?>
|
124 |
7786daaa
|
Colin Fleming
|
<select id="type" onchange="method_change(jQuery('#type').val());" name="type">
|
125 |
34525fef
|
Ermal
|
<?php foreach ($tables as $table) {
|
126 |
7786daaa
|
Colin Fleming
|
echo "<option value=\"{$table}\"";
|
127 |
34525fef
|
Ermal
|
if ($tablename == $table)
|
128 |
7786daaa
|
Colin Fleming
|
echo " selected=\"selected\"";
|
129 |
34525fef
|
Ermal
|
echo ">{$table}</option>\n";
|
130 |
|
|
}
|
131 |
|
|
?>
|
132 |
7afae53f
|
Scott Ullrich
|
</select>
|
133 |
|
|
|
134 |
7786daaa
|
Colin Fleming
|
<br/><br/>
|
135 |
7afae53f
|
Scott Ullrich
|
|
136 |
7786daaa
|
Colin Fleming
|
<table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0" summary="tables">
|
137 |
7afae53f
|
Scott Ullrich
|
<tr>
|
138 |
441e7f01
|
Renato Botelho
|
<td class="listhdrr"><?=gettext("IP Address");?></td>
|
139 |
7afae53f
|
Scott Ullrich
|
</tr>
|
140 |
|
|
<?php $count = 0; foreach($entries as $entryA): ?>
|
141 |
|
|
<?php $entry = trim($entryA); ?>
|
142 |
763afdaf
|
N0YB
|
<tr id="entry_<?=str_replace("/", "-", $entry);?>">
|
143 |
7afae53f
|
Scott Ullrich
|
<td>
|
144 |
|
|
<?php echo $entry; ?>
|
145 |
|
|
</td>
|
146 |
|
|
<td>
|
147 |
909e7d0d
|
N0YB
|
<?php if ( ($tablename != "bogons") && ($tablename != "bogonsv6") ) { ?>
|
148 |
7786daaa
|
Colin Fleming
|
<a onclick="del_entry('<?=htmlspecialchars($entry)?>');">
|
149 |
|
|
<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" alt="delete" />
|
150 |
7afae53f
|
Scott Ullrich
|
</a>
|
151 |
7786daaa
|
Colin Fleming
|
<?php } ?>
|
152 |
7afae53f
|
Scott Ullrich
|
</td>
|
153 |
|
|
</tr>
|
154 |
|
|
<?php $count++; endforeach; ?>
|
155 |
|
|
<?php
|
156 |
|
|
if($count == 0)
|
157 |
e166769c
|
Renato Botelho
|
if( ($tablename == "bogons") || ($tablename == "bogonsv6") )
|
158 |
7786daaa
|
Colin Fleming
|
echo "<tr><td>" . gettext("No entries exist in this table.") . " " . "<input name=\"Download\" type=\"submit\" class=\"formbtn\" value=\"" . gettext("Download") . "\" /> " . gettext(" the latest bogon data.");
|
159 |
909e7d0d
|
N0YB
|
else
|
160 |
7786daaa
|
Colin Fleming
|
echo "<tr><td>" . gettext("No entries exist in this table.");
|
161 |
7afae53f
|
Scott Ullrich
|
?>
|
162 |
|
|
|
163 |
|
|
<?php
|
164 |
|
|
if($count > 0)
|
165 |
e166769c
|
Renato Botelho
|
if( ($tablename == "bogons") || ($tablename == "bogonsv6") ) {
|
166 |
83b9c4d2
|
N0YB
|
$last_updated = exec('/usr/bin/grep -i -m 1 -E "^# last updated" /etc/' . escapeshellarg($tablename));
|
167 |
7786daaa
|
Colin Fleming
|
echo "<tr><td> <b>$count</b> " . gettext("entries in this table.") . " " . "<input name=\"Download\" type=\"submit\" class=\"formbtn\" value=\"" . gettext("Download") . "\" /> " . gettext(" the latest bogon data.") . "<br />" . "$last_updated";
|
168 |
15fc311f
|
jim-p
|
}
|
169 |
6c474eb8
|
Warren Baker
|
else
|
170 |
7786daaa
|
Colin Fleming
|
echo "<tr><td>" . gettext("Delete") . " <a href=\"diag_tables.php?deleteall=true&type=" . htmlspecialchars($tablename) . "\">" . gettext("all") . "</a> " . "<b>$count</b> " . gettext("entries in this table.");
|
171 |
7afae53f
|
Scott Ullrich
|
?>
|
172 |
7786daaa
|
Colin Fleming
|
</td></tr>
|
173 |
909e7d0d
|
N0YB
|
</table>
|
174 |
7786daaa
|
Colin Fleming
|
</form>
|
175 |
909e7d0d
|
N0YB
|
|
176 |
7afae53f
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
177 |
7786daaa
|
Colin Fleming
|
</body>
|
178 |
|
|
</html>
|