Use formmated string for "api.php?summary" (#2067)

restoring the old behavior

Signed-off-by: rdwebdesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign
2022-01-10 15:23:37 -03:00
committed by GitHub
parent 9a5f62aba7
commit f0c3ecded3
2 changed files with 14 additions and 3 deletions

View File

@@ -39,12 +39,23 @@ else
$tmp = explode(" ",$line);
if($tmp[0] === "domains_being_blocked" && !is_numeric($tmp[1])) {
$stats[$tmp[0]] = $tmp[1]; // Expect string response
// Expect string response
$stats[$tmp[0]] = $tmp[1];
} elseif ($tmp[0] === "status") {
// Expect string response
$stats[$tmp[0]] = piholeStatusAPI();
} elseif (isset($_GET['summary'])) {
// "summary" expects a formmated string response
if($tmp[0] !== "ads_percentage_today") {
$stats[$tmp[0]] = number_format($tmp[1]);
} else {
$stats[$tmp[0]] = number_format($tmp[1], 1, '.', '');
}
} else {
$stats[$tmp[0]] = floatval($tmp[1]); // Expect float response
// Expect float response
$stats[$tmp[0]] = floatval($tmp[1]);
}
}
$stats['gravity_last_updated'] = gravity_last_update(true);
$data = array_merge($data,$stats);