diff --git a/html/input.php b/html/input.php index 54a9aaf..4ac9679 100644 --- a/html/input.php +++ b/html/input.php @@ -7,6 +7,9 @@ if (!file_exists($jsonFile)) { } $data = json_decode(file_get_contents($jsonFile), true); +// ---------------------------------------------------- +// ADD SERVICE +// ---------------------------------------------------- if ($_SERVER["REQUEST_METHOD"] === "POST" && $_POST["action"] === "add") { $new = [ "id" => time(), @@ -22,25 +25,55 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" && $_POST["action"] === "add") { $data[] = $new; file_put_contents($jsonFile, json_encode($data, JSON_PRETTY_PRINT)); - echo "OK"; exit; } +// ---------------------------------------------------- +// DELETE SERVICE +// ---------------------------------------------------- if ($_SERVER["REQUEST_METHOD"] === "POST" && $_POST["action"] === "delete") { $id = intval($_POST["id"]); $newData = []; foreach ($data as $row) { - if ($row["id"] != $id) { - $newData[] = $row; - } + if ($row["id"] != $id) $newData[] = $row; } file_put_contents($jsonFile, json_encode($newData, JSON_PRETTY_PRINT)); echo "OK"; exit; } + +// ---------------------------------------------------- +// UPDATE SERVICE +// ---------------------------------------------------- +if ($_SERVER["REQUEST_METHOD"] === "POST" && $_POST["action"] === "edit") { + $id = intval($_POST["id"]); + $newData = []; + + foreach ($data as $row) { + if ($row["id"] == $id) { + $row = [ + "id" => $id, + "input_udp" => $_POST["input_udp"], + "output_udp" => $_POST["output_udp"], + "video_format" => $_POST["video_format"], + "audio_format" => $_POST["audio_format"], + "resolution" => $_POST["resolution"], + "video_bitrate" => $_POST["video_bitrate"], + "audio_bitrate" => $_POST["audio_bitrate"], + "status" => $_POST["status"] + ]; + } + $newData[] = $row; + } + + file_put_contents($jsonFile, json_encode($newData, JSON_PRETTY_PRINT)); + + echo "OK"; + exit; +} ?>
| Video Bitrate | Audio Bitrate | Status | -Action | +Actions | = $row["video_bitrate"] ?> | = $row["audio_bitrate"] ?> | = $row["status"] ?> | -+ | + + + | @@ -137,7 +178,9 @@ if ($_SERVER["REQUEST_METHOD"] === "POST" && $_POST["action"] === "delete") {
|---|