From 97a9cac5e8ecd19edc7ca931174e55ed26ae1464 Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 31 Oct 2023 20:31:27 +0000 Subject: [PATCH] Write debug log to tempDir, redirect + download w/ readfile() --- ajax/system/sys_debug.php | 11 ++++++++++- ajax/system/sys_get_logfile.php | 21 +++++++++++++++++++++ app/js/custom.js | 11 +++++++++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 ajax/system/sys_get_logfile.php diff --git a/ajax/system/sys_debug.php b/ajax/system/sys_debug.php index faad8fd3..8390dafc 100644 --- a/ajax/system/sys_debug.php +++ b/ajax/system/sys_debug.php @@ -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(); } diff --git a/ajax/system/sys_get_logfile.php b/ajax/system/sys_get_logfile.php new file mode 100644 index 00000000..7bcb3445 --- /dev/null +++ b/ajax/system/sys_get_logfile.php @@ -0,0 +1,21 @@ +