battles/tournament.php

52 lines
1.6 KiB
PHP

<?php
session_start();
require_once "functions.php";
$user = $user ?? new \Battles\User($_SESSION['uid']);
$Tournament = new Tournament();
\Battles\Template::header('Турниры');
?>
<META HTTP-EQUIV="REFRESH" CONTENT="10">
<div style='color:#8F0000; font-weight:bold; font-size:16px; text-align:center; float:left;'>Турнирная</div>
<div style="float: right; padding-right: 6px;">
<input type="button" onclick="window.location='main.php?setch=1'" value="Вернуться">
</div>
<br>
<?php
if (!empty($_POST)) {
if ($_POST['newtournament']) {
$Tournament->CreateTournament("Еженедельные турниры");
}
if ($_POST['preptournament']) {
$Tournament->PrepearTournir();
}
if ($_POST['addzayvka']) {
$Tournament->AddUserInTournament($_POST['idtur']);
}
if ($_POST['dellzayvka']) {
$Tournament->DellUserInTournament($_POST['idtur']);
}
if ($_POST['expenemy']) {
$Tournament->expectationenemy((int)$_POST['expenemy']);
}
}
$dateD = mysql_fetch_row(mysql_query("select datetime from turnament where old=0 limit 1"));
if (mktime() >= ($dateD[0] + 10)) {
$Tournament->UpdateTournir();
}
$Tournament->showAllTurnament();
if (mktime() >= ($dateD[0] + 10)) {
$Tournament->StartTournir();
}
$Tournament->ShowTournirFinaliats();
?>
<form method="post">
<?php if ($user->admin) { ?>
<div>
<input type="submit" name="newtournament" value="Добавить новый турнир">
<input type="submit" name="preptournament" value="Приготовить турнир и запустить">
</div>
<?php } ?>
</form>