Add Dry Run button; fix CSRF token on all POST API calls
All fetch() POSTs now send application/x-www-form-urlencoded with the page-injected csrf_token, satisfying unRAID's auto_prepend CSRF check. All PHP API handlers switched from php://input JSON to $_POST. Also adds Dry Run button (orange, between Run and Log) that sets DRY_RUN=1 in the script environment before executing.
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
header('Content-Type: application/json');
|
||||
require_once dirname(__DIR__) . '/include/scheduler.php';
|
||||
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
$id = trim($body['id'] ?? '');
|
||||
$id = trim($_POST['id'] ?? '');
|
||||
|
||||
if (!$id || !preg_match('/^[a-zA-Z0-9_.\/\-]+\.sh$/', $id) || str_contains($id, '..')) {
|
||||
echo json_encode(['ok' => false, 'error' => 'Invalid id']);
|
||||
@@ -23,6 +22,6 @@ if (!is_dir($logDir)) mkdir($logDir, 0755, true);
|
||||
// Stamp the log so the panel shows when the run started
|
||||
file_put_contents($logFile, date('[Y-m-d H:i:s]') . " Manual run started\n", FILE_APPEND);
|
||||
|
||||
exec('bash ' . escapeshellarg($script) . ' >> ' . escapeshellarg($logFile) . ' 2>&1 &');
|
||||
exec('nohup bash ' . escapeshellarg($script) . ' >> ' . escapeshellarg($logFile) . ' 2>&1 </dev/null &');
|
||||
|
||||
echo json_encode(['ok' => true]);
|
||||
|
||||
Reference in New Issue
Block a user