mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Write debug log to tempDir, redirect + download w/ readfile()
This commit is contained in:
@@ -8,7 +8,16 @@ if (isset($_POST['csrf_token'])) {
|
||||
handleInvalidCSRFToken();
|
||||
}
|
||||
exec( RASPI_CONFIG.'/system/debuglog.sh', $return);
|
||||
echo json_encode(end($return));
|
||||
|
||||
$logOutput = implode(PHP_EOL, $return);
|
||||
$filename = "raspap_debug.log";
|
||||
$tempDir = sys_get_temp_dir();
|
||||
$filePath = $tempDir . DIRECTORY_SEPARATOR . $filename;
|
||||
$handle = fopen($filePath, "w");
|
||||
fwrite($handle, $logOutput);
|
||||
fclose($handle);
|
||||
echo json_encode($filePath);
|
||||
|
||||
} else {
|
||||
handleInvalidCSRFToken();
|
||||
}
|
||||
|
21
ajax/system/sys_get_logfile.php
Normal file
21
ajax/system/sys_get_logfile.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
require '../../includes/csrf.php';
|
||||
|
||||
$filePath = $_GET['filePath'];
|
||||
$filename = "raspap_debug.log";
|
||||
|
||||
if (isset($filePath) && strpos($filePath, $filename) !== false) {
|
||||
header('Content-Type: application/octet-stream');
|
||||
header('Content-Disposition: attachment; filename='.basename($filePath));
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate');
|
||||
header('Pragma: public');
|
||||
header('Content-Length: '.filesize($filePath));
|
||||
readfile($filePath);
|
||||
exit();
|
||||
} else {
|
||||
header('Location: '.'/system_info');
|
||||
exit();
|
||||
}
|
||||
|
Reference in New Issue
Block a user