Plugin lives in Plugin/ — invisible to User Script Plugin. dev_install.sh symlinks into /usr/local/emhttp/plugins/varaverk/ for development. Pages: Monitor (5s poll), Scheduler (orchs + Advanced children, toggle + cron), Config (raw editor, host-aware file access), Docs (markdown + live $VAR substitution). API endpoints: monitor.php (JSON), scheduler.php (writes schedule.json + cron.d), config.php (writes conf files with host permission check). Includes: config.php (parser, host detection, var map), scheduler.php (job tree, cron.d rebuild), monitor.php (docker, GPU, resources, fallback, transcode), docs.php (file tree, var substitution, Parsedown renderer).
23 lines
713 B
PHP
23 lines
713 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'] ?? '');
|
|
$enabled = (bool)($body['enabled'] ?? false);
|
|
$cron = trim($body['cron'] ?? '');
|
|
|
|
if (!$id) {
|
|
echo json_encode(['ok' => false, 'error' => 'Missing id']);
|
|
exit;
|
|
}
|
|
|
|
// Basic cron validation — 5 fields or empty
|
|
if ($cron && !preg_match('/^(\S+\s+){4}\S+$/', $cron)) {
|
|
echo json_encode(['ok' => false, 'error' => 'Invalid cron expression']);
|
|
exit;
|
|
}
|
|
|
|
$ok = vv_schedule_update($id, $enabled, $cron);
|
|
echo json_encode(['ok' => $ok, 'error' => $ok ? null : 'Failed to write schedule']);
|