add type checking to generic_stats.inc.php for $vars['to'] and $vars['from'] (#14871)

* make sure the $vars['from'] and $vars['to'] are actually numeric

* style fix
This commit is contained in:
Zane C. Bowers-Hadley 2023-03-02 15:59:31 -06:00 committed by GitHub
parent a828bdf26c
commit a0f1dab07b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,8 +119,14 @@ if ($height > 25) {
$rrd_options .= ' VDEF:' . $id . '25th=' . $id . ',25,PERCENTNAN';
$rrd_options .= ' VDEF:' . $id . '75th=' . $id . ',75,PERCENTNAN';
// the if is needed as with out it the group page will case an error
// devices/group=1/format=graph_poller_perf/from=-24hour/to=now/
if (is_numeric($vars['to']) && is_numeric($vars['from'])) {
$time_diff = $vars['to'] - $vars['from'];
} else {
$time_diff = 1;
}
// displays nan if less than 17 hours
$time_diff = $vars['to'] - $vars['from'];
if ($time_diff >= 61200) {
$rrd_options .= ' DEF:' . $id . "1d=$filename:$ds:AVERAGE:step=86400";
}