div.container { position: relative; } div.station { overlap: hidden; font-size: ".$font_size."em; font-family: Times New Roman; position: absolute; text-align: center; padding: ".$padding."px; border: ".$border."px solid #000000; height: ".$height."px; width: ".$station_width."px; left: 0px; background-color: #eee; } div.program { overflow: hidden; position: absolute; text-align: left; padding: ".$padding."px; border: ".$border."px solid #151500; height: ".$height."px; } div.wrapper { overflow: visible; position: absolute; height: ".$height."px; padding: 0px; margin: 0px; } div.time { font-size: ".$font_size."em; font-family: Arial; position: absolute; text-align: left; padding: ".$padding."px; border: ".$border."px solid #333; border-left-color: #aaa; height: ".$time_height."px; width: ".$time_width."px; color: #aaa; background-color: #333; } div.over { display: none; position: absolute; width: 250px; margin: 0px; padding: 3px; left: -1px; top: -1px; border: 2px solid #222; background-color: #eee; }\n"; if ($ie) { echo "div.hover { z-index: 1; } div.hover div { display: block; z-index: 1; } \n\n"; } else { echo "div div:hover div { display: block; z-index: 1; } \n\n"; } } function draw_timebar($stime, $etime, $offset, $height, $y_coord, $seconds_per_pixel) { $h = date('g', $stime); $m = date('i', $stime); # assumes stime and etime are at 30-minute intervals $ap = date('A', $stime); $end_h = date('g', $etime); $end_m = date('i', $etime); $end_ap = date('A', $etime); $x_coord = floor(($stime - $offset) / $seconds_per_pixel); $step = floor(1800 / $seconds_per_pixel); echo "
 
"; while ($h != $end_h || $m != $end_m || $ap != $end_ap) { echo "
$h:".(($m == 0) ? '00' : $m)." $ap
"; $m += 30; if ($m == 60) { $m = 0; ++$h; } if ($h == 12 && $m == 0) $ap = ($ap == 'AM') ? 'PM' : 'AM'; if ($h == 13) $h = 1; $x_coord += $step; } echo "\n"; } function print_show($p, $x, $y, $width, $color) { echo "
\n\t" ."
{$p->title}"; if ($p->subtitle) { echo ": {$p->subtitle}"; } echo "
\n\t
".$p->title.''; if ($p->subtitle) { echo ": {$p->subtitle}"; } echo '
'; if ($p->description) echo $p->description.'
'; echo date('g:i A', do_dst($p->stime)).' - '. date('g:i A', do_dst($p->etime))."
\n
"; } function print_ie_show($p, $x, $y, $width, $color) { echo "
\n\t
". $p->title." {$p->subtitle}
\n\t
".$p->title.'
'; if ($p->description) echo $p->description.'
'; echo date('g:i A', do_dst($p->stime)).' - '. date('g:i A', do_dst($p->etime))."
\n
"; } function do_dst($time) { return $time + 3600 * (intval(date('I', $time) - 1)); } function undo_dst($time) { return $time - 3600 * (intval(date('I', $time) - 1)); } # Prints the full lineup from $stime to $etime. (Use mktime() for the times.) $ie is a bool flag; if true, it'll output for Internet Explorer. function print_lineup($stime, $etime, $seconds_per_pixel, $station_width, $border, $padding, $height, $timebar_height, $ie) { $sdst = undo_dst($stime); $edst = undo_dst($etime); # mysql_select_db('tv') or die(mysql_error()); echo "
\n"; # precalculations $cell_buffer = $border + 2*$padding; // $lineup_start is used to move the programs to the lineup's left corner. // This line moves it to the right, making room for the station list. $lineup_start = $stime - $seconds_per_pixel * $station_width; # echo "\n"; // Channel setup/output $top = 0; $sql = "SELECT id, affiliate, callSign, channel, name FROM stations ORDER BY channel"; $query = mysql_query($sql) or die(mysql_error()); $num_rows = mysql_num_rows($query); for($i = 0; $i < $num_rows; $i++) { if ($i % 8 == 0) { draw_timebar($stime, $etime, $lineup_start, $timebar_height, $top, $seconds_per_pixel); $top += $timebar_height; } $channel = mysql_fetch_object($query); $channels[$channel->id] = array('top' => $top + 'px', 'color' => (($i % 2 == 0) ? '#fff' : '#eee')); #array('callSign' => $channel->callSign, 'channel' => $channel->channel, 'name' => $channel->name, 'top' => $top + 'px'); if ($channel->channel > "10" ) echo "
".$channel->callSign.'
'.$channel->channel."
\n"; else { $affiliate = trim(str_replace("Affiliate", "", $channel->affiliate)); echo "
".$affiliate."
" . $channel->channel ."
\n"; } $top += $height; } // Show output $sql = "SELECT title, subtitle, description, stime, etime, station FROM programs WHERE (etime > '$sdst' AND stime < '$edst')"; $query = mysql_query($sql) or die(mysql_error()); for ($j = mysql_num_rows($query); $j > 0; $j--) { $p = mysql_fetch_object($query); $start = do_dst($p->stime); $start = (($start > $stime) ? $start : $stime); $end = do_dst($p->etime); $t = floor(( (($end < $etime) ? $end : $etime) - $start) / $seconds_per_pixel) + 'px'; $start = floor(($start - $lineup_start) / $seconds_per_pixel) + 'px'; $top = $channels[$p->station]['top']; $color = $channels[$p->station]['color']; if ($ie) print_ie_show($p, $start + 'px', $top + 'px', $t + 1, $color); else print_show($p, $start + 'px', $top + 'px', $t - $cell_buffer, $color); ob_flush(); flush(); } echo "
\n"; } ?>