From f975bd2f2a1423dd9e2f92c9d687cde6a154dec2 Mon Sep 17 00:00:00 2001 From: slawkens Date: Thu, 26 Feb 2026 19:48:16 +0100 Subject: [PATCH] [WIP] Mounts TOML + XML parsers --- system/src/Server/Mounts.php | 24 +++++++++++++++ system/src/Server/TOML/Mounts.php | 39 ++++++++++++++++++++++++ system/src/Server/XML/Mounts.php | 49 +++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 system/src/Server/Mounts.php create mode 100644 system/src/Server/TOML/Mounts.php create mode 100644 system/src/Server/XML/Mounts.php diff --git a/system/src/Server/Mounts.php b/system/src/Server/Mounts.php new file mode 100644 index 00000000..ae6e6d24 --- /dev/null +++ b/system/src/Server/Mounts.php @@ -0,0 +1,24 @@ +load(); + + return $mounts->get(); + }); + } +} diff --git a/system/src/Server/TOML/Mounts.php b/system/src/Server/TOML/Mounts.php new file mode 100644 index 00000000..cad7e3a8 --- /dev/null +++ b/system/src/Server/TOML/Mounts.php @@ -0,0 +1,39 @@ + $mount) + { + $this->mounts[] = [ + 'id' => $mount['id'], + 'client_id' => $mount['clientid'] ?? false, + 'name' => $name, + 'speed' => $mount['speed'] ?? 0, + 'premium' => $mount['premium'] ?? false, + ]; + } + } + + public function get(): array { + return $this->mounts; + } +} diff --git a/system/src/Server/XML/Mounts.php b/system/src/Server/XML/Mounts.php new file mode 100644 index 00000000..5773757c --- /dev/null +++ b/system/src/Server/XML/Mounts.php @@ -0,0 +1,49 @@ +load($file); + + foreach ($xml->getElementsByTagName('mount') as $mount) { + $this->mounts[] = $this->parseMountNode($mount); + } + } + + private function parseMountNode($node): array + { + $id = (int)$node->getAttribute('id'); + $client_id = (int)$node->getAttribute('clientid'); + $name = $node->getAttribute('name'); + $speed = (int)$node->getAttribute('speed'); + $premium = getBoolean($node->getAttribute('premium')); + $type = $node->getAttribute('type'); + + return [ + 'id' => $id, + 'client_id' => $client_id, + 'name' => $name, + 'speed' => $speed, + 'premium' => $premium, + 'type' => $type + ]; + } + + public function get(): array { + return $this->mounts; + } +}