blob: 2499ecf80c8acaec63043af9a34418c8c72c995c (
plain)
1 <?php
2 // Useless comment
3 require_once('DB.php');
4 Markup("timeline", "directives", "/\\(:timeline(\\s+.*)?\\s*:\\)/e",
5 "'<:block>'.GetEvents()");
6
7 function GetEvents() {
8
9 $days = 14;
10 if (isset($_POST['days'])) {
11 $days = intval($_POST['days']);
12 }
13
14 $dsn = 'sqlite:////home/crux/public_html/local/timeline.db';
15 $db =& DB::connect($dsn);
16 if (DB::isError($db)) die("Cannot connect to database");
17 $db->setFetchMode(DB_FETCHMODE_ASSOC);
18 $from = time() - ($days * 24 * 60 * 60);
19 $sql = "select distinct event_date, event_description, event_notes, event_type, event_time from events where event_tstamp >= $from order by event_tstamp desc";
20 $res =& $db->Query($sql);
21 if (DB::isError($res)) die("Query error");
22
23 $timeline .= '<table cellspacing="0" border="0" cellpadding="0">'."\n";
24 $currdate = "noway";
25 while ($evt =& $res->fetchRow()) {
26 if ($evt['event_date'] != $currdate) {
27 $timeline .= '<tr><td class="timeline-head" colspan="3"><span class="timeline-date">'.$evt['event_date']."</span></td></tr>\n";
28 }
29 $event_description = $evt['event_description'];
30 if ($evt['event_notes'] != "") {
31 $event_description .= ": ".$evt['event_notes'];
32 }
33 $img = '<img src="/images/'.$evt['event_type'].'.png">';
34 $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>';
35 $timeline .= "\n";
36 $currdate = $evt['event_date'];
37 }
38 $timeline .= "</table>\n";
39 $timeline .= '<br><form method="post" action="pmwiki.php?n=Main.Timeline">Show the latest <input size="4" type="text" name="days" value="'.$days.'"> days <input type="submit" value="Show"></form>'."\n";
40 return $timeline;
41
42 }
43 ?>
|