raspap-webgui-mirror/ajax/system/sys_debug.php

24 lines
634 B
PHP
Raw Normal View History

<?php
require '../../includes/csrf.php';
require_once '../../includes/config.php';
2023-10-31 15:17:13 +00:00
if (isset($_POST['csrf_token'])) {
if (csrfValidateRequest() && !CSRFValidate()) {
handleInvalidCSRFToken();
}
2023-10-31 22:18:23 +00:00
$root = getenv("DOCUMENT_ROOT");
2023-11-01 07:46:36 +00:00
exec('sudo '.RASPI_CONFIG.'/system/debuglog.sh -i '.$root, $return);
$logOutput = implode(PHP_EOL, $return);
$tempDir = sys_get_temp_dir();
2023-10-31 22:18:23 +00:00
$filePath = $tempDir . DIRECTORY_SEPARATOR . RASPI_DEBUG_LOG;
$handle = fopen($filePath, "w");
fwrite($handle, $logOutput);
fclose($handle);
echo json_encode($filePath);
2023-10-31 15:17:13 +00:00
} else {
handleInvalidCSRFToken();
}