require_once("inc/func.php");
start();
tprint_begin("Kirpputori");
$textq = q("SELECT * FROM flea_texts");
while ($text = assoc($textq)) {
$texts[$text['key']] = $text['text'];
}
tprint("story", array($texts['header'], nl2br($texts['text'])));
$time = time();
$where = "";
if (!$LOGGED_IN)
$where = " WHERE booking_open_time < $time AND booking_close_time > $time";
$flea_q = q("SELECT * FROM flea_fleas$where ORDER BY time ASC");
if (rows())
while ($flea = assoc($flea_q))
{
$open = ($flea['booking_open_time'] < $time && $flea['booking_close_time'] > $time);
if ($LOGGED_IN && $open)
$color = "#007c16";
else if ($LOGGED_IN && !$open)
$color = "#8e231d";
else
$color = "#007c16";
tprint("flea", "".str_date($flea['time'])."");
}
else
print "Ei kirpputoreja";
$fleaq = q("SELECT * FROM flea_fleas WHERE booking_open_time > $time ORDER BY time ASC LIMIT 3");
if (rows() && !$LOGGED_IN)
{
tprint("fleas_future");
while ($flea = assoc($fleaq))
tprint("flea", str_date($flea['time'])."
(Avautuu ".date("j.n.Y", $flea['booking_open_time']).")");
}
tprint("fleas_end");
tprint_end();
?>