Просмотр исходного кода

Update docker/ui.php

Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
sstidl 1 год назад
Родитель
Сommit
0274f6e587
1 измененных файлов с 6 добавлено и 1 удалено
  1. 6 1
      docker/ui.php

+ 6 - 1
docker/ui.php

@@ -14,7 +14,12 @@ $mode=getenv("MODE");
 if($mode=="standalone" || $mode=="backend"){ ?>
 var SPEEDTEST_SERVERS=[];
 <?php } elseif ($mode=="dual") {
-	$servers = json_decode(file_get_contents('/servers.json'), true);
+ $jsonContent = @file_get_contents('/servers.json');
+ if ($jsonContent === false) {
+     $servers = [];
+ } else {
+     $servers = json_decode($jsonContent, true) ?: [];
+ }
 
 	// find out my own URL
 	$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";