Skip to content

Commit

Permalink
use status api endpoint for FPP 5-7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
computergeek1507 authored Nov 27, 2023
1 parent 4129ee6 commit 169da65
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions www/api/controllers/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,8 @@ function SystemGetStatus()
foreach ($ipAddresses as $ip) {
//validate IP address is a valid IPv4 address - possibly overkill but have seen IPv6 addresses polled
if (filter_var($ip, FILTER_VALIDATE_IP)) {
//Make the request - also send across whether advancedView data is requested so it's returned all in 1 request

// TODO: For FPPD 6.0, this should be moved to the new API.
// On 5.0 Boxes it is just a redirect back to http://localhost/api/system/status
// Retained for backwards compatibility
$curl = curl_init("http://" . $ip . "/fppjson.php?command=getFPPstatus&advancedView=true");
// Only FPP 5+
$curl = curl_init("http://" . $ip . "/api/system/status");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
Expand All @@ -252,6 +248,16 @@ function SystemGetStatus()
if ($responseCode == 401) {
$result[$ip]['reason'] = "Cannot Access - Web GUI Password Set";
$result[$ip]["status_name"] = "password";
} else if ($responseCode == 404) {
// old device, FPP4
$curl = curl_init("http://" . $ip . "/fppjson.php?command=getFPPstatus&advancedView=true");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, 500);
curl_setopt($curl, CURLOPT_TIMEOUT_MS, 3000);
$request_content = curl_exec($curl);
$responseCode = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
} else if ($responseCode == 0) {
$result[$ip]["status_name"] = "unreachable";
}
Expand Down

0 comments on commit 169da65

Please sign in to comment.