battles/tournament.php

61 lines
1.7 KiB
PHP
Raw Normal View History

<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$user = $user ?? null;
if ($user->battle) {
header('location: fbattle.php');
exit;
}
$Tournament = new Tournament();
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>