<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!-- config --> <?php include "config.php"; # DB and password config $html_title = "Nättsjö 1:15 event log"; $title = $html_title; $REFRESH = 3600; # Seconds for $limit = 200; $do_group = "GROUP BY date(time)"; $do_group = ""; $sql = "SELECT WEEKDAY(l.time) as weekday, WEEK(l.time,3) as wk, YEAR(l.time) as yr, DAY(l.time) as d, DATE_FORMAT(l.time, '%a %b %d %H:%i:%s') as t, d.descr FROM nattsjo_events_log l, nattsjo_devices d WHERE l.method = d.method AND l.td_event = d.td_event AND d.type = 2 $do_group ORDER BY -l.time LIMIT $limit"; $this_document = $_SERVER["SCRIPT_NAME"]; ?> <!-- main --> <HTML> <HEAD> <TITLE><?php echo "$html_title" ?></TITLE> <META http-equiv=Content-Type content="text/html; charset=utf-8"> <LINK href="temp.css" type="text/css" rel="stylesheet"> <META http-equiv="Refresh" content="<?php echo "$REFRESH" ?>"> <META http-equiv="Pragma" content="no-cache"> </HEAD> <body> <table class="events"> <tr class='title'> <td colspan="2"><?php echo $title;?></td> </tr> <tbody> <tr> <td class='header1'>Time</td> <td class='header2'>Event</td> </tr> <?php $DB = mysql_connect($DBHOST, $DBUSER, $DBPASS); mysql_select_db($DBNAME, $DB); mysql_query("SET NAMES UTF8", $DB); $result = mysql_query($sql); $blank_row = "<tr class='blank'><td colspan=2></td></tr>\n"; $cur_date = 0; $week = 0; $day = 0; while ($row = mysql_fetch_array($result)) { if ($row["wk"] <> $week) { $week = $row["wk"]; $day = $row["d"]; echo $blank_row; echo "<tr class='week'><td>Week $week " . $row["yr"] . "</td></tr>\n"; } if ($row["d"] <> $day) { $day = $row["d"]; if (!$do_group) echo $blank_row . $blank_row . $blank_row; } echo "<tr class='data'>"; echo "<td>"; echo $row["t"]; echo "</td><td"; if (preg_match("/OFF/", $row["descr"])) { echo " class='relay_off'"; } if (preg_match("/ON/", $row["descr"])) { echo " class='relay_on'"; } echo ">"; echo $row["descr"]; echo "</td></tr>\n"; } echo $blank_row; echo $blank_row; ?> <tr><td colspan=2><hr></td></tr> <tr><td colspan=2 class="right">(c) Daniel Vindevåg</td></tr> </tbody></table> </body> </html>