[]]; $message = ''; $msgType = ''; // success | error // === LOGIC === if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Делаем бэкап file_put_contents($backupDir . 'config_' . time() . '.json', $json); $action = $_POST['action'] ?? ''; if ($action === 'save') { $id = $_POST['id']; $name = htmlspecialchars($_POST['name']); $url = htmlspecialchars($_POST['url']); $match = htmlspecialchars($_POST['metaMatch']); $cat = htmlspecialchars($_POST['category']) ?: 'Общее'; if (empty($id)) { // ADD NEW $newStation = [ 'id' => uniqid(), 'name' => $name, 'url' => $url, 'metaMatch' => $match, 'category' => $cat ]; $data['stations'][] = $newStation; $message = "Станция '$name' добавлена."; } else { // EDIT EXISTING foreach ($data['stations'] as &$s) { if ($s['id'] === $id) { $s['name'] = $name; $s['url'] = $url; $s['metaMatch'] = $match; $s['category'] = $cat; break; } } $message = "Станция '$name' обновлена."; } $msgType = 'success'; } elseif ($action === 'delete') { $id = $_POST['id']; $data['stations'] = array_filter($data['stations'], function($s) use ($id) { return $s['id'] !== $id; }); $data['stations'] = array_values($data['stations']); $message = "Станция удалена."; $msgType = 'error'; } // Save $newJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); if (file_put_contents($configFile, $newJson)) { $json = $newJson; } else { $message = "ОШИБКА ЗАПИСИ ФАЙЛА! Проверь права на папку app."; $msgType = 'error'; } } // Grouping $grouped = []; $categories = []; foreach ($data['stations'] as $station) { $cat = !empty($station['category']) ? $station['category'] : 'Без категории'; $grouped[$cat][] = $station; $categories[$cat] = true; } ksort($grouped); ?> PHOENIX CONTROL v3

PHOENIX CONTROL

SYSTEM STATUS: ONLINE
Эфирная сетка пуста (или ошибка чтения).
$stations): ?>