$content_tpl->parse("H_WB_PLAYER1", "B_WB_PLAYER1", true); } } if ($season['double_elimination'] != "") { $content_tpl->set_var("I_ID_SEASON", $season['id']); $content_tpl->parse("H_WB_DOUBLE_ELIMINATION", "B_WB_DOUBLE_ELIMINATION"); } else { $content_tpl->set_var("I_ID_SEASON", $season['id']); $content_tpl->parse("H_WB_SINGLE_ELIMINATION", "B_WB_SINGLE_ELIMINATION"); } $content_tpl->parse("H_WINNERS_BRACKET", "B_WINNERS_BRACKET"); $content_tpl->parse("H_RESULTS", "B_RESULTS"); } elseif ($_REQUEST['opt'] == "lb" and $season['double_elimination'] != "") { // LB // Set the lb_round names $num_lb_rounds = getNumLBRounds($season); for ($i = 0; $i <= $num_lb_rounds; ++$i) { $counter_lb_player[$i] = 0; $counter_lb_match[$i] = 1; $content_tpl->set_var("I_ROUND", $i + 1); // Deadline $content_tpl->set_var("H_LB_ACTUAL_ROUND", ""); $content_tpl->set_var("H_LB_DEADLINE", ""); $lb_round = $i + 1; $deadline_ref = dbQuery("SELECT * FROM `{$cfg['db_table_prefix']}deadlines` " . "WHERE `id_season` = {$season['id']} AND `round` = 'lb{$lb_round}'"); if ($deadline_row = dbFetch($deadline_ref)) { if (isAfterPreDeadline($season, "lb", $i + 1) and isBeforePostDeadline($season, "lb", $i + 1)) { $content_tpl->parse("H_LB_ACTUAL_ROUND", "B_LB_ACTUAL_ROUND"); } $content_tpl->set_var("I_DEADLINE", htmlspecialchars($deadline_row['deadline'])); $content_tpl->parse("H_LB_DEADLINE", "B_LB_DEADLINE");
dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('q1', '{$deadline}', {$season['id']})"); } // Wb dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('wb0', '{$deadline}', {$season['id']})"); for ($i = 1; $i <= getNumWBRounds($season); $i++) { $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length']); dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('wb{$i}', '{$deadline}', {$season['id']})"); if ($i == getNumWBRounds($season) - getNumLBRounds($season) / 2) { $lb_startdate = $deadline; } } // Lb if ($season['double_elimination'] != "") { $deadline = $lb_startdate; dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('lb0', '{$deadline}', {$season['id']})"); for ($i = 1; $i <= getNumLBRounds($season); $i++) { if ($i == 1) { $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length']); } elseif (1 & $i) { $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length'] - $_REQUEST['lb_round_length']); } else { $deadline = addDaysToDate($deadline, $_REQUEST['lb_round_length']); } dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('lb{$i}', '{$deadline}', {$season['id']})"); } // Gf dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('gf0', '{$deadline}', {$season['id']})"); $deadline = addDaysToDate($deadline, $_REQUEST['wb_round_length'] - $_REQUEST['lb_round_length']); dbQuery("INSERT INTO `{$cfg['db_table_prefix']}deadlines` (`round`, `deadline`, `id_season`) " . "VALUES ('gf1', '{$deadline}', {$season['id']})"); } $content_tpl->parse("H_MESSAGE_DEADLINES_SETUP", "B_MESSAGE_DEADLINES_SETUP");
function getNextWinnerPlayer(&$match) { global $season; if ($match['bracket'] == "q") { return "player2"; } elseif ($match['bracket'] == "wb" and $match['round'] < getNumWBRounds($season)) { if (1 & $match['match']) { return "player1"; } else { return "player2"; } } elseif ($match['bracket'] == "wb" and $match['round'] == getNumWBRounds($season) and $season['double_elimination'] != "") { return "player1"; } elseif ($match['bracket'] == "lb" and $match['round'] < getNumLBRounds($season)) { if (1 & $match['round']) { return "player2"; } else { if (1 & $match['match']) { return "player1"; } else { return "player2"; } } } elseif ($match['bracket'] == "lb" and $match['round'] == getNumLBRounds($season)) { return "player2"; } elseif ($match['bracket'] == "gf" and $match['id_player2'] == winnerOf($match)) { return "player2"; } }