mirror of
https://github.com/SubleXBle/Fail2Ban-Report.git
synced 2026-02-09 02:08:42 -06:00
Create get-json.php
This commit is contained in:
21
Web-UI/includes/get-json.php
Normal file
21
Web-UI/includes/get-json.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
// includes/get-json.php
|
||||
require_once __DIR__ . '/paths.php';
|
||||
|
||||
$filename = basename($_GET['file'] ?? '');
|
||||
$filepath = $PATHS["fail2ban"] . '/' . $filename;
|
||||
|
||||
// secure: it can only read json from archive
|
||||
if (
|
||||
!$filename ||
|
||||
!preg_match('/^fail2ban-events-\d{8}\.json$/', $filename) ||
|
||||
strpos(realpath($filepath), realpath($PATHS["fail2ban"])) !== 0 ||
|
||||
!file_exists($filepath)
|
||||
) {
|
||||
http_response_code(404);
|
||||
exit('Not found');
|
||||
}
|
||||
|
||||
// deliver header and json
|
||||
header('Content-Type: application/json');
|
||||
readfile($filepath);
|
||||
Reference in New Issue
Block a user