= 0) { $timezone = "+" . $timezone; } $timezone .= ":00"; } $is_orienteering = 0; $event_id; $event_q = mysql_query("SELECT EventType, UUID FROM tractrac.Events WHERE `Database` = '$database'") or die (mysql_error()); while ($event = mysql_fetch_assoc($event_q)) { $event_id = $event["UUID"]; if ($event["EventType"] == 'ef1a1876-60e1-102f-8f95-406186cbf87c') { $is_orienteering = 1; } } $mq = mysql_query("SELECT CONVERT_TZ(StartTime,'+0:00','$timezone') AS StartTime, Name, UUID, OnlineStatus,initialized, EndTime, StartTime AS StartTime2 FROM Races WHERE NOT OnlineStatus = 'HIDDEN' ORDER BY StartTime2 DESC,Name"); $date = ""; $todayEvents = ""; $previousEvents = ""; $futureEvents = ""; while ($race = mysql_fetch_assoc($mq)) { $currentEvent = ""; $date_arr = split(" ", $race["StartTime"]); $end_time = $race["EndTime"]; $start_time = $race["StartTime2"]; $initialized=$race["initialized"]; $newDate = join("-",array_reverse(split("-",$date_arr[0]))); if ($date != $newDate) { $date = $newDate; $currentEvent .= "
".$date."
"; } $currentEvent .= mb_convert_encoding($race["Name"], "UTF-8", "ISO-8859-15"); $now = date('Y-m-d H:i:s'); if ($race["OnlineStatus"] != "OFFLINE") { if ($now<$start_time) { // coming up $currentEvent .= " - Coming up "; // $currentEvent .= ""; $currentEvent .= ""; } if ($now>$start_time && $now<$end_time && $initialized!="0") { // live $currentEvent .= " - "; $currentEvent .= ""; $currentEvent .= ""; } if ($now>$end_time && $initialized!="0") { //Replay $currentEvent .= " - "; $currentEvent .= ""; $currentEvent .= ""; if ($is_orienteering == 1) { $currentEvent .= " - "; $currentEvent .= ""; $currentEvent .= ""; } } } $currentEvent .= "
"; $today = date("Y-m-d"); $now = date("H-i:s"); $pieces = explode("-", $date); $comparableDate = $pieces[2]."-".$pieces[1]."-".$pieces[0]; if ($today == $comparableDate) { $todayEvents .= $currentEvent; } else if ($today > $comparableDate) { $previousEvents .= $currentEvent; } else { $futureEvents .= $currentEvent; } } if ($todayEvents != "") { echo "

Today's races:

"; echo $todayEvents; echo "
"; } if ($previousEvents != "") { echo "

Previous races:

"; echo $previousEvents; echo "
"; } if ($futureEvents != "") { echo "

Future races:

"; echo $futureEvents; } ?>