Replace literal w/ RASPI_DEBUG_LOG

This commit is contained in:
billz 2023-10-31 22:18:23 +00:00
parent 98d5f5b64b
commit 86ac3e2ff6
4 changed files with 7 additions and 6 deletions

View file

@ -7,17 +7,16 @@ if (isset($_POST['csrf_token'])) {
if (csrfValidateRequest() && !CSRFValidate()) { if (csrfValidateRequest() && !CSRFValidate()) {
handleInvalidCSRFToken(); handleInvalidCSRFToken();
} }
exec( RASPI_CONFIG.'/system/debuglog.sh', $return); $root = getenv("DOCUMENT_ROOT");
exec( RASPI_CONFIG.'/system/debuglog.sh -i '.$root, $return);
$logOutput = implode(PHP_EOL, $return); $logOutput = implode(PHP_EOL, $return);
$filename = "raspap_debug.log";
$tempDir = sys_get_temp_dir(); $tempDir = sys_get_temp_dir();
$filePath = $tempDir . DIRECTORY_SEPARATOR . $filename; $filePath = $tempDir . DIRECTORY_SEPARATOR . RASPI_DEBUG_LOG;
$handle = fopen($filePath, "w"); $handle = fopen($filePath, "w");
fwrite($handle, $logOutput); fwrite($handle, $logOutput);
fclose($handle); fclose($handle);
echo json_encode($filePath); echo json_encode($filePath);
} else { } else {
handleInvalidCSRFToken(); handleInvalidCSRFToken();
} }

View file

@ -1,11 +1,11 @@
<?php <?php
require '../../includes/csrf.php'; require '../../includes/csrf.php';
require_once '../../includes/config.php';
$filePath = $_GET['filePath']; $filePath = $_GET['filePath'];
$filename = "raspap_debug.log";
if (isset($filePath) && strpos($filePath, $filename) !== false) { if (isset($filePath) && strpos($filePath, RASPI_DEBUG_LOG) !== false) {
header('Content-Type: application/octet-stream'); header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($filePath)); header('Content-Disposition: attachment; filename='.basename($filePath));
header('Expires: 0'); header('Expires: 0');

View file

@ -7,6 +7,7 @@ define('RASPI_CONFIG_PROVIDERS', 'config/vpn-providers.json');
define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth'); define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');
define('RASPI_WIFI_AP_INTERFACE', 'wlan0'); define('RASPI_WIFI_AP_INTERFACE', 'wlan0');
define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap'); define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap');
define('RASPI_DEBUG_LOG', 'raspap_debug.log');
// Constants for configuration file paths. // Constants for configuration file paths.
// These are typical for default RPi installs. Modify if needed. // These are typical for default RPi installs. Modify if needed.

View file

@ -12,6 +12,7 @@ $defaults = [
'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth',
'RASPI_WIFI_AP_INTERFACE' => 'wlan0', 'RASPI_WIFI_AP_INTERFACE' => 'wlan0',
'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap', 'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap',
'RASPI_DEBUG_LOG' => 'raspap_debug.log',
// Constants for configuration file paths. // Constants for configuration file paths.
// These are typical for default RPi installs. Modify if needed. // These are typical for default RPi installs. Modify if needed.