Okay, I updated the schedule. Click here to see the schedule as normal users now see it.

EOT; } // if they're looking at it in test mode after updating the schedule } // if they need to be logged in if( !isset($_REQUEST['from_day']) ) { $_REQUEST['from_day'] = 0; $_REQUEST['to_day'] = 2; } // if they didn't say what they want // We have DJ's names. We need their database entries. So we should look them // up, and add them if we need to. $DJ = array(); $query = "SELECT DJID, DJName FROM DJ"; $res = mysql_query($query) or die(mysql_error()." -- ".$query); while( $row = mysql_fetch_array($res, MYSQL_ASSOC) ) { $DJ[$row['DJName']] = $row['DJID']; } // while thar be dj's foreach( $_REQUEST as $key => $val ) { if( strstr($key, "dj:") == $key ) { list($throwaway, $show_id) = explode(":", $key); $djid = $DJ[stripslashes($val)]; if( ! $djid ) { $query = "INSERT INTO DJ SET DJName='".stripslashes($val)."'"; $res = mysql_query($query) or die(mysql_error()." -- ".$query); $djid = mysql_insert_id(); } // if there is no such DJ $_REQUEST["db:schedule:{$show_id}:djid"] = $djid; } // if it starts with dj: } // foreach request var $responder = new DB_Responder($conn); $responder->respond(); // ----------------------------------------------- $GLOBALS['semester_id'] = 'xxx'; $GLOBALS['semester_name'] = ''; $GLOBALS['num_to_day'] = array( 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ); $GLOBALS['day_to_num'] = array( 'Monday' => 0, 'Tuesday' => 1, 'Wednesday' => 2, 'Thursday' => 3, 'Friday' => 4, 'Saturday' => 5, 'Sunday' => 6 ); function the_day_after($day) { $num = $GLOBALS['day_to_num'][$day]; $num = ($num+1) % 7; $ret_day = $GLOBALS['num_to_day'][$num]; return $ret_day; } // function the_day_after function the_day_before($day) { $num = $GLOBALS['day_to_num'][$day]; $num = ($num-1) % 7; $ret_day = $GLOBALS['num_to_day'][$num]; return $ret_day; } // function the_day_after // Gather the day-ta // (first, figure out what semester it is) // If we're supposed to look at the test semester, then that is what we shall // do. if( $_REQUEST['test'] == 'yes' && !$_REQUEST['semester_to_live'] ) { $query = "SELECT id, name FROM semester WHERE name='seTESTer'"; } else if( $_REQUEST['test'] == 'yes' && $_REQUEST['semester_to_live'] ) { $query = "SELECT id, name FROM semester WHERE id='{$_REQUEST['semester_to_live']}'"; } else { $query = "SELECT id, name FROM semester ORDER BY start DESC LIMIT 1"; } // if this is a test $res = mysql_query($query) or die(mysql_error()." -- ".$query); $row = mysql_fetch_array($res, MYSQL_ASSOC); $GLOBALS['semester_id'] = $row['id']; $GLOBALS['semester_name'] = $row['name']; $from_day = $_REQUEST['from_day']; $to_day = $_REQUEST['to_day'] + 1; // We have to organize it by when the show starts, so we know how to draw the // table rows $query = "SELECT H.id, H.showname, H.url, H.djid, D.DJName, H.startday, H.starttime, H.stoptime, (H.startday+5)%7 AS pseudo_day_num, IF( H.starttime < '06:00:00', 60*60*24*( (( (H.startday+5)%7 )+6)%7 )+ TIME_TO_SEC(H.starttime), 60*60*24*((H.startday+5)%7)+TIME_TO_SEC(H.starttime) ) AS secs_in_wk FROM schedule H, DJ D WHERE semester='{$GLOBALS['semester_id']}' AND D.DJID=H.djid HAVING secs_in_wk >= 60*60*24*{$from_day} AND secs_in_wk < 60*60*24*{$to_day} ORDER BY starttime, secs_in_wk"; $res = mysql_query($query) or die(mysql_error()." -- ".$query); $x = 0; while( $row = mysql_fetch_array($res, MYSQL_ASSOC) ) { $x++; $row['SHOWNAME'] = strtoupper($row['showname']); if( $row['url'] ) { $row['SHOWNAME'] = "{$row['SHOWNAME']}"; } // if the show has a url $key = sprintf( "{$row['starttime']} %07d {$x}", $row['secs_in_wk'] ); $firstdraft[$key] = $row; if( $row['stoptime']<$row['starttime'] && $row['stoptime']>'06:00:00' ) { $last = count($schedule[$row['starttime']]) - 1; $key = sprintf( "{$row['starttime']} %07d {$x}", $row['secs_in_wk'] ); $firstdraft[$key]['stoptime'] = '06:00:00'; $x++; $row['SHOWNAME'] .= " (cont.)"; $row['starttime'] = '06:00:00'; $key = sprintf( "{$row['starttime']} %07d {$x}", $row['secs_in_wk'] ); $firstdraft[$key] = $row; } // if the show crosses a 6am } // while thar be rows ksort($firstdraft); foreach( $firstdraft as $puppy ) { $schedule[$puppy['starttime']][] = $puppy; } // foreach of the shows, sorted by starttime then startday if( $_REQUEST['test'] == 'yes' ) { $query = "SELECT id, name, start, stop FROM semester ORDER BY id DESC"; $res = mysql_query($query) or die(mysql_error()." -- ".$query); while( $row = mysql_fetch_array($res, MYSQL_ASSOC) ) { $semesters[] = $row; } // while thar be rows } // if this is the test semester mysql_close($conn); // readfile('schedule-head.html'); $word_list = array(); for( $i=$_REQUEST['from_day']; $i<=$_REQUEST['to_day']; $i++ ) { $word_list[] = $GLOBALS['num_to_day'][$i]; } // for all the days $thisdays = word_list($word_list); $daylinks = "[ "; foreach( array( array(0, 2), array(3, 4), array(5, 6) ) as $fromto ) { if( $fromto[0] == $_REQUEST['from_day'] && $fromto[1] == $_REQUEST['to_day'] ) { // ignore it } else { $word_list = array(); for( $i=$fromto[0]; $i<=$fromto[1]; $i++ ) { $word_list[] = $GLOBALS['num_to_day'][$i]; } // for all the days $thesedays = word_list($word_list); if( $_REQUEST['test'] == 'yes' ) { $testpart = "&test=yes"; } // if this is the tester else { $testpart = ""; } // if this is not the tester if( $_REQUEST['semester_to_live'] ) { $semesterpart = "&semester_to_live={$_REQUEST['semester_to_live']}"; } // if this is the tester else { $semesterpart = ""; } // if this is not the tester $daylinks .= "{$thesedays} / "; } // if we should put this link in the list } // foreach fromto $daylinks = rtrim($daylinks, " /"); $daylinks .= " ]"; $testtext = ""; if( $_REQUEST['test'] == 'yes' ) { $testtext = << This is not the current schedule. This is the one that you're trying out. I got it from iCal or whatever. If the schedule that appears here is the one that you want to be the current schedule, then click the "UPDATE THIS SCHEDULE" button. I put that button at the BOTTOM of this page, so that I know that you MEAN it when you push the button.

