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 = <<