function drawBar($deviceIndex, $timeOn, $timeOff, $dotdotdot = 0) { global $barHeight; global $barWidthPerHour; $left = round($timeOn / 3600.0 * $barWidthPerHour); $width = max(1, round(($timeOff - $timeOn) / 3600.0 * $barWidthPerHour)); print "<span style=\"left: {$left}px; width: {$width}px;\" class=\"d{$deviceIndex}\"></span>\n"; if ($dotdotdot) { $both = $left + $width; print "<span style=\"left: {$both}px;\" class=\"d{$deviceIndex} dotdotdot\">...</span>\n"; } } $reverseDevices = array_flip($devices); $days = array(); while ($line = fgets($logFh)) { if ($parsedLine = parseLogLine($line)) { if ($parsedLine == NULL) { continue; } $currentDay = GregorianToJD($parsedLine[2], $parsedLine[3], $parsedLine[1]); $timeOfDay = $parsedLine[4] * 60 * 60 + $parsedLine[5] * 60 + $parsedLine[6]; $deviceIndex = 0; foreach ($devices as $devicePin) { if ($devicePin == $parsedLine[7]) { break; } ++$deviceIndex; } if ($deviceIndex == count($devices)) { continue; }
if (substr($candidateFile, -3) === ".gz") { $logFh = @gzopen($candidateFile, "r"); } else { $logFh = @fopen($candidateFile, "r"); } if ($logFh) { break; } } } else { $logFh = @fopen($logFile, "r"); } if ($logFh) { $reverseDevices = array_flip($devices); while ($line = fgets($logFh)) { if ($matches = parseLogLine($line)) { ?> <tr> <td><?php echo sprintf("%02d-%02d-%02d %02d:%02d:%02d", $matches[1], $matches[2], $matches[3], $matches[4], $matches[5], $matches[6]); ?> </td> <td><?php echo $reverseDevices[$matches[7]]; ?> </td> <td> <?php if ($matches[8] == 1) { print 'On'; } else {