diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2011-10-31 20:33:05 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2011-10-31 20:33:05 +0100 |
| commit | 133a6dff495236e2d3a4eb70081ddb1448765625 (patch) | |
| tree | cabc0df642f5432b10129448a727c4fbd4193f4d /htmlreport/gen-html.php | |
| parent | dfdadfc0ee73f552273966135963be036c5d4223 (diff) | |
| download | usb-wde1-tools-133a6dff495236e2d3a4eb70081ddb1448765625.tar.gz usb-wde1-tools-133a6dff495236e2d3a4eb70081ddb1448765625.zip | |
(html) file generator
Diffstat (limited to 'htmlreport/gen-html.php')
| -rw-r--r-- | htmlreport/gen-html.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/htmlreport/gen-html.php b/htmlreport/gen-html.php new file mode 100644 index 0000000..f495622 --- /dev/null +++ b/htmlreport/gen-html.php @@ -0,0 +1,36 @@ +<?php +$cfgfile = __DIR__ . '/config.php'; +if (!file_exists($cfgfile)) { + echo "Copy config.php.dist to config.php and adjust it\n"; + exit(1); +} +require $cfgfile; + +$data = array(); +foreach ($names as $id => $name) { + $data[$id]['name'] = $name; + foreach (array('humidity', 'temperature') as $item) { + $lu = rrd_lastupdate( + str_replace( + array('{item}', '{id}'), + array($item, $id), + $filetemplate + ) + ); + if ($lu === false) { + throw new Exception(rrd_error()); + } + + $data[$id][$item] = reset($lu['data']); + } +} + +foreach (glob(__DIR__ . '/templates/*.php') as $tplfile) { + $outfile = $outdir . basename($tplfile, '.php'); + ob_start(); + include $tplfile; + $content = ob_get_contents(); + ob_end_clean(); + file_put_contents($outfile, $content); +} +?>
\ No newline at end of file |
