0) {
$log_totalfiles = count($log_filenames);
for ($cnt = 0; $cnt < $log_totalfiles; $cnt++) {
$log_filenames[$cnt] = basename($log_filenames[$cnt]);
}
}
// Sort the filename
asort($log_filenames);
// Done
return $log_filenames;
}
/* Define logtypes:
name => Displayname of the type
ext => Log extentions (array for multiple extentions)
logdir => Log directory
clear => Add clear button (TRUE/FALSE) */
$pfb_logtypes = array( 'defaultlogs' => array('name' => 'Log Files',
'logdir' => "{$pfb['logdir']}/",
'logs' => array('pfblockerng.log', 'error.log', 'dnsbl.log', 'extras.log', 'maxmind_ver'),
'download' => TRUE,
'clear' => TRUE
),
'masterfiles' => array('name' => 'Masterfiles',
'logdir' => "{$pfb['dbdir']}/",
'logs' => array('masterfile', 'mastercat'),
'download' => TRUE,
'clear' => FALSE
),
'originallogs' => array('name' => 'Original IP Files',
'ext' => array('orig', 'raw'),
'logdir' => "{$pfb['origdir']}/",
'download' => TRUE,
'clear' => TRUE
),
'origdnslogs' => array('name' => 'Original DNS Files',
'ext' => array('orig', 'raw'),
'logdir' => "{$pfb['dnsorigdir']}/",
'download' => TRUE,
'clear' => TRUE
),
'denylogs' => array('name' => 'Deny Files',
'ext' => 'txt',
'txt' => 'deny',
'logdir' => "{$pfb['denydir']}/",
'download' => TRUE,
'clear' => TRUE
),
'dnsbl' => array('name' => 'DNSBL Files',
'ext' => array('txt', 'ip'),
'txt' => 'dnsbl',
'logdir' => "{$pfb['dnsdir']}/",
'download' => TRUE,
'clear' => TRUE
),
'permitlogs' => array('name' => 'Permit Files',
'ext' => 'txt',
'txt' => 'permit',
'logdir' => "{$pfb['permitdir']}/",
'download' => TRUE,
'clear' => TRUE
),
'matchlogs' => array('name' => 'Match Files',
'ext' => 'txt',
'txt' => 'match',
'logdir' => "{$pfb['matchdir']}/",
'download' => TRUE,
'clear' => TRUE
),
'nativelogs' => array('name' => 'Native Files',
'ext' => 'txt',
'logdir' => "{$pfb['nativedir']}/",
'download' => TRUE,
'clear' => TRUE
),
'aliaslogs' => array('name' => 'Alias Files',
'ext' => 'txt',
'logdir' => "{$pfb['aliasdir']}/",
'download' => TRUE,
'clear' => FALSE
),
'etiprep' => array('name' => 'ET IPRep Files',
'ext' => '*',
'logdir' => "{$pfb['etdir']}/",
'download' => TRUE,
'clear' => FALSE
),
'country' => array('name' => 'Country Files',
'ext' => 'txt',
'logdir' => "{$pfb['ccdir']}/",
'download' => TRUE,
'clear' => FALSE
),
'unbound' => array('name' => 'Unbound',
'ext' => 'conf',
'logdir' => "{$pfb['dnsbldir']}/",
'download' => TRUE,
'clear' => FALSE
)
);
// Check logtypes
$logtypeid = 'defaultlogs';
if (isset($_POST['logtype'])) {
$logtypeid = htmlspecialchars($_POST['logtype']);
} elseif (isset($_GET['logtype'])) {
$logtypeid = htmlspecialchars($_GET['logtype']);
}
// Check if POST has been set
if (isset($_POST['file'])) {
clearstatcache();
$pfb_logfilename = htmlspecialchars($_POST['file']);
$pfb_ext = pathinfo($pfb_logfilename, PATHINFO_EXTENSION);
// Load log
if ($_POST['action'] == 'load') {
if (!is_file($pfb_logfilename)) {
echo "|3|" . gettext('Log file is empty or does not exist') . ".|";
} else {
$data = file_get_contents($pfb_logfilename);
if ($data === false) {
echo "|1|" . gettext('Failed to read log file') . ".|";
} else {
$data = base64_encode($data);
echo "|0|" . $pfb_logfilename . "|" . $data . "|";
}
}
exit;
}
}
if (isset($_POST['logFile'])) {
$s_logfile = htmlspecialchars($_POST['logFile']);
// Clear selected file
if (isset($_POST['clear'])) {
unlink_if_exists($s_logfile);
}
// Download log
if (isset($_POST['download'])) {
if (file_exists($s_logfile)) {
ob_start(); //important or other posts will fail
if (isset($_SERVER['HTTPS'])) {
header('Pragma: ');
header('Cache-Control: ');
} else {
header('Pragma: private');
header('Cache-Control: private, must-revalidate');
}
header('Content-Type: application/octet-stream');
header('Content-length: ' . filesize($s_logfile));
header('Content-disposition: attachment; filename = ' . basename($s_logfile));
ob_end_clean(); //important or other post will fail
readfile($s_logfile);
}
}
} else {
$s_logfile = '';
}
$pgtitle = gettext('pfBlockerNG: Log Browser');
include_once('head.inc');
?>
");
if ($savemsg) {
print_info_box($savemsg);
}
?>
|
|
|
|
|
|
|
|
|
|
|