Jelajahi Sumber

Grab IP by qualifyURL rather than substring

Henry Whitaker 6 tahun lalu
induk
melakukan
e80dac95e0
1 mengubah file dengan 2 tambahan dan 1 penghapusan
  1. 2 1
      api/functions/homepage-connect-functions.php

+ 2 - 1
api/functions/homepage-connect-functions.php

@@ -127,7 +127,8 @@ function getPihole()
 				$response = Requests::get($url, [], []);
 				if ($response->success) {
 					$piholeResults = json_decode($response->body, true);
-					$api['data'][substr($url, 7, -16)] = $piholeResults;
+					$ip = qualifyURL($url, true)['host'];
+					$api['data'][$ip] = $piholeResults;
 				}
 			} catch (Requests_Exception $e) {
 				writeLog('error', 'Pi-hole Connect Function - Error: ' . $e->getMessage(), 'SYSTEM');