- Run button (blue) fires script immediately, opens log panel; stamps log with manual run timestamp before exec - Save moved to card footer — one button saves all cron expressions for the orchestrator and all its children at once - Toggle still auto-saves immediately on flip (enable/disable is instant) - Removed onblur from cron inputs — cron only saves on explicit Save - api/run.php: validates id, appends timestamp, execs script in background
29 lines
910 B
PHP
29 lines
910 B
PHP
<?php
|
|
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'] ?? '');
|
|
|
|
if (!$id || !preg_match('/^[a-zA-Z0-9_.\/\-]+\.sh$/', $id) || str_contains($id, '..')) {
|
|
echo json_encode(['ok' => false, 'error' => 'Invalid id']);
|
|
exit;
|
|
}
|
|
|
|
$script = SCRIPTS_DIR . '/' . $id;
|
|
if (!file_exists($script)) {
|
|
echo json_encode(['ok' => false, 'error' => 'Script not found: ' . $id]);
|
|
exit;
|
|
}
|
|
|
|
$logFile = vv_job_log_path($id);
|
|
$logDir = dirname($logFile);
|
|
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 &');
|
|
|
|
echo json_encode(['ok' => true]);
|