78 |
78 |
);
|
79 |
79 |
|
80 |
80 |
$filter_logfile = "{$g['varlog_path']}/filter.log";
|
81 |
|
$filterlog = conv_log_filter($filter_logfile, $nentries, 50, $filterfieldsarray); //Get log entries
|
82 |
81 |
|
83 |
82 |
/* AJAX related routines */
|
84 |
|
handle_ajax($nentries, $nentries + 20);
|
|
83 |
if (isset($_POST['lastsawtime'])) {
|
|
84 |
$filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 20);
|
85 |
85 |
|
86 |
|
?>
|
87 |
|
<script type="text/javascript">
|
88 |
|
//<![CDATA[
|
89 |
|
lastsawtime = '<?php echo time(); ?>';
|
90 |
|
var lines = Array();
|
91 |
|
var timer;
|
92 |
|
var updateDelay = 30000;
|
93 |
|
var isBusy = false;
|
94 |
|
var isPaused = false;
|
95 |
|
var nentries = <?php echo $nentries; ?>;
|
96 |
|
|
97 |
|
<?php
|
98 |
|
if(isset($config['syslog']['reverse']))
|
99 |
|
echo "var isReverse = true;\n";
|
100 |
|
else
|
101 |
|
echo "var isReverse = false;\n";
|
102 |
|
?>
|
103 |
|
|
104 |
|
/* Called by the AJAX updater */
|
105 |
|
function format_log_line(row) {
|
106 |
|
var rrText = "<?php echo gettext("Reverse Resolve with DNS"); ?>";
|
107 |
|
|
108 |
|
if ( row[8] == '6' ) {
|
109 |
|
srcIP = '[' + row[3] + ']';
|
110 |
|
dstIP = '[' + row[5] + ']';
|
111 |
|
} else {
|
112 |
|
srcIP = row[3];
|
113 |
|
dstIP = row[5];
|
|
86 |
foreach ($filterlog as $idx => $row) {
|
|
87 |
if (strtotime($log_row['time']) <= $_POST['lastsawtime'])
|
|
88 |
unset($filterlog[$idx]);
|
114 |
89 |
}
|
115 |
|
|
116 |
|
if ( row[4] == '' )
|
117 |
|
srcPort = '';
|
118 |
|
else
|
119 |
|
srcPort = ':' + row[4];
|
120 |
|
if ( row[6] == '' )
|
121 |
|
dstPort = '';
|
122 |
|
else
|
123 |
|
dstPort = ':' + row[6];
|
124 |
|
|
125 |
|
var line = '<td class="listMRlr" align="center">' + row[0] + '</td>' +
|
126 |
|
'<td class="listMRr ellipsis" title="' + row[1] + '">' + row[1].slice(0,-3) + '</td>' +
|
127 |
|
'<td class="listMRr ellipsis" title="' + row[2] + '">' + row[2] + '</td>' +
|
128 |
|
'<td class="listMRr ellipsis" title="' + srcIP + srcPort + '"><a href="diag_dns.php?host=' + row[3] + '" title="' + rrText + '">' + srcIP + '</a></td>' +
|
129 |
|
'<td class="listMRr ellipsis" title="' + dstIP + dstPort + '"><a href="diag_dns.php?host=' + row[5] + '" title="' + rrText + '">' + dstIP + '</a>' + dstPort + '</td>';
|
130 |
|
|
131 |
|
var nentriesacts = "<?php echo $nentriesacts; ?>";
|
132 |
|
var nentriesinterfaces = "<?php echo $nentriesinterfaces; ?>";
|
133 |
|
|
134 |
|
var Action = row[0].match(/alt=.*?(pass|block|reject)/i).join("").match(/pass|block|reject/i).join("");
|
135 |
|
var Interface = row[2];
|
136 |
|
|
137 |
|
if ( !(in_arrayi(Action, nentriesacts.replace (/\s+/g, ',').split(',') ) ) && (nentriesacts != 'All') ) return false;
|
138 |
|
if ( !(in_arrayi(Interface, nentriesinterfaces.replace(/\s+/g, ',').split(',') ) ) && (nentriesinterfaces != 'All') ) return false;
|
139 |
|
|
140 |
|
return line;
|
141 |
90 |
}
|
142 |
|
//]]>
|
|
91 |
else
|
|
92 |
$filterlog = conv_log_filter($filter_logfile, $nentries, 50, $filterfieldsarray);
|
|
93 |
?>
|
|
94 |
<script>
|
|
95 |
var logWidgetLastRefresh = <?=time()?>;
|
143 |
96 |
</script>
|
144 |
|
<script src="/javascript/filter_log.js" type="text/javascript"></script>
|
145 |
97 |
|
146 |
98 |
<table class="table table-striped">
|
147 |
99 |
<thead>
|
... | ... | |
164 |
116 |
$dstIP = htmlspecialchars($filterent['dstip']);
|
165 |
117 |
}
|
166 |
118 |
|
167 |
|
if ($filterent['srcport'])
|
168 |
|
$srcPort = ":" . htmlspecialchars($filterent['srcport']);
|
169 |
|
else
|
170 |
|
$srcPort = "";
|
171 |
|
|
172 |
|
if ($filterent['dstport'])
|
173 |
|
$dstPort = ":" . htmlspecialchars($filterent['dstport']);
|
174 |
|
else
|
175 |
|
$dstPort = "";
|
176 |
|
|
177 |
119 |
if ($filterent['act'] == "block")
|
178 |
120 |
$iconfn = "remove";
|
179 |
121 |
else if ($filterent['act'] == "reject")
|
... | ... | |
186 |
128 |
$rule = find_rule_by_number($filterent['rulenum'], $filterent['tracker'], $filterent['act']);
|
187 |
129 |
?>
|
188 |
130 |
<tr>
|
189 |
|
<td>
|
190 |
|
<a role="button" data-toggle="popover" data-trigger="hover" data-title="Rule that triggered this action" data-content="<?=htmlspecialchars($rule)?>">
|
191 |
|
<i class="icon icon-<?=$iconfn?>"></i>
|
192 |
|
</a>
|
193 |
|
</td>
|
194 |
|
<td><?=substr(htmlspecialchars($filterent['time']),0,-3)?></td>
|
|
131 |
<td><a role="button" data-toggle="popover" data-trigger="hover"
|
|
132 |
data-title="Rule that triggered this action"
|
|
133 |
data-content="<?=htmlspecialchars($rule)?>"> <i
|
|
134 |
class="icon icon-<?=$iconfn?>"></i>
|
|
135 |
</a></td>
|
|
136 |
<td title="<?=htmlspecialchars($filterent['time'])?>"><?=substr(htmlspecialchars($filterent['time']),0,-3)?></td>
|
195 |
137 |
<td><?=htmlspecialchars($filterent['interface']);?></td>
|
196 |
|
<td>
|
197 |
|
<a href="diag_dns.php?host=<?=$filterent['srcip']?>" title="<?=gettext("Reverse Resolve with DNS")?>">
|
198 |
|
<?=$srcIP?>
|
199 |
|
</a>:<?=$srcPort?>
|
|
138 |
<td><a href="diag_dns.php?host=<?=$filterent['srcip']?>"
|
|
139 |
title="<?=gettext("Reverse Resolve with DNS")?>"><?=$srcIP?></a>:<?=htmlspecialchars($filterent['srcport'])?>
|
200 |
140 |
</td>
|
201 |
|
<td>
|
202 |
|
<a href="diag_dns.php?host=<?=$filterent['dstip']?>" title="<?=gettext("Reverse Resolve with DNS");?>">
|
203 |
|
<?=$dstIP?>
|
204 |
|
</a>:<?=$dstPort?>
|
|
141 |
<td><a href="diag_dns.php?host=<?=$filterent['dstip']?>"
|
|
142 |
title="<?=gettext("Reverse Resolve with DNS");?>"><?=$dstIP?></a>:<?=htmlspecialchars($filterent['dstport'])?>
|
205 |
143 |
</td>
|
206 |
144 |
</tr>
|
207 |
145 |
<?php endforeach; ?>
|
208 |
146 |
</tbody>
|
209 |
147 |
</table>
|
210 |
148 |
|
211 |
|
<!-- close the body we're wrapped in and add a configuration-panel -->
|
212 |
|
</div><div class="panel-footer collapse">
|
213 |
|
|
214 |
|
<form action="/widgets/widgets/log.widget.php" method="post">
|
215 |
|
Number of lines to display:
|
216 |
|
<select name="filterlogentries" class="formfld unknown" id="filterlogentries">
|
217 |
|
<?php for ($i = 1; $i <= 20; $i++) { ?>
|
218 |
|
<option value="<?php echo $i;?>" <?php if ($nentries == $i) echo "selected=\"selected\"";?>><?php echo $i;?></option>
|
219 |
|
<?php } ?>
|
220 |
|
</select>
|
221 |
|
|
222 |
|
<?php
|
223 |
|
$Include_Act = explode(" ", $nentriesacts);
|
224 |
|
if ($nentriesinterfaces == "All") $nentriesinterfaces = "";
|
225 |
|
?>
|
226 |
|
<input id="actpass" name="actpass" type="checkbox" value="Pass" <?php if (in_arrayi('Pass', $Include_Act)) echo "checked=\"checked\""; ?> /> Pass
|
227 |
|
<input id="actblock" name="actblock" type="checkbox" value="Block" <?php if (in_arrayi('Block', $Include_Act)) echo "checked=\"checked\""; ?> /> Block
|
228 |
|
<input id="actreject" name="actreject" type="checkbox" value="Reject" <?php if (in_arrayi('Reject', $Include_Act)) echo "checked=\"checked\""; ?> /> Reject
|
229 |
|
<br />
|
230 |
|
Interfaces:
|
231 |
|
<select id="filterlogentriesinterfaces" name="filterlogentriesinterfaces" class="formselect">
|
232 |
|
<option value="All">ALL</option>
|
233 |
149 |
<?php
|
234 |
|
$interfaces = get_configured_interface_with_descr();
|
235 |
|
foreach ($interfaces as $iface => $ifacename):
|
236 |
|
?>
|
237 |
|
<option value="<?=$iface;?>" <?php if ($nentriesinterfaces == $iface) echo "selected=\"selected\"";?>>
|
238 |
|
<?=htmlspecialchars($ifacename);?>
|
239 |
|
</option>
|
240 |
|
<?php
|
241 |
|
endforeach;
|
242 |
|
unset($interfaces);
|
243 |
|
unset($Include_Act);
|
|
150 |
|
|
151 |
/* for AJAX response, we only need the panel-body */
|
|
152 |
if (isset($_POST['lastsawtime']))
|
|
153 |
exit;
|
244 |
154 |
?>
|
245 |
|
</select>
|
246 |
155 |
|
247 |
|
<input id="submita" name="submita" type="submit" class="formbtn" value="Save" />
|
248 |
|
</form>
|
|
156 |
<!-- close the body we're wrapped in and add a configuration-panel -->
|
|
157 |
</div>
|
|
158 |
<div class="panel-footer collapse">
|
|
159 |
|
|
160 |
<form action="/widgets/widgets/log.widget.php" method="post"
|
|
161 |
class="form-horizontal">
|
|
162 |
<div class="form-group">
|
|
163 |
<label for="filterlogentries" class="col-sm-4 control-label">Number
|
|
164 |
of entries</label>
|
|
165 |
<div class="col-sm-6">
|
|
166 |
<input type="number" name="filterlogentries" value="<?=$nentries?>"
|
|
167 |
min="1" max="20" class="form-control" />
|
|
168 |
</div>
|
|
169 |
</div>
|
|
170 |
|
|
171 |
<div class="form-group">
|
|
172 |
<label class="col-sm-4 control-label">Filter actions</label>
|
|
173 |
<div class="col-sm-6 checkbox">
|
|
174 |
<?php $include_acts = explode(" ", strtolower($nentriesacts)); ?>
|
|
175 |
<label><input name="actpass" type="checkbox" value="Pass"
|
|
176 |
<?=(in_array('pass', $include_acts) ? 'checked="checked"':'')?> />Pass</label>
|
|
177 |
<label><input name="actblock" type="checkbox" value="Block"
|
|
178 |
<?=(in_array('block', $include_acts) ? 'checked="checked"':'')?> />Block</label>
|
|
179 |
<label><input name="actreject" type="checkbox" value="Reject"
|
|
180 |
<?=(in_array('reject', $include_acts) ? 'checked="checked"':'')?> />Reject</label>
|
|
181 |
</div>
|
|
182 |
</div>
|
|
183 |
|
|
184 |
<div class="form-group">
|
|
185 |
<label for="filterlogentriesinterfaces"
|
|
186 |
class="col-sm-4 control-label">Filter interface</label>
|
|
187 |
<div class="col-sm-6 checkbox">
|
|
188 |
<select name="filterlogentriesinterfaces" class="form-control">
|
|
189 |
<?php foreach (array("All" => "ALL") + get_configured_interface_with_descr() as $iface => $ifacename):?>
|
|
190 |
<option value="<?=$iface?>"
|
|
191 |
<?=($nentriesinterfaces==$iface?'selected="selected"':'')?>><?=htmlspecialchars($ifacename)?></option>
|
|
192 |
<?php endforeach;?>
|
|
193 |
</select>
|
|
194 |
</div>
|
|
195 |
</div>
|
|
196 |
|
|
197 |
<div class="form-group">
|
|
198 |
<div class="col-sm-offset-4 col-sm-6">
|
|
199 |
<button type="submit" class="btn btn-default">Save</button>
|
|
200 |
</div>
|
|
201 |
</div>
|
|
202 |
</form>
|
log.widget - replaced js processor with simple xhr that fetches html
firewall_rules - typo, duplicate $pgtitle
log.js - simple xhr html updater, no need for duplicate logic
log.widget - migrated