View file phpmytourney/admin/adminfunctions.php

File size: 6.24Kb
<html>
<body>
<?php
/***********************************************************
* This file was created by Jйrфme Poulin under the phpmytourney
* project.  
* You can modify and redistribute this file as long as this
* copyright notice stays in the file.
*
* If you want to do major upgrades on my script, please contact
* me and we could work together.
* 
* Jйrфme Poulin
* Student University of Sherbrooke
* [email protected] <== dont use for support !!!
* http:/phpmytourney.sourceforge.net/ <== use sourceforce forum for support
* 
*  phpMyTourney <C> 2001-2002
************************************************************/
/***********************************************************
*	filename : adminfunctions.php
*	Created by : Jйrфme Poulin@09-02-2002
*	Last modified : Jйrфme Poulin@09-02-2002
************************************************************/
include('../config.inc');
include($functions_file);

if(!isset($action))	echo("this page wasnt properly called");
else{
	$action();
}

function welcome(){
	echo("Welcome to Tourney Administrator");
}
function menu(){
?>
<br>- <a href="adminfunctions.php?action=newtourney" target="main">New Tourney</a>
<br>- <a href="adminfunctions.php?action=editdeletetourney" target="main">View Tourney</a>
<?php
}
function newtourney(){
	global $maps,$tourney_types;
	print_top_form("New Tourney","POST","adminmysql.php");
	print_textbox("Host Name","hostname");
	print_textbox("Nb players per team?<br>(1 = single)<br>This information cannot be altered so pick it carefully","nb_per_team");
	print_textbox("Tourney Name","tname");
	print_textbox("Checkin datetime<br><b>(yyyy-mm-dd hh:mm:ss)</b>","tdatetime");
	print_select_2dim_array("Tourney Type","ttype",$tourney_types);
	print_textbox("Prize","prize",50,200);
		
//default value of textarea :
$maps = "Any Html Code in Here...";	
	print_textarea("More Information...","maps",35,20);
	echo("<input type=\"HIDDEN\" name=\"action\" value=\"newtourney\">");
	print_submit("New Tourney");
	
}
function editdeletetourney(){
	$sql = "Select id, tname, tdatetime, nb_per_team, status, id  from  " . $GLOBALS['dbtable_header'] . "info order by id";
	$tarray = get_mysql_rows($sql,"no");
if($tarray){
	$header[0][] = "ID";
	$header[0][] = "Tourney Name";
	$header[0][] = "DateTime";
	$header[0][] = "#/team";
	$header[0][] = "Status";
	$header[0][] = "View Players";
	$header[0][] = "Change Status";
	$header[0][] = "Edit";
	$header[0][] = "Delete";
	$nb = count($tarray);
	for($i=0;$i<$nb;$i++){
		$tarray[$i][4] = get_status_name($tarray[$i][4]);
		$tourney_id = $tarray[$i][5];
		$tarray[$i][5] = "<a href=\"adminfunctions.php?action=viewplayers&tourney_id=" . $tourney_id . "\" target=\"main\">Manage Tourney</a>";
		$tarray[$i][6] = "<a href=\"adminfunctions.php?action=changestatus&tourney_id=" . $tourney_id . "\" target=\"main\">Change Status</a>";
		$tarray[$i][7] = "<a href=\"adminfunctions.php?action=edittourney&tourney_id=" . $tourney_id . "\" target=\"main\">Edit Info</a>";
		$tarray[$i][8] = "<a href=\"adminfunctions.php?action=deletetourney&tourney_id=" . $tourney_id . "\" target=\"main\">Delete</a>";
	}
	$table = array_merge($header,$tarray);
	print_table($table,"Current Tourneys");
}
else
	print_error("No tournaments to view/edit...");
	
	print_status_legende();

}
function edittourney(){
	global $tourney_id;

	get_tourney_info($tourney_id);

	print_top_form("Edit Tourney","POST","adminmysql.php");
	print_textbox("Host Name","hostname");
	print_textbox("Tourney Name","tname");
	print_textbox("Checkin datetime<br><b>(yyyy-mm-dd hh:mm:ss)</b>","tdatetime");

	print_textbox("Prize","prize");	
	print_textarea("More Information...","maps",35,20);
	echo("	<input type=\"HIDDEN\" name=\"action\" value=\"edittourney\">
		<input type=\"HIDDEN\" name=\"tourney_id\" value=\"" . $tourney_id . "\">");
	print_submit("Edit Tourney");

}
function deletetourney(){
	global $tourney_id;
	echo("	<P>Are you sure you want to DELETE tourney. This operation 
		is totaly permanent. No information will be backed up and 
		everything regarding the tourney will be lost</P>");
	echo("<br><a href=\"adminmysql.php?action=deletetourney&tourney_id=" . $tourney_id . "\" target=\"main\">Delete it!</a>");
			
}
function get_tourney_info($id){
	global $hostname, $tname, $tdatetime, $ttype, $tspeed, $prize, $maps;
	$sql = "SELECT hostname, tname, tdatetime, ttype, tspeed, prize, maps
		FROM  " . $GLOBALS['dbtable_header'] . "info 
		WHERE id = '$id'";
	$values = get_mysql_row($sql);
	$hostname = $values[0];
	$tname = $values[1];
	$tdatetime = $values[2];
	$ttype = $values[3];
	$tspeed = $values[4];
	$prize = $values[5];
	$maps = $values[6];
}

function changestatus(){
	global $tourney_id;
	echo("Modify Status...");
	echo("	<p> Allrite this isnt much user friendly, but it takes me much less time...
		<br> Use theses code for Tourney Status");
	print_status_legende();
	
	print_top_form("Change Status","POST","adminmysql.php");
	print_textbox("Status Number","status",1,1);
	echo("	<input type=\"HIDDEN\" name=\"action\" value=\"changestatus\">
		<input type=\"HIDDEN\" name=\"tourney_id\" value=\"" . $tourney_id . "\">");
	print_submit("Change Status");
	
}
function replacebye(){
	global $tourney_id,$pos;
	$tou_type = get_tourney_type($tourney_id);
	
	if ($tou_type == "team")
		$rows = get_mysql_rows("SELECT a.id, c.teamname from ALLTOURNEY_players a, tourney_signup_" . $tourney_id . " c LEFT JOIN tourney_data_" . $tourney_id . " b ON a.id=b.id WHERE a.id = c.id and b.id IS NULL","no");
	else
		$rows = get_mysql_rows("SELECT a.id, a.name from ALLTOURNEY_players a LEFT JOIN tourney_data_" . $tourney_id . " b ON a.id=b.id WHERE b.id IS NULL","no");
		
	if($rows){
		print_top_form("Replace Bye with " . $tou_type . " ?","POST","adminmysql.php");
		print_select_2dim_array($tou_type,"id",$rows);
		echo("	<input type=\"HIDDEN\" name=\"action\" value=\"replacebye_sql\">
			<input type=\"HIDDEN\" name=\"pos\" value=\"" . $pos . "\">
			<input type=\"HIDDEN\" name=\"tourney_id\" value=\"" . $tourney_id . "\">");
		print_submit("Replace Bye with This " . $tou_type);
	}
	else{
		print_error("There is no other " . $tou_type . " to pick ");
		viewplayers();	
	}


}
?>
</body>
</html>