= DATE(NOW())) AND (exclude_from_main=0) ORDER BY showDate LIMIT 4"; $res = $gDB->query($sql); $shows = array(); $dates = array(); while ($row = $gDB->fetchObject($res)) { # For this date, get all shows. $show_sql = "SELECT id,artistName,showDate,showTime,audio from rb12Schedule WHERE (showDate='{$row->{'showDate'}}') AND (exclude_from_main=0)"; $show_res = $gDB->query($show_sql); $data = array(); while ($show_row = $gDB->fetchObject($show_res)) { $audio = preg_replace('/width="?\d+"? /', 'width="215" ', $show_row->{'audio'}); $audio = preg_replace('/height="?\d+"? /', 'height="230" ', $audio); $show_row->{'audio'} = $audio; $data[] = $show_row; } uasort($data, 'byTime'); $shows[ $row->{'showDate'} ] = $data; $dates[] = $row->{'showDate'}; } ###### # Main feature if the first date ###### $dir = "/www1/htdocs/ijazz/getshowtix/regattabar/inc/schedule/bio/artists"; $featured = $shows[$dates[0]][0]; if (file_exists("$dir/{$featured->id}.jpg")) { $featured->{artistImage} = "{$featured->id}.jpg"; } if (file_exists("$dir/{$featured->id}.png")) { $featured->{artistImage} = "{$featured->id}.png"; } $gSmarty->assign("featured", $featured); $gSmarty->assign("featured_shows", $shows[$dates[0]]); ###### # The next three dates ###### $upcoming = array(); for ($i=1; $i<=3; $i++) { $audio = preg_replace('/width="?\d+"? /', 'width="140" ', $shows[$dates[$i]][0]->audio); $audio = preg_replace('/height="?\d+"? /', 'height="250" ', $audio); $artistImage = ""; $id = $shows[$dates[$i]][0]->id; if (file_exists("$dir/{$id}.jpg")) { $artistImage = "{$id}.jpg"; } if (file_exists("$dir/{$id}.png")) { $artistImage = "{$id}.png"; } $upcoming[] = array( 'id' => $shows[$dates[$i]][0]->id, 'showDate' => $shows[$dates[$i]][0]->showDate, 'artistName' => $shows[$dates[$i]][0]->artistName, 'artistImage' => $artistImage, 'audio' => $audio, 'shows' => $shows[$dates[$i]] ); } $gSmarty->assign('upcoming', $upcoming); $gSmarty->display("iframe.tpl"); exit; ###################################################################### ###################################################################### # byTime($a, $b) # A user-callback sort comparison function expecting the values of # show rows/objects to sort by time (noting am/pm). # function byTime($a, $b) { $showtime_a = $a->{showTime}; $showtime_b = $b->{showTime}; $timea = 0; $timeb = 0; if (preg_match("/(\d+)(:(\d+))?\s*(AM|PM)?/i", $showtime_a, $m)) { $hra = $m[1]; $mna = $m[3]; $ta = strtoupper($m[4]); # Assume PM if ($ta == "") { $ta = "PM"; } # Go military time on hours if (($ta == "PM") && ($hra < 12)) { $hra += 12; } # For AM shows, put them *after* PM shows, these are early morning shows if (($ta == "AM") && (($hra < 8) || ($hra == 12))) { $hra += 24; } # Calculate a decimal time to use in sort comparison $timea = $hra + $mna / 60; } if (preg_match("/(\d+)(:(\d+))?\s*(AM|PM)?/i", $showtime_b, $m)) { $hrb = $m[1]; $mnb = $m[3]; $tb = strtoupper($m[4]); # Assume PM if ($tb == "") { $tb = "PM"; } # Go militbry time on hours if (($tb == "PM") && ($hrb < 12)) { $hrb += 12; } # For AM shows, put them *after* PM shows, these are early morning shows if (($tb == "AM") && (($hrb < 8) || ($hrb == 12))) { $hrb += 24; } # Calculate a decimal time to use in sort comparison $timeb = $hrb + $mnb / 60; } if ($timea == $timeb) { return 0; } return ($timea < $timeb) ? -1 : 1; } ###################################################################### ?>