diff --git a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php index cf5f41e14..fdef02aad 100644 --- a/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php +++ b/plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/include/myservers1.php @@ -1,4 +1,3 @@ - -'; += 300) { + // Get the remote manifest JSON + $remoteManifestJson = file_get_contents($remoteResourceUrl . 'manifest.json'); + + // Compare the remote and local manifest versions + $remoteManifest = json_decode($remoteManifestJson, true); + $localManifest = json_decode(file_get_contents($localManifestFile), true); + + if ($remoteManifest && $localManifest && $remoteManifest !== $localManifest) { + // Update the local manifest + file_put_contents($localManifestFile, $remoteManifestJson); + + // Download the file contents for the search value + $searchText = 'connect-components.client.mjs'; + $fileValue = null; + + foreach ($remoteManifest as $key => $value) { + if (strpos($key, $searchText) !== false && isset($value["file"])) { + $fileValue = file_get_contents($remoteResourceUrl . $value["file"]); + break; + } + } + + if ($fileValue !== null) { + // Extract the directory path from the URL + $directoryPath = pathinfo($value["file"], PATHINFO_DIRNAME); + // Set the local file path + $localFilePath = '/usr/local/emhttp/plugins/dynamix.my.servers' . $directoryPath; + // Create the directory if it doesn't exist + if (!is_dir($localFilePath)) { + mkdir($localFilePath, 0777, true); + } + // Save the file contents to a local file + file_put_contents($localFilePath . '/' . basename($value["file"]), $fileValue); + } + } + + // Set the session cookie with the current timestamp + setcookie('manifest_last_checked', time(), time() + 300); // Expire in 5 minutes +} + +// Load the local manifest +$localManifest = json_decode(file_get_contents($localManifestFile), true); + +$searchText = 'connect-components.client.mjs'; +$fileValue = null; + +foreach ($localManifest as $key => $value) { + if (strpos($key, $searchText) !== false && isset($value["file"])) { + $fileValue = $value["file"]; + break; + } +} + +if ($fileValue !== null) { + $prefixedPath = '/plugins/dynamix.my.servers/connect-components/'; + echo ''; +} else { + echo ''; +} ?> -