Store logged data in spool directory
[usb-wde1-tools.git] / htmlreport / gen-html.php
old mode 100644 (file)
new mode 100755 (executable)
index f495622..61c94ec
@@ -1,3 +1,4 @@
+#!/usr/bin/env php
 <?php
 $cfgfile = __DIR__ . '/config.php';
 if (!file_exists($cfgfile)) {
@@ -6,6 +7,18 @@ if (!file_exists($cfgfile)) {
 }
 require $cfgfile;
 
+if (!function_exists('rrd_lastupdate')) {
+    echo "rrd PHP extension is missing\n";
+    exit(2);
+}
+
+if (!is_array($filetemplate)) {
+    $filetemplate = array_combine(
+        array_keys($names),
+       array_fill(0, count($names), $filetemplate)
+    );
+}
+
 $data = array();
 foreach ($names as $id => $name) {
     $data[$id]['name'] = $name;
@@ -14,7 +27,7 @@ foreach ($names as $id => $name) {
             str_replace(
                 array('{item}', '{id}'),
                 array($item, $id),
-                $filetemplate
+                $filetemplate[$id]
             )
         );
         if ($lu === false) {