diff --git a/api/actions/lookup.php b/api/actions/lookup.php new file mode 100644 index 0000000..6231c21 --- /dev/null +++ b/api/actions/lookup.php @@ -0,0 +1,21 @@ + "ping.php", "vars" => [ ] + ], + "lookup" => [ + "load" => "lookup.php", + "vars" => [ + "id" => "/^[0-9a-z]+$/" + ] ] ]; diff --git a/database.mwb b/database.mwb index 5f8f8bd..79264d0 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/lib/Machine.lib.php b/lib/Machine.lib.php index fded1b6..170ca93 100644 --- a/lib/Machine.lib.php +++ b/lib/Machine.lib.php @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -class Machine { +class Machine implements JsonSerializable { private $machineid = ""; private $machine = []; @@ -26,6 +26,19 @@ class Machine { } } + public function jsonSerialize() { + if ($this->exists) { + return [ + "status" => "OK", + "id" => $this->machineid, + "info" => $this->machine, + "events" => $this->events, + "components" => $this->components + ]; + } + return []; + } + public static function create(): Machine { return new Machine(Machine::generateId()); } @@ -219,7 +232,8 @@ class Machine { public static function generateId(int $min = 1000000000, int $max = 9999999999): int { global $database; - $id = random_int(1000000000, 9999999999);; + $id = random_int(1000000000, 9999999999); + ; do { $id = random_int(1000000000, 9999999999);