EOT; } // if it's the test semester $colspan = $to_day - $from_day + 2; echo << WCBN Daily Schedule for {$thisdays}
{$daylinks}
{$testtext} EOT; for( $whichday=$from_day; $whichday < $to_day; $whichday++ ) { $whichdaystring = strtoupper($GLOBALS['num_to_day'][$whichday]); echo "{$whichdaystring}\n"; } // for the days echo "\n\n"; $all_starting_times = array_keys($schedule); // Find the min // sort($all_starting_times); $min = "99:99:99"; foreach( $all_starting_times as $startingtime ) { if( $startingtime < $min && $startingtime >= '06:00:00' ) { $min = $startingtime; } // if this is the new min } // foreach starting time while( $all_starting_times[0] != $min && $min != '99:99:99' ) { $time = $all_starting_times[0]; array_shift($all_starting_times); $all_starting_times[] = $time; } // while the schedule doesn't start at 6. $juststarting = true; for( $hr=6; $hr!=6 || $juststarting; $hr=($hr+1)%24 ) { if( $juststarting ) { $juststarting = false; } foreach( array('00', '15', '30', '45') as $min ) { $time_in_question = sprintf("%02d:%02d:00", $hr, $min); if( !is_array($schedule[$time_in_question]) || count($schedule[$time_in_question]) == 0 ) { continue; } $readable_time_arr = explode(":", $time_in_question); $r_hr = ltrim($readable_time_arr[0], "0"); if( $r_hr > 12 ) { $r_hr -= 12; $r_ampm = 'PM'; } else if( $r_hr < 12 ) { $r_ampm = 'AM'; } else { $r_ampm = 'PM'; } if( $r_hr == 0 ) { $r_hr += 12; } if( $readable_time_arr[1] != '00' ) { $readable_time = "{$r_hr}:{$readable_time_arr[1]} {$r_ampm}"; } else { $readable_time = "{$r_hr} {$r_ampm}"; } // if it's the hour echo "\n"; echo "{$readable_time}\n"; foreach( $schedule[$time_in_question] as $show ) { // How many shows start between my start time and my end time? $start_index = array_search($show['starttime'], $all_starting_times); $stop_index = array_search($show['stoptime'], array_slice($all_starting_times, $start_index+1) ); if( !is_numeric($stop_index) ) { $stop_index = count($all_starting_times); } // if we didn't find a stop index else { $stop_index += $start_index + 1; } // else we did find a stop index $rowspan = $stop_index - $start_index; if( $rowspan < 1 ) { $rowspan = 1; } if( isset($show['DJName']) && $show['DJName'] != NULL && $show['DJName'] != "" ) { $show['DJName'] = htmlspecialchars($show['DJName']); $djname = "
with {$show['DJName']} "; } // if djname else { $djname = ""; } // if no djname echo "\n"; echo "{$show['SHOWNAME']}"; echo "{$djname}\n"; echo "\n"; } // foreach show echo "\n"; } // foreach possible minute } // for each hour if( $_REQUEST['test'] == 'yes' ) { $colspan = $_REQUEST['to_day'] - $_REQUEST['from_day'] + 2; echo << If the schedule looks like it should look for this semester, then you can make it go live starting NOW. That will put the schedule up for ordinary folk to see. Do this if you're sure the schedule is ready.

What is the name of this semester? (e.g. "Fall 2004", "Spring 2005", etc.)

And, uh, hey... if you make a mistake, and want to put up the schedule for a different semseter? Change this thingey here. If you leave it as it is (it should say 'seTESTer', then it will take the schedule that you see, and make it go live. If you change it to a different semester, it will make that semester go live.

Which semester do you want to go live?