963 lines
31 KiB
PHP
Executable File
963 lines
31 KiB
PHP
Executable File
<?php
|
|
|
|
$admin_digest = $_COOKIE['bobsleddigest'];
|
|
$digest = "b8939260fa537f7c975aaad60c951aaf5bbb7a9f";
|
|
$phrase = file_get_contents('../../../data/bobsledphrase.txt');
|
|
|
|
if( $admin_digest == "" or ($_POST['user'] and $_POST['password']) )
|
|
{
|
|
$admin_digest = sha1("{$_POST['user']}^{$_POST['password']}^$phrase");
|
|
setcookie('bobsleddigest',$admin_digest,time() + (30*60),'/bobsled/admin','192.168.0.105');
|
|
}
|
|
|
|
include "../header.php";
|
|
|
|
if( $admin_digest == $digest )
|
|
{
|
|
if( $_POST['cmd'] == 'add_picture' )
|
|
{ print "<div class='alert'>" . AddPicture() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'add_disc' )
|
|
{ print "<div class='alert'>" . AddDisc() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'add_event' )
|
|
{ print "<div class='alert'>" . AddEvent() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'add_team' )
|
|
{ print "<div class='alert'>" . AddTeam() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'delete_team' )
|
|
{ print "<div class='alert'>" . DeleteTeam() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'delete_disc' )
|
|
{ print "<div class='alert'>" . DeleteDisc() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'delete_event' )
|
|
{ print "<div class='alert'>" . DeleteEvent() . "</div>"; }
|
|
|
|
else if( $_POST['cmd'] == 'delete_picture' )
|
|
{ print "<div class='alert'>" . DeletePicture() . "</div>"; }
|
|
|
|
PrintAdminIndex();
|
|
}
|
|
else { PrintLoginPage(); }
|
|
|
|
include "../footer.php";
|
|
|
|
//=================================================
|
|
// PAGE FUNCTIONS
|
|
//=================================================
|
|
|
|
//=======================================
|
|
// Adds a team folder
|
|
//=======================================
|
|
function AddTeam()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
if( file_exists("../pictures/$team/") ) //make sure this team doesn't already exist
|
|
{
|
|
$message = "> $team already exists!";
|
|
|
|
print `rm "../pictures/$team/icon.jpg"`; //remove old icon, replace with new one
|
|
if( move_uploaded_file($_FILES['icon']['tmp_name'],"../pictures/$team/icon.jpg") )
|
|
{ $message .= "<br />> Updated image for $team."; }
|
|
else { $message .= "<br />> Could not update image for $team, please try again."; }
|
|
}
|
|
else //if the team does not already exist
|
|
{
|
|
print `mkdir "../pictures/$team/"`;
|
|
|
|
if( file_exists("../pictures/$team") )
|
|
{
|
|
$message = "> Team $team successfully added.";
|
|
|
|
if( move_uploaded_file($_FILES['icon']['tmp_name'],"../pictures/$team/icon.jpg") )
|
|
{ $message .= "<br />> Image successfully set for $team."; }
|
|
else { $message .= "<br />> Could not set image for $team."; }
|
|
}
|
|
else
|
|
{ $message = "> $team could not be added, please try again."; }
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Adds a discipline to an existing team
|
|
//=======================================
|
|
function AddDisc()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$disc = str_replace(".","_",$_POST['discname']);
|
|
$disc = str_replace("/","_",$disc);
|
|
$disc = str_replace(" ","_",$disc);
|
|
$disc = escapeshellcmd($disc);
|
|
|
|
if( file_exists("../pictures/$team/$disc/") ) //make sure this discipline doesn't already exist
|
|
{
|
|
$message = "> $disc for $team already exists!";
|
|
|
|
print `rm "../pictures/$team/$disc/icon.jpg"`; //remove old icon, replace with new one
|
|
if( move_uploaded_file($_FILES['icon']['tmp_name'],"../pictures/$team/$disc/icon.jpg") )
|
|
{ $message .= "<br />> Updated image for $disc."; }
|
|
else { $message .= "<br />> Could not update image for $disc, please try again."; }
|
|
}
|
|
else //if the discipline does not already exist
|
|
{
|
|
print `mkdir "../pictures/$team/$disc/"`;
|
|
|
|
if( file_exists("../pictures/$team/$disc") )
|
|
{
|
|
$message = "> $disc for $team successfully added.";
|
|
|
|
if( move_uploaded_file($_FILES['icon']['tmp_name'],"../pictures/$team/$disc/icon.jpg") )
|
|
{ $message .= "<br />> Image successfully set for $disc."; }
|
|
else { $message .= "<br />> Could not set image for $disc."; }
|
|
}
|
|
else
|
|
{ $message = "> $disc for $team could not be added, please try again."; }
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Adds an event to an existing team
|
|
//=======================================
|
|
function AddEvent()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$disc = str_replace(".","_",$_POST['discname']);
|
|
$disc = str_replace("/","_",$disc);
|
|
$disc = str_replace(" ","_",$disc);
|
|
$disc = escapeshellcmd($disc);
|
|
|
|
$event = str_replace(".","_",$_POST['eventname']);
|
|
$event = str_replace("/","_",$event);
|
|
$event = str_replace(" ","_",$event);
|
|
$event = escapeshellcmd($event);
|
|
|
|
if( file_exists("../pictures/$team/$disc/$event/") ) //make sure this event doesn't already exist
|
|
{
|
|
$message = "> $event for $team already exists!";
|
|
|
|
print `rm "../pictures/$team/$disc/$event/icon.jpg"`; //remove old icon, replace with new one
|
|
if( move_uploaded_file($_FILES['icon']['tmp_name'],"../pictures/$team/$disc/$event/icon.jpg") )
|
|
{ $message .= "<br />> Updated image for $event."; }
|
|
else { $message .= "<br />> Could not update image for $event, please try again."; }
|
|
}
|
|
else //if the event does not already exist
|
|
{
|
|
print `mkdir "../pictures/$team/$disc/$event/"`;
|
|
|
|
if( file_exists("../pictures/$team/$disc/$event") )
|
|
{
|
|
$message = "> $event for $team successfully added.";
|
|
|
|
if( move_uploaded_file($_FILES['icon']['tmp_name'],"../pictures/$team/$disc/$event/icon.jpg") )
|
|
{ $message .= "<br />> Image successfully set for $event."; }
|
|
else { $message .= "<br />> Could not set image for $event."; }
|
|
}
|
|
else
|
|
{ $message = "> $event for $team could not be added, please try again."; }
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Adds a picture to an existing
|
|
// event of an existing team
|
|
//=======================================
|
|
function AddPicture()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$disc = str_replace(".","_",$_POST['discname']);
|
|
$disc = str_replace("/","_",$disc);
|
|
$disc = str_replace(" ","_",$disc);
|
|
$disc = escapeshellcmd($disc);
|
|
|
|
$event = str_replace(".","_",$_POST['eventname']);
|
|
$event = str_replace("/","_",$event);
|
|
$event = str_replace(" ","_",$event);
|
|
$event = escapeshellcmd($event);
|
|
|
|
$name = $_FILES['picture']['name'];
|
|
$description = addslashes($_POST['description']);
|
|
$price = addslashes($_POST['price']);
|
|
|
|
if( move_uploaded_file($_FILES['picture']['tmp_name'],"../pictures/$team/$disc/$event/$name") )
|
|
{
|
|
if( file_put_contents("../pictures/$team/$disc/$event/$name.txt","$price\n$description") )
|
|
{ $message = "Picture $name successfully added to team $team for $event."; }
|
|
}
|
|
else { $message = "Picture $name could not be added to $disc for team $team for $event, please try again."; }
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Deletes a team's entire folder
|
|
//=======================================
|
|
function DeleteTeam()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$team_folder = scandir("../pictures/$team");
|
|
|
|
foreach($team_folder as $file)
|
|
{
|
|
if( $file != '.' and $file != '..' )
|
|
{
|
|
$disc_folder = scandir("../pictures/$team/$file");
|
|
foreach($disc_folder as $file2)
|
|
{
|
|
if( $file2 != '.' and $file2 != '..' )
|
|
{
|
|
$event_folder = scandir("../pictures/$team/$file/$file2");
|
|
foreach($event_folder as $file3)
|
|
{
|
|
if( $file3 != '.' and $file3 != '..' )
|
|
{
|
|
if( is_dir("../pictures/$team/$file/$file2/$file3") )
|
|
{ print `rmdir "../pictures/$team/$file/$file2/$file3/"`; }
|
|
else
|
|
{ print `rm "../pictures/$team/$file/$file2/$file3"`; }
|
|
}
|
|
}
|
|
|
|
if( is_dir("../pictures/$team/$file/$file2") )
|
|
{ print `rmdir "../pictures/$team/$file/$file2"`; }
|
|
else
|
|
{ print `rm "../pictures/$team/$file/$file2"`; }
|
|
}
|
|
}
|
|
|
|
if( is_dir("../pictures/$team/$file") )
|
|
{ print `rmdir "../pictures/$team/$file"`; }
|
|
else
|
|
{ print `rm "../pictures/$team/$file"`; }
|
|
}
|
|
}
|
|
|
|
print `rmdir "../pictures/$team"`;
|
|
|
|
if( file_exists("../pictures/$team") )
|
|
{ $message = "> Could not delete team."; }
|
|
else { $message = "> Team deleted successfully."; }
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Deletes a team's entire discipline folder
|
|
//=======================================
|
|
function DeleteDisc()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$disc = str_replace(".","_",$_POST['discname']);
|
|
$disc = str_replace("/","_",$disc);
|
|
$disc = str_replace(" ","_",$disc);
|
|
$disc = escapeshellcmd($disc);
|
|
|
|
$disc_folder = scandir("../pictures/$team/$disc/");
|
|
|
|
foreach($disc_folder as $file)
|
|
{
|
|
if( $file != '.' and $file != '..' )
|
|
{
|
|
$event_folder = scandir("../pictures/$team/$disc/$file");
|
|
foreach($event_folder as $file2)
|
|
{
|
|
if( $file2 != '.' and $file2 != '..' )
|
|
{
|
|
if( is_dir("../pictures/$team/$disc/$file/$file2") )
|
|
{ print `rmdir "../pictures/$team/$disc/$file/$file2/"`; }
|
|
else
|
|
{ print `rm "../pictures/$team/$disc/$file/$file2"`; }
|
|
}
|
|
}
|
|
|
|
if( is_dir("../pictures/$team/$disc/$file") )
|
|
{ print `rmdir "../pictures/$team/$disc/$file/"`; }
|
|
else
|
|
{ print `rm "../pictures/$team/$disc/$file"`; }
|
|
}
|
|
}
|
|
|
|
print `rmdir "../pictures/$team/$disc"`;
|
|
|
|
if( file_exists("../pictures/$team/$disc") )
|
|
{ $message = "> Could not delete discipline."; }
|
|
else { $message = "> Discipline deleted successfully."; }
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Deletes a team's entire event folder
|
|
//=======================================
|
|
function DeleteEvent()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$disc = str_replace(".","_",$_POST['discname']);
|
|
$disc = str_replace("/","_",$disc);
|
|
$disc = str_replace(" ","_",$disc);
|
|
$disc = escapeshellcmd($disc);
|
|
|
|
$event = str_replace(".","_",$_POST['eventname']);
|
|
$event = str_replace("/","_",$event);
|
|
$event = str_replace(" ","_",$event);
|
|
$event = escapeshellcmd($event);
|
|
|
|
$event_folder = scandir("../pictures/$team/$disc/$event/");
|
|
|
|
foreach($event_folder as $file)
|
|
{
|
|
if( $file != '.' and $file != '..' )
|
|
{ print `rm "../pictures/$team/$disc/$event/$file"`; }
|
|
}
|
|
|
|
print `rmdir "../pictures/$team/$disc/$event/"`;
|
|
|
|
if( file_exists("../pictures/$team/$disc/$event") )
|
|
{ $message = "> Could not delete event."; }
|
|
else { $message = "> Event deleted successfully."; }
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Deletes a picture from an event of a team
|
|
//=======================================
|
|
function DeletePicture()
|
|
{
|
|
$team = str_replace(".","_",$_POST['teamname']);
|
|
$team = str_replace("/","_",$team);
|
|
$team = str_replace(" ","_",$team);
|
|
$team = escapeshellcmd($team);
|
|
|
|
$disc = str_replace(".","_",$_POST['discname']);
|
|
$disc = str_replace("/","_",$disc);
|
|
$disc = str_replace(" ","_",$disc);
|
|
$disc = escapeshellcmd($disc);
|
|
|
|
$event = str_replace(".","_",$_POST['eventname']);
|
|
$event = str_replace("/","_",$event);
|
|
$event = str_replace(" ","_",$event);
|
|
$event = escapeshellcmd($event);
|
|
|
|
$picture = str_replace("/","_",$_POST['picturename']);
|
|
$picture = str_replace(" ","_",$picture);
|
|
$picture = escapeshellcmd($picture);
|
|
|
|
print `rm "../pictures/$team/$disc/$event/$picture"`;
|
|
print `rm "../pictures/$team/$disc/$event/$picture.txt"`;
|
|
|
|
|
|
if( file_exists("../pictures/$team/$disc/$event/$picture") )
|
|
{ $message = "> Could not delete picture."; }
|
|
else { $message = "> Picture deleted successfully."; }
|
|
|
|
if( file_exists("../pictures/$team/$disc/$event/$picture.txt") )
|
|
{ $message .= "<br />> Could not delete picture details file."; }
|
|
else { $message .= "<br />> Picture details file deleted successfully."; }
|
|
|
|
return $message;
|
|
}
|
|
|
|
//=======================================
|
|
// Prints the admin index
|
|
//=======================================
|
|
function PrintAdminIndex()
|
|
{
|
|
$teams = scandir('../pictures');
|
|
$teams_html = "";
|
|
$events_js = "";
|
|
$pictures_js = "";
|
|
if($teams)
|
|
{
|
|
foreach($teams as $file) //traverse each team's folder
|
|
{
|
|
if( $file != '.' and $file != ".." and $file != 'icon.jpg') //ignore certain files/folders
|
|
{
|
|
$teams_html .= "<option value='$file'>$file</option>\n"; //create the html for each teams select menu
|
|
|
|
$var_name = str_replace(" ","_",$file); //all spaces are to be replaced with underscores
|
|
$discs_counter = 0;
|
|
$discs_js .= "\nvar $var_name = new Array();"; //create a javascript array for this team's discipline
|
|
|
|
$discs = scandir("../pictures/$file");
|
|
if($discs)
|
|
{
|
|
foreach($discs as $file2) //traverse each discipline folder for this team
|
|
{
|
|
if($file2 != '.' and $file2 != ".." and $file2 != 'icon.jpg') //ignore certain files/folders
|
|
{
|
|
$file_name = addslashes($file2);
|
|
$discs_js .= "\n $var_name" . "[$discs_counter] = '$file2';";
|
|
$discs_counter++;
|
|
|
|
$var_name2 = str_replace(" ","_",$file2);
|
|
$events_counter = 0;
|
|
$events_js .= "\nvar $var_name$var_name2 = new Array();";
|
|
|
|
$events = scandir("../pictures/$file/$file2");
|
|
if($events)
|
|
{
|
|
foreach($events as $file3) //traverse events folder for team's disciplines
|
|
{
|
|
if($file3 != '.' and $file3 != '..' and $file3 != 'icon.jpg')
|
|
{
|
|
$file_name2 = addslashes($file3);
|
|
$events_js .= "\n $var_name$var_name2" . "[$events_counter] = '$file_name2';";
|
|
$events_counter++;
|
|
|
|
$var_name3 = str_replace(" ","_",$file3);
|
|
$pictures_counter = 0;
|
|
$pictures_js .= "\nvar $var_name$var_name2$var_name3 = new Array();";
|
|
|
|
$pictures = scandir("../pictures/$file/$file2/$file3");
|
|
if($pictures)
|
|
{
|
|
foreach($pictures as $file4) //scan the pictures for each event of each team's disciplines
|
|
{
|
|
if($file4 != '.' and $file4 != '..' and $file4 != 'icon.jpg' and !(true == strpos($file4,".txt")))
|
|
{
|
|
$file_name3 = addslashes($file4);
|
|
$pictures_js .= "\n $var_name$var_name2$var_name3" . "[$pictures_counter] = '$file_name3';";
|
|
$pictures_counter++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
?>
|
|
<strong>Admin Panel</strong>
|
|
<br /> <hr />
|
|
|
|
<!--ADD TEAM-->
|
|
<form action='index.php' method='post' enctype="multipart/form-data">
|
|
<input type='hidden' name='cmd' value='add_team' />
|
|
<div class='admin_section'>Add a new bobsled team</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Team name:</td>
|
|
<td><input type='text' size='30' name='teamname' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Icon for this team:</td>
|
|
<td><input type='file' name='icon' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Add Team' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<!--ADD Discipline-->
|
|
<form action='index.php' method='post' enctype="multipart/form-data">
|
|
<input type='hidden' name='cmd' value='add_disc' />
|
|
<div class='admin_section'>Add a new discipline to an existing team</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select Team:</td>
|
|
<td>
|
|
<select name='teamname'>
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Discipline name:</td>
|
|
<td><input type='text' size='30' name='discname' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Icon for this discipline:</td>
|
|
<td><input type='file' name='icon' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Add Discipline' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<!--ADD EVENT-->
|
|
<form action='index.php' method='post' enctype="multipart/form-data">
|
|
<input type='hidden' name='cmd' value='add_event' />
|
|
<div class='admin_section'>Add a new event to an existing team's discipline</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select Team:</td>
|
|
<td>
|
|
<select name='teamname' id='add_teams_select' onchange="SetDiscsHTML('add')">
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select Discipline:</td>
|
|
<td>
|
|
<select name='discname' id='add_discs_select' style='visibility:hidden'>
|
|
<option>Select a Discipline</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Event name:</td>
|
|
<td><input type='text' size='30' name='eventname' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Icon for this event:</td>
|
|
<td><input type='file' name='icon' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Add Event' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<!--ADD PICTURE-->
|
|
<form action='index.php' method='post' enctype="multipart/form-data">
|
|
<input type='hidden' name='cmd' value='add_picture' />
|
|
<div class='admin_section'>Add a new picture to an existing team's event</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select Team:</td>
|
|
<td>
|
|
<select name='teamname' id='add2_teams_select' onchange="SetDiscsHTML('add2')">
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select Discipline:</td>
|
|
<td>
|
|
<select name='discname' id='add2_discs_select' style='visibility:hidden' onchange="SetEventsHTML('add2')">
|
|
<option>Select a Discipline</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select Event:</td>
|
|
<td>
|
|
<select name='eventname' id='add2_events_select' style='visibility:hidden'>
|
|
<option>Select an Event</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Browse for picture:</td>
|
|
<td><input type='file' name='picture' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Picture description:</td>
|
|
<td><input type='text' size='50' name='description' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Picture price:</td>
|
|
<td><input type='text' size='5' name='price' /> (no dollar sign)</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Add Picture' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<script type='text/javascript' language='javascript'>
|
|
<!--
|
|
<?php print $discs_js . "\n\n" . $events_js . "\n\n" . $pictures_js;
|
|
?>
|
|
|
|
function SetDiscsHTML(id_prefix)
|
|
{
|
|
var discs_id = id_prefix + "_discs_select";
|
|
var teams_id = id_prefix + "_teams_select";
|
|
|
|
//grab the HTML elements
|
|
var discs_select = document.getElementById(discs_id);
|
|
var team_selected = document.getElementById(teams_id).value;
|
|
|
|
//replace all spaces with an underscore
|
|
while( team_selected.indexOf(" ") > 0 )
|
|
{ team_selected = team_selected.replace(" ","_"); }
|
|
|
|
var discs_array = eval(team_selected);
|
|
var array_length = discs_array.length;
|
|
|
|
if( team_selected != 'Select a Team' )
|
|
{
|
|
if(id_prefix == "delete3")
|
|
{
|
|
var picture_options = document.getElementById(id_prefix + "_pictures_select").options.length - 1;
|
|
for(var c=picture_options;c>0;c--)
|
|
{ document.getElementById(id_prefix + "_pictures_select").remove(c); }
|
|
}
|
|
if((id_prefix == "delete2") || (id_prefix == "delete3") || (id_prefix == "add2"))
|
|
{
|
|
var event_options = document.getElementById(id_prefix + "_events_select").options.length - 1;
|
|
for(var c=event_options;c>0;c--)
|
|
{ document.getElementById(id_prefix + "_events_select").remove(c); }
|
|
}
|
|
|
|
var num_options = discs_select.options.length - 1;
|
|
for(var c=num_options;c>0;c--)
|
|
{ discs_select.remove(c); }
|
|
|
|
for(var i=0;i < array_length;i++)
|
|
{
|
|
var new_option = document.createElement("OPTION");
|
|
new_option.text = discs_array[i];
|
|
new_option.value = discs_array[i];
|
|
|
|
discs_select.style.visibility = "visible";
|
|
discs_select.options.add(new_option);
|
|
}
|
|
}
|
|
}
|
|
|
|
function SetEventsHTML(id_prefix)
|
|
{
|
|
var events_id = id_prefix + "_events_select";
|
|
var discs_id = id_prefix + "_discs_select";
|
|
var teams_id = id_prefix + "_teams_select";
|
|
|
|
//grab the HTML elements
|
|
var events_select = document.getElementById(events_id);
|
|
var disc_selected = document.getElementById(discs_id).value;
|
|
var team_selected = document.getElementById(teams_id).value;
|
|
|
|
//replace all spaces with an underscore
|
|
while( disc_selected.indexOf(" ") > 0 )
|
|
{ disc_selected = disc_selected.replace(" ","_"); }
|
|
while( team_selected.indexOf(" ") > 0 )
|
|
{ team_selected = team_selected.replace(" ","_"); }
|
|
|
|
var events_array = eval(team_selected + disc_selected);
|
|
var array_length = events_array.length;
|
|
|
|
if( disc_selected != 'Select a Discipline' )
|
|
{
|
|
if(id_prefix == "delete3")
|
|
{
|
|
var picture_options = document.getElementById(id_prefix + "_pictures_select").options.length - 1;
|
|
for(var c=picture_options;c>0;c--)
|
|
{ document.getElementById(id_prefix + "_pictures_select").remove(c); }
|
|
}
|
|
|
|
var num_options = events_select.options.length - 1;
|
|
for(var c=num_options;c>0;c--)
|
|
{ events_select.remove(c); }
|
|
|
|
for(var i=0;i < array_length;i++)
|
|
{
|
|
var new_option = document.createElement("OPTION");
|
|
new_option.text = events_array[i];
|
|
new_option.value = events_array[i];
|
|
|
|
events_select.style.visibility = "visible";
|
|
events_select.options.add(new_option);
|
|
}
|
|
}
|
|
}
|
|
|
|
function SetPicturesHTML()
|
|
{
|
|
//grab the HTML elements
|
|
var pictures_select = document.getElementById('delete3_pictures_select');
|
|
var event_selected = document.getElementById('delete3_events_select').value;
|
|
var disc_selected = document.getElementById('delete3_discs_select').value;
|
|
var team_selected = document.getElementById('delete3_teams_select').value;
|
|
|
|
//replace all spaces with an underscore
|
|
while( event_selected.indexOf(" ") > 0 )
|
|
{ event_selected = event_selected.replace(" ","_"); }
|
|
while( disc_selected.indexOf(" ") > 0 )
|
|
{ disc_selected = disc_selected.replace(" ","_"); }
|
|
while( team_selected.indexOf(" ") > 0 )
|
|
{ team_selected = team_selected.replace(" ","_"); }
|
|
|
|
var pictures_array = eval(team_selected + disc_selected + event_selected);
|
|
var array_length = pictures_array.length;
|
|
|
|
if( event_selected != 'Select an Event' )
|
|
{
|
|
var num_options = pictures_select.options.length - 1;
|
|
for(var c=num_options;c>0;c--)
|
|
{ pictures_select.remove(c); }
|
|
|
|
for(var i=0;i < array_length;i++)
|
|
{
|
|
var new_option = document.createElement("OPTION");
|
|
new_option.text = pictures_array[i];
|
|
new_option.value = pictures_array[i];
|
|
|
|
pictures_select.style.visibility = "visible";
|
|
pictures_select.options.add(new_option);
|
|
}
|
|
}
|
|
}
|
|
|
|
function ReallyDeleteTeam()
|
|
{
|
|
if( confirm("Do you really want to delete this team?") )
|
|
{ return true; }
|
|
else { return false; }
|
|
}
|
|
|
|
function ReallyDeleteDisc()
|
|
{
|
|
if( confirm("Do you really want to delete this discipline?") )
|
|
{ return true; }
|
|
else { return false; }
|
|
}
|
|
|
|
function ReallyDeleteEvent()
|
|
{
|
|
if( confirm("Do you really want to delete this event?") )
|
|
{ return true; }
|
|
else { return false; }
|
|
}
|
|
|
|
function ReallyDeletePicture()
|
|
{
|
|
if( confirm("Do you really want to delete this picture?") )
|
|
{ return true; }
|
|
else { return false; }
|
|
}
|
|
|
|
//-->
|
|
</script>
|
|
<hr /> <hr />
|
|
<!--DELETION CAPABILITIES--->
|
|
|
|
<!--DELETE TEAM-->
|
|
<form action='index.php' method='post'>
|
|
<input type='hidden' name='cmd' value='delete_team' />
|
|
<div class='admin_section'>Delete an entire, existing team</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select a team:</td>
|
|
<td>
|
|
<select name='teamname'>
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Delete Team' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<!--DELETE DISCIPLINE-->
|
|
<form action='index.php' method='post'>
|
|
<input type='hidden' name='cmd' value='delete_disc' />
|
|
<div class='admin_section'>Delete an entire, existing discipline of an existing team</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select Team:</td>
|
|
<td>
|
|
<select name='teamname' id='delete_teams_select' onchange="SetDiscsHTML('delete')">
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select a Discipline:</td>
|
|
<td>
|
|
<select name='discname' id='delete_discs_select' style='visibility:hidden'>
|
|
<option>Select a Discipline</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Delete Discipline' onsubmit='ReallyDeleteDisc()' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<!--DELETE EVENT-->
|
|
<form action='index.php' method='post'>
|
|
<input type='hidden' name='cmd' value='delete_event' />
|
|
<div class='admin_section'>Delete an entire, existing event of an existing team</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select Team:</td>
|
|
<td>
|
|
<select name='teamname' id='delete2_teams_select' onchange="SetDiscsHTML('delete2')">
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select a Discipline:</td>
|
|
<td>
|
|
<select name='discname' id='delete2_discs_select' style='visibility:hidden' onchange="SetEventsHTML('delete2')">
|
|
<option>Select a Discipline</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select an event:</td>
|
|
<td>
|
|
<select name='eventname' id='delete2_events_select' style='visibility:hidden'>
|
|
<option>Select an Event</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Delete Event' onsubmit='ReallyDeleteEvent()' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<!--DELETE PICTURE-->
|
|
<form action='index.php' method='post'>
|
|
<input type='hidden' name='cmd' value='delete_picture' />
|
|
<div class='admin_section'>Delete a picture from an existing team's event</div>
|
|
<div class='indented_para'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Select Team:</td>
|
|
<td>
|
|
<select name='teamname' id='delete3_teams_select' onchange="SetDiscsHTML('delete3')">
|
|
<option>Select a Team</option>
|
|
<?php print $teams_html;
|
|
?>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select a Discipline:</td>
|
|
<td>
|
|
<select name='discname' id='delete3_discs_select' style='visibility:hidden' onchange="SetEventsHTML('delete3')">
|
|
<option>Select a Discipline</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select Event:</td>
|
|
<td>
|
|
<select name='eventname' id="delete3_events_select" onchange="SetPicturesHTML()" style='visibility:hidden'>
|
|
<option>Select an Event</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Select Picture:</td>
|
|
<td>
|
|
<select name='picturename' id="delete3_pictures_select" style='visibility:hidden'>
|
|
<option>Select a Picture</option>
|
|
</select>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='Delete Picture' /></td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</form>
|
|
<hr />
|
|
|
|
<?php
|
|
}
|
|
|
|
//=======================================
|
|
// Displays the admin login page
|
|
//=======================================
|
|
function PrintLoginPage()
|
|
{
|
|
?>
|
|
<form action='index.php' method='post'>
|
|
<table cellpadding='4' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td align='right'>Username:</td>
|
|
<td><input type='text' size='20' name='user' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td align='right'>Password:</td>
|
|
<td><input type='password' size='20' name='password' /></td>
|
|
</tr>
|
|
<tr>
|
|
<td> </td>
|
|
<td><input type='submit' value='login' /></td>
|
|
</table>
|
|
</form>
|
|
<?php
|
|
}
|
|
|
|
?>
|