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

Generated by cgit