21 lines
900 B
PHP
21 lines
900 B
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$action = $_GET["action"] ?? "status";
|
|
$configs = glob(__DIR__ . "/config/*.json");
|
|
$all = [];
|
|
foreach ($configs as $f) {
|
|
$name = basename($f, ".json");
|
|
$data = json_decode(file_get_contents($f), true);
|
|
$all[$name] = ["status" => $data["status"] ?? "unknown", "file" => $f];
|
|
}
|
|
if ($action === "status") echo json_encode(["ok"=>true, "credentials"=>$all]);
|
|
elseif ($action === "activate" && isset($_POST["name"],$_POST["key"],$_POST["value"])) {
|
|
$f = __DIR__ . "/config/" . basename($_POST["name"]) . ".json";
|
|
if (file_exists($f)) {
|
|
$d = json_decode(file_get_contents($f), true);
|
|
$d[$_POST["key"]] = $_POST["value"];
|
|
file_put_contents($f, json_encode($d, JSON_PRETTY_PRINT));
|
|
echo json_encode(["ok"=>true, "updated"=>$_POST["key"]]);
|
|
}
|
|
} else echo json_encode(["error"=>"Use: status, activate"]);
|