////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//DO NOT EDIT THIS FILE
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
include("./config.inc.php");
include("./template.inc.php");
include("./global.inc.php");
$config[header]=html_header($tourney[id]);
$config[footer]=$config[tailer].html_footer($tourney[id]);
$tinfo=tourney_defaults($tourney[id]);
if(($action)&&(!$tinfo[tid])){
error("Unknown Tournament ID
Click Here for the Tournament List");
exit;
}
if((!$action)&&($tinfo[tid])){
$action="details";
}
switch($action){
case "details":
tourney_details($tourney);
break;
case "signup":
tourney_signup();
break;
case "tourney_signup_2":
tourney_signup_2($signup);
break;
case "players":
tourney_players();
break;
case "playerinfo":
tourney_playerinfo($player);
break;
case "brackets":
tourney_brackets();
break;
default:
tourney_list($search);
break;
}
//START FUNCTIONS
function tourney_list($search){
global $config,$tinfo;
if($search[type]==1){
$searchfield=characters($search[field]);
$searchfield="%".$searchfield."%";
$maxresults="25";
$searchinfo=mysql_query("SELECT tid FROM tourneys WHERE name LIKE '$searchfield' LIMIT $maxresults");
while(list($tid)=mysql_fetch_row($searchinfo)) {
$searchresult[$tid]="1";
}
}
echo"$config[header]";
?>
Tournaments
| TID |
Tournament |
Details |
Brackets |
Signup |
$tourneylist=mysql_query("SELECT tid,size,active,name FROM tourneys ORDER BY name");
while(list($tid,$size,$active,$name)=mysql_fetch_row($tourneylist)){
if(($search[type]==1)&&($searchresult[$tid])){
$resultmatch="1";
$showmainlink="1";
}
elseif(($search[type]==2)&&($search[field]==$tid)){
$resultmatch="1";
$showmainlink="1";
}
elseif(($search[type]==1)||($search[type]==2)){
$resultmatch="";
$showmainlink="1";
}
else{
$resultmatch="1";
$showmainlink="";
}
if($resultmatch){
?>
| echo"$searchresulta $tid $searchresultb"; ?> |
echo"$searchresulta $name $searchresultb"; ?> |
Details |
Brackets |
Signup |
}
}
if($showmainlink){
?>
List All Tournaments |
}
?>
echo"$config[footer]";
}
function tourney_search($search){
}
function tourney_details($tourney){
global $config,$tinfo;
$SearchArray = array("\n","<",">");
$ReplaceArray = array("
","<",">");
$tinfo[details]=str_replace($SearchArray,$ReplaceArray,$tinfo[details]);
$UrlSearchArray = array("/([^]_a-z0-9-=\"'\/])((https?|ftp|news):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si","/^((https?|ftp|news):\/\/|www\.)([^ \r\n\(\)\*\^\$!`\"'\|\[\]\{\};<>]*)/si",);
$UrlReplaceArray = array("\\1\\2\\4","\\1\\3");
$tinfo[details]=preg_replace($UrlSearchArray,$UrlReplaceArray,$tinfo[details]);
echo"$config[header]";
?>
Tournament Directors: echo"$tinfo[directors]"; ?>
echo"$tinfo[name]"; ?> Details
| echo"$tinfo[details]"; ?> |
echo"$config[footer]";
}
function tourney_signup(){
global $config,$tinfo;
echo"$config[header]";
?>
echo"$tinfo[name]"; ?> Signup
if($tinfo[active]){
?>
}else{
?>
Signups are currently disabled
}
?>
echo"$config[footer]";
}
function tourney_signup_2($signup){
global $config,$tinfo;
while(list($varib,$value)=each($signup)){
$signup[$varib]=characters($value);
if(!$signup[$varib]){
error("All fields are required");
exit;
}
}
if(mysql_num_rows(mysql_query("SELECT pid FROM players2 WHERE tid='$tinfo[tid]' AND name='$signup[name]'"))){
error("That Name is already in use on this tournament");
exit;
}
if(mysql_num_rows(mysql_query("SELECT pid FROM players2 WHERE tid='$tinfo[tid]' AND email='$signup[email]'"))){
error("That Email Adddress is already in use on this tournament");
exit;
}
if(mysql_num_rows(mysql_query("SELECT pid FROM players2 WHERE tid='$tinfo[tid]' AND ipaddress='$config[ip]'"))){
error("Your IP Adddress is already in use on this tournament");
exit;
}
mysql_query("INSERT INTO players2 VALUES (
NULL,
'$tinfo[tid]',
'$config[ip]',
'$config[stamp]',
'$signup[name]',
'$signup[email]',
'$signup[field1]',
'$signup[field2]',
'$signup[field3]');");
echo"$config[header]";
?>
You have been added to the player signups!
Entering the tournament does not guarantee you a spot.
echo"$config[admintail] $config[footer]";
}
function tourney_players(){
global $config,$tinfo;
echo"$config[header]";
?>
echo"$tinfo[name]"; ?> Players
| # |
Name |
$tourneyreports=mysql_query("SELECT pid,name FROM players2 WHERE tid='$tinfo[tid]' ORDER BY joined");
while(list($pid,$name)=mysql_fetch_row($tourneyreports)){
$count++;
?>
| echo"$count"; ?> |
echo"$name"; ?> |
}
?>
echo"$config[footer]";
}
function tourney_playerinfo($player){
global $config,$tinfo;
$player=mysql_query("SELECT * FROM players2 WHERE pid='$player[id]'");
$player=mysql_fetch_array($player);
if(($action)&&(!$tinfo[tid])){
error("Unknown Player ID");
exit;
}
echo"$config[header]";
?>
echo"$tinfo[name]"; ?> Player Information
| Name |
echo"$player[name]"; ?> |
| Email |
echo"$player[email]"; ?> |
if($tinfo[field1]){
?>
| echo"$tinfo[field1]"; ?> |
border='0'> |
}
if($tinfo[field2]){
?>
| echo"$tinfo[field2]"; ?> |
echo"$player[field2]"; ?> |
}
if($tinfo[field3]){
?>
| echo"$tinfo[field3]"; ?> |
echo"$player[field3]"; ?> |
}
?>
echo"$config[footer]";
}
function tourney_brackets(){
global $config,$tinfo;
$brackets=mysql_query("SELECT bid,pid,name,winner FROM brackets2 WHERE tid='$tinfo[tid]' ORDER BY bid");
while(list($bid,$pid,$name,$winner)=mysql_fetch_row($brackets)){
if($winner){
$bracket[$bid]="$name
\n $winner";
}else{
$bracket[$bid]="$name";
}
$pid="";
}
$brackets="$tinfo[size]";
//TEMP FOR TESTING
//$brackets="64";
$spots=($brackets * 2 - 1);
$temp_rows="$brackets";
while($temp_rows > 1){
$rowcount++;
if($rowcount > 1){
$temp_rows=($temp_rows / 2);
}
$listrows.="-> $temp_rows";
$rows="$rowcount";
}
$rowwidths=round(100 / $rows - 0.5);
$actualrows=($rows * 2);
/*
//UNCOMMENT SECTION FOR DEBUGGING
echo"
[Bracket Stats]
Brackets: $brackets
Spots: $spots
Game Rows: $rows
Actual Rows: $actualrows
Row Widths: $rowwidths
Pattern: $listrows
";
*/
////////////////////////////////
echo"$config[header]";
?>
echo"$tinfo[name]"; ?> Brackets
$counter="$brackets";
while($counter > 1){
if($round){
$counter=($counter / 2);
}
$lastcb="$countbrackets";
$countbrackets="";
$game="";
$round++;
$finals=($rows - 1);
$winner=($rows);
$roundgamesay="Round $round Games";
if($round=="$winner"){
$roundgamesay="Winner!";
}
if($round=="$finals"){
$roundgamesay="Finals";
}
?>
echo"$roundgamesay"; ?>
$spacesetcount="";
while($countbrackets < $counter){
$countbrackets++;
$spot++;
$spacesetcount++;
if($spacesetcount=="4"){
$spacesetcount="";
}
$bracketid="$round"."_"."$countbrackets";
?>
| echo"$bracket[$bracketid]"; ?> |
|
if($countbrackets < $counter){
$spacecounter++;
$spacecounter=($spacecounter + 1);
if($spacecounter==2){
$roundx2p1=($lastroundx2p1 * 2 + 1);
if($round==1){
$roundx2p1="1";
}
while($countspaces < $roundx2p1){
$countspaces++;
$spacesetbgcolor="#$tinfo[tdcolor]";
if((!$spacesetcount)||($spacesetcount=="2")){
$spacesetbgcolor="";
}
$spacecentercount++;
$spacecenterword="";
$alignspacer1="left";
$spacecentercountcheck=($lastroundx2p1 + 1);
if($spacecentercount=="$spacecentercountcheck"){
$spacecenterwordcount++;
if(($spacecenterwordcount==1)||($spacecenterwordcount==3)){
$actualgamecount++;
$spacecenterword="Game $actualgamecount";
$alignspacer1="center";
if($spacecenterwordcount==3){
$spacecenterwordcount="";
$spacecenterwordcount++;
}
}
}
?>
| echo"$spacecenterword"; ?> |
|
}
$spacecounter="";
$countspaces="";
$spacecentercount="";
}
}
}
$spacecenterwordcount="";
$actualgamecount="";
$lastroundx2p1="$roundx2p1";
?>
|
}
?>
}
?>