<?php
require('include.php');
require('admin.php');
switch($cmd) {
case "namechange":
print "<html><head><meta http-equiv=\"refresh\" content=\"0; url=indivplaylist.php?edit=$hschdnum\">";
print "</head><body></body></html>";
mysql_query("Update HourScheduleNames set name='$playlistname' where hsid='$hschdnum'");
print mysql_error();
break;
case "addend":
$result = mysql_query("Select slot from HourSchedule where hsid = '$hschdnum' order by slot desc limit 1");
$maxslot = mysql_fetch_row($result);
$maxslot = $maxslot[0];
$maxslot++;
print "<html><head></head><body bgcolor=#DODCE0>";
print "<center>" . geektime() . "</center><br>";
$result = mysql_query("Select name from HourScheduleNames where hsid='$hschdnum'");
$result = mysql_fetch_row($result);
$playlistname = $result[0];
print "<center><font size=+2><b>Add Item to End of Playlist #$hschdnum - \"$playlistname\"</b></font></center><br>";
print "<form method=post action=indivplaylistcmd.php>";
print "<input type=hidden name=cmd value=addend>";
print "<input type=hidden name=hschdnum value=$hschdnum>";
print "<u><font size=+2>Properties of Item to Add</font></u><br><br>";
print "<table cellspacing=2 cellpadding=2 width=100%>";
print "<tr><td><b>Position</b></td><td>$maxslot<input type=hidden name=slot value=$maxslot></td></tr>";
print "<tr><td><b><input type=radio name=itemtype value=cid checked>Content Item</b></td><td><select name=cid>";
$cidresult = mysql_query("Select cid, title, creator from Content order by cid");
while($thisrow = mysql_fetch_array($cidresult)) {
$thiscid = $thisrow['cid'];
$thistitle = $thisrow['title'];
$thiscreator = $thisrow['creator'];
print "<option value=$thiscid>$thiscid - $thistitle by $thiscreator</option>";
}
print "</select>";
print "</td></tr>";
$ridresult = mysql_query("Select rid, name from RandomNames order by rid");
if (mysql_num_rows($ridresult) != 0) {
print "<tr><td><b><input type=radio name=itemtype value=rid>Randomizer</b></td><td><select name=rid>";
while($thisrow = mysql_fetch_array($ridresult)) {
$thisrid = $thisrow['rid'];
$thisname = $thisrow['name'];
print "<option value=$thisrid>$thisrid - $thisname</option>";
}
print "</select></td></tr>";
}
print "<tr><td><br></td></tr>";
print "<input type=submit value=\"Add Item\"></form>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
print "</table></body></html>";
break;
case "addbefore":
$nums = checkedcids($HTTP_POST_VARS);
if (count($nums) == 1) {
$itemnum = $nums[0];
print "<html><head></head><body bgcolor=#DODCE0>";
print "<center>" . geektime() . "</center><br>";
$result = mysql_query("Select name from HourScheduleNames where hsid='$hschdnum'");
$result = mysql_fetch_row($result);
$playlistname = $result[0];
print "<center><font size=+2><b>Add Item to Playlist #$hschdnum - \"$playlistname\"</b></font></center><br>";
print "<form method=post action=indivplaylistcmd.php>";
print "<input type=hidden name=cmd value=addbefore>";
print "<input type=hidden name=hschdnum value=$hschdnum>";
print "<u><font size=+2>Properties of Item to Add</font></u><br><br>";
print "<table cellspacing=2 cellpadding=2 width=100%>";
print "<tr><td><b>Position</b></td><td>$itemnum<input type=hidden name=slot value=$itemnum></td></tr>";
print "<tr><td><b><input type=radio name=itemtype value=cid checked>Content Item</b></td><td><select name=cid>";
$cidresult = mysql_query("Select cid, title, creator from Content order by cid");
while($thisrow = mysql_fetch_array($cidresult)) {
$thiscid = $thisrow['cid'];
$thistitle = $thisrow['title'];
$thiscreator = $thisrow['creator'];
print "<option value=$thiscid>$thiscid - $thistitle by $thiscreator</option>";
}
print "</select>";
print "</td></tr>";
$ridresult = mysql_query("Select rid, name from RandomNames order by rid");
if (mysql_num_rows($ridresult) != 0) {
print "<tr><td><b><input type=radio name=itemtype value=rid>Randomizer</b></td><td><select name=rid>";
while($thisrow = mysql_fetch_array($ridresult)) {
$thisrid = $thisrow['rid'];
$thisname = $thisrow['name'];
print "<option value=$thisrid>$thisrid - $thisname</option>";
}
print "</select></td></tr>";
}
print "<tr><td><br></td></tr>";
print "<input type=submit value=\"Add Item\"></form>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
print "</table></body></html>";
} else {
print "<html><head></head><body bgcolor=#DODCE0>";
print "You must select exactly one playlist item that the new playlist item will replace!";
print "</body></html>";
}
break;
case "edit":
$result = mysql_query("Select name from HourScheduleNames where hsid='$hschdnum'");
$result = mysql_fetch_row($result);
$playlistname = $result[0];
print "<html><head></head><body bgcolor=#DODCE0>";
print "<center>" . geektime() . "</center><br>";
print "<center><font size=+2><b>Edit Playlist Item(s) in Playlist #$hschdnum - \"$playlistname\"</b></font></center><br>";
print "<form method=post action=indivplaylistcmd.php>";
print "<input type=hidden name=cmd value=edit>";
print "<input type=hidden name=hschdnum value=$hschdnum>";
print "<u><font size=+2>Playlist Item(s) to Edit</font></u><br><br>";
$filterarray = checkedcids($HTTP_POST_VARS);
if ($filterarray != "") {
print fetchtable("indivplaylist",$hschdnum,1,$filterarray);
print "<br><u><font size=+2>Set Selected Playlist Item(s) To</font></u><br><br>";
print "<table cellspacing=2 cellpadding=2 width=100%>";
print "<tr><td><b><input type=radio name=itemtype value=cid checked>Content Item</b></td><td><select name=cid>";
$cidresult = mysql_query("Select cid, title, creator from Content order by cid");
while($thisrow = mysql_fetch_array($cidresult)) {
$thiscid = $thisrow['cid'];
$thistitle = $thisrow['title'];
$thiscreator = $thisrow['creator'];
print "<option value=$thiscid>$thiscid - $thistitle by $thiscreator</option>";
}
print "</select>";
print "</td></tr>";
$ridresult = mysql_query("Select rid, name from RandomNames order by rid");
if (mysql_num_rows($ridresult) != 0) {
print "<tr><td><b><input type=radio name=itemtype value=rid>Randomizer</b></td><td><select name=rid>";
while($thisrow = mysql_fetch_array($ridresult)) {
$thisrid = $thisrow['rid'];
$thisname = $thisrow['name'];
print "<option value=$thisrid>$thisrid - $thisname</option>";
}
print "</select></td></tr>";
}
print "<tr><td><br></td></tr>";
print "<input type=submit value=\"Update Selected Item(s)\"></form>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
print "</table></body></html>";
} else {
print "No items selected to edit!<br><br>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
}
break;
case "delete":
print "<html><head></head><body bgcolor=#DODCE0>";
print "<center>" . geektime() . "</center><br>";
print "<center><font size=+2><b>Delete Playlist Items</b></font></center><br>";
print "<form method=post action=indivplaylistcmd.php>";
print "<input type=hidden name=cmd value=delete>";
print "<input type=hidden name=hschdnum value=$hschdnum>";
print "<u><font size=+2>Playlist Item(s) to Delete</font></u><br><br>";
$filterarray = checkedcids($HTTP_POST_VARS);
if ($filterarray != "") {
print fetchtable("indivplaylist",$hschdnum,1,$filterarray);
print "<br><u><font size=+2>Confirmation to Delete Playlist Item(s)</font></u><br><br>";
print "<input type=submit value=\"Delete Selected Playlist Item(s)\"></form>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
print "</body></html>";
} else {
print "No playlists selected to delete!<br><br>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
}
break;
case "switch":
print "<html><head></head><body bgcolor=#DODCE0>";
print "<center>" . geektime() . "</center><br>";
print "<center><font size=+2><b>Switch Playlist Items</b></font></center><br>";
print "<form method=post action=indivplaylistcmd.php>";
print "<input type=hidden name=cmd value=switch>";
print "<input type=hidden name=hschdnum value=$hschdnum>";
print "<u><font size=+2>Playlist Items to Switch</font></u><br><br>";
$filterarray = checkedcids($HTTP_POST_VARS);
if (count($filterarray) == 2) {
print fetchtable("indivplaylist",$hschdnum,1,$filterarray);
print "<br><u><font size=+2>Confirmation to Switch Playlist Items</font></u><br><br>";
print "<input type=submit value=\"Switch Playlist Items\"></form>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
print "</body></html>";
} else {
print "Exactly two items must be selected for a switch!<br><br>";
print "<form method=post action=indivplaylist.php?edit=$hschdnum><input type=submit value=Cancel></form>";
}
break;
case "headerchange":
print "<html><head></head><body bgcolor=#D0DCE0>";
print "<center>" . geektime() . "</center><br>";
print "<center><font size=+2><b>Change Playlist Header</b></font></center><br>";
print "<form method=post action=indivplaylistcmd.php>";
print "<input type=hidden name=cmd value=headerchange>";
print "<input type=hidden name=hschdnum value=$hschdnum>";
print "<u><font size=+2>Header Selection</font></u><br><br>";
print "<table width=100% cellborder=2 cellpadding=2>";
print "<tr><td><input type=radio name=newheadertype value=nothing checked><b>No Header</b></td></tr>";
print "<tr><td><input type=radio name=newheadertype value=cid><b>Content Item</b></td>";
print "<select name=cid>";
$cidresult = mysql_query("Select cid, title, creator from Content order by cid");
while($thisrow = mysql_fetch_array($cidresult)) {
$thiscid = $thisrow['cid'];
$thistitle = $thisrow['title'];
$thiscreator = $thisrow['creator'];
print "<option value=$thiscid>$thiscid - $thistitle by $thiscreator</option>";
}
print "</select>";
print "</td></tr>";
$ridresult = mysql_query("Select rid, name from RandomNames order by rid");
if (mysql_num_rows($ridresult) != 0) {
print "<tr><td><b><input type=radio name=newheadertype value=rid>Randomizer</b></td><td><select name=rid>";
while($thisrow = mysql_fetch_array($ridresult)) {
$thisrid = $thisrow['rid'];
$thisname = $thisrow['name'];
print "<option value=$thisrid>$thisrid - $thisname</option>";
}
print "</select></td></tr>";
}
print "<tr><td><br></td></tr><input type=submit value=\"Set Header\"></form>";
print "<form method=post action=\"indivplaylist.php?edit=$hschdnum\"><input type=submit value=Cancel></td></tr></form>";
print "</table></body></html>";
break;
default:
print "<html><head>";
print "<meta http-equiv=\"refresh\" content=\"0; url=playlists.php\">";
print "</head><body></body></html>";
break;
}
?>