"context/git@gitlab.lisha.ufsc.br:iot/platform.git" did not exist on "671375c5e62eb0f309c007845437b77e06b2ac81"
Newer
Older
Rodrigo Goncalves
committed
<?php
namespace Ingress\Services\tikiwiki;
class TikiWIkiConfig
{
private const CONFIG_PATH='./config/tikiwiki.json';
public static function getTrackers(string $domain) {
if (!file_exists(TikiWIkiConfig::CONFIG_PATH)) {
die("File not found: " . TikiWIkiConfig::CONFIG_PATH);
}
// Read the contents of the JSON file
$jsonContent = file_get_contents(TikiWIkiConfig::CONFIG_PATH);
if ($jsonContent === false) {
die("Error reading file: " . TikiWIkiConfig::CONFIG_PATH);
}
// Decode the JSON data into a PHP array
$dataArray = json_decode($jsonContent, true);
if (json_last_error() !== JSON_ERROR_NONE) {
die("Error decoding JSON: " . json_last_error_msg());
}
if (! array_key_exists('domains', $dataArray) || ! array_key_exists($domain, $dataArray['domains'])) {
die("Missing domain configuration: " . json_last_error_msg());
}
return $dataArray['domains'][$domain]['trackers'];
}
}