46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
|
// Useless comment
|
|
require_once('DB.php');
|
|
Markup("timeline", "directives", "/\\(:timeline(\\s+.*)?\\s*:\\)/e",
|
|
"'<:block>'.GetEvents()");
|
|
|
|
|
|
function GetEvents() {
|
|
|
|
$days = 30;
|
|
if (isset($_POST['days'])) {
|
|
$days = intval($_POST['days']);
|
|
}
|
|
|
|
$dsn = 'sqlite:////home/crux/public_html/local/timeline.db';
|
|
$db =& DB::connect($dsn);
|
|
if (DB::isError($db)) die("Cannot connect to database");
|
|
$db->setFetchMode(DB_FETCHMODE_ASSOC);
|
|
$from = time() - ($days * 24 * 60 * 60);
|
|
$sql = "select * from events where event_tstamp >= $from order by event_tstamp desc";
|
|
$res =& $db->Query($sql);
|
|
if (DB::isError($res)) die("Query error");
|
|
|
|
|
|
$timeline .= '<table cellspacing="0" border="0" cellpadding="0">'."\n";
|
|
$currdate = "noway";
|
|
while ($evt =& $res->fetchRow()) {
|
|
if ($evt['event_date'] != $currdate) {
|
|
$timeline .= '<tr><td class="timeline-head" colspan="3"><span class="timeline-date">'.$evt['event_date']."</span></td></tr>\n";
|
|
}
|
|
$event_description = $evt['event_description'];
|
|
if ($evt['event_notes'] != "") {
|
|
$event_description .= ": ".$evt['event_notes'];
|
|
}
|
|
$img = '<img src="/images/'.$evt['event_type'].'.png">';
|
|
$timeline .= '<tr><td align="right" valign="top" width="60">'.$evt['event_time'].'</td><td align="center" valign="top" width="30">'.$img.'</td><td valign="top">'.$event_description.'</td></tr>';
|
|
$timeline .= "\n";
|
|
$currdate = $evt['event_date'];
|
|
}
|
|
$timeline .= "</table>\n";
|
|
$timeline .= '<br><form method="post" action="pmwiki.php?n=Main.Test">Show the latest <input size="4" type="text" name="days" value="'.$days.'"> days <input type="submit" value="Show"></form>'."\n";
|
|
return $timeline;
|
|
|
|
}
|
|
?>
|