$IMGFILE="/tmp/power.svg";
+$days = array_key_exists('d', $_REQUEST) ? (int)$_REQUEST['d'] : 0;
$hours = array_key_exists('h', $_REQUEST) ? (int)$_REQUEST['h'] : 0;
$minutes = array_key_exists('m', $_REQUEST) ? (int)$_REQUEST['m'] : 0;
-if (!$hours && !$minutes)
+if (!$days && !$hours && !$minutes)
$hours = 1;
+$step = array_key_exists('step', $_REQUEST) ? (int)$_REQUEST['step'] : 0;
$params = [
"--daemon", RRDSOCK,
"--imgformat", "SVG",
- "-s", "now-".$hours."h".$minutes."m",
+ "-s", "now-".$days."d".$hours."h".$minutes."m",
"--width", "".IMGWIDTH,
"--height", "".IMGHEIGHT,
"--vertical-label", "watts",
#"LINE:maxwatts#0000FF",
#"GPRINT:maxwatts:Max %6.2lf %sW",
];
+if ($step) {
+ $params[] = '--step';
+ $params[] = "$step";
+}
/*header("Content-Type: text/plain");
foreach ($params as $param) echo(escapeshellarg($param)." ");
}
header("Content-Type: image/svg+xml");
header("Cache-Control: no-cache, max-age=0, must-revalidate");
-header("Refresh: ".(60*(60*$hours)+$minutes)/IMGWIDTH);
+header("Refresh: ".(60*(60*(24*$days+$hours))+$minutes)/IMGWIDTH);
readfile($IMGFILE);
?>