Starte Turnier
"; function L($str) { echo $str; ob_flush(); } // clear all tables except wm_stations L("Lösche Tabellen ...\n"); $tables = array("wm_bets", "wm_group_assoc", "wm_groups", "wm_locations", "wm_log", "wm_matches", "wm_survey", "wm_teams", "wm_users"); foreach ($tables as $table) { Query("DELETE FROM $table"); Query("ALTER TABLE $table AUTO_INCREMENT = 1"); } // fill wm_teams L("Erzeuge Mannschaften ...\n"); $q = "INSERT INTO wm_teams(id,valid,name,`group`) VALUES "; // base teams for ($i = 1; $i <= TeamCount; $i++) { $group = chr(65 + (($i - 1) / 4)); $q .= "($i,1,'" . DBEscape(stripslashes($_POST["team$i"])) . "','$group'),"; } Query(substr($q, 0, strlen($q) - 1)); $q = "INSERT INTO wm_teams(valid,name,`group`,refcode) VALUES "; // first/second of group for ($i = 0; $i < TeamCount; $i += 4) { $group = chr(65 + ($i / 4)); $q .= "(0,'Erster $group','$group',0),(0,'Zweiter $group','$group',0),"; } for ($i = 0; $i < $ExtraTeams; $i++) { $q .= "(0,'" . DBEscape(stripslashes($_POST["et$i"])) . "','X',0),"; } // final rounds $FMBase = TeamCount / 4 * 6; if (HaveRO16) { for ($i = 1; $i <= 8; $i++) { $q .= "(0,'Sieger AF$i','$i'," . ($FMBase + $i) . "),"; } $FMBase += 8; } for ($i = 1; $i <= 4; $i++) $q .= "(0,'Sieger VF$i','$i'," . ($FMBase + $i) . "),"; for ($i = 1; $i <= 2; $i++) $q .= "(0,'Sieger HF$i','$i'," . ($FMBase + 4 + $i) . "),"; for ($i = 1; $i <= 2; $i++) $q .= "(0,'Verlierer HF$i','$i'," . ($FMBase + 104 + $i) . "),"; Query(substr($q, 0, strlen($q) - 1)); // fill wm_matches L("Erzeuge Spiele ...\n"); $t = DBEscape(stripslashes($_POST["date"])) . " " . DBEscape(stripslashes($_POST["time"])) . ":00"; $q = "INSERT INTO wm_matches(teamA,teamB,time,location,station,class,number) VALUES "; for ($g = 1; $g <= TeamCount; $g += 4) { for ($i = 0; $i < 6; $i++) { $q .= "($g,$g,'$t',0,1,100," . ($i + 1) . "),"; } } if (HaveRO16) { for ($i = 1; $i <= 8; $i++) { $q .= "(" . (TeamCount + $i * 2 - 1) . "," . (TeamCount + $i * 2) . ",'$t',0,1,8,$i),"; } for ($i = 1; $i <= 4; $i++) { $q .= "(" . (TeamCount + $i * 2 + 15) . "," . (TeamCount + $i * 2 + 16) . ",'$t',0,1,4,$i),"; } $QFBase = TeamCount + 24; } else { for ($i = 1; $i <= 4; $i++) { $q .= "(" . (TeamCount + $i * 2 - 1) . "," . (TeamCount + $i * 2) . ",'$t',0,1,4,$i),"; } $QFBase = TeamCount + 8; } $q .= "(" . ($QFBase + 1) . "," . ($QFBase + 2) . ",'$t',0,1,2,1),"; $q .= "(" . ($QFBase + 3) . "," . ($QFBase + 4) . ",'$t',0,1,2,2),"; if ((MatchCount & 1) == 0) { $q .= "(" . ($QFBase + 7) . "," . ($QFBase + 8) . ",'$t',0,1,1,3),"; } $q .= "(" . ($QFBase + 5) . "," . ($QFBase + 6) . ",'$t',0,1,1,1)"; Query($q); // fill locations L("Erzeuge Spielorte ...\n"); $locs = array_filter(array_map('trim', explode("\n", stripslashes($_POST['locations']))), 'strlen'); if (count($locs)) { $q = "INSERT INTO wm_locations(name) VALUES "; foreach ($locs as $loc) { $q .= "('" . DBEscape($loc) . "'),"; } Query(substr($q, 0, strlen($q) - 1)); } else { L("WARNUNG: Keine Spielorte angegeben!\n"); } L("Fertig.\n"); echo ""; } else { ///////////////////////////////////////////////////////////////////// StartPage("Admin: Turnier starten"); echo "