<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; utils\csrf_protect(); $u = user\check_current(); $u->require_perm('admin'); utils\require_get_params(['club_id', 'season_id']); utils\require_post_params(['firstname', 'lastname', 'gender']); $season = Season::by_id($_GET['season_id']); $club = User::by_id($_GET['club_id']); $name = \sprintf('%s, %s', $_POST['lastname'], $_POST['firstname']); $textid = \str_replace(' ', '_', $club->name . '-' . $_POST['firstname'] . ' ' . $_POST['lastname']); try { $player = Player::create($season->id, $club->id, $textid, $name, $_POST['gender']); $player->save(); } catch (utils\DuplicateEntryException $e) { render_ajax_error(sprintf('Ein Spieler mit der Id "%s" existiert bereits', $textid)); exit; } render_ajax('season/' . $season->id . '/club/' . $club->id . '/', ['player' => $player]);
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; utils\csrf_protect(); $u = user\check_current(); $u->require_perm('admin'); utils\require_post_params(['name']); $textid = \preg_replace('/[^a-z]+/', '', strtolower($_POST['name'])); assert(\preg_match('/^[a-z]+$/', $textid)); try { $club = User::create($textid, $_POST['name'], null); $club->save(); } catch (utils\DuplicateEntryException $e) { render_ajax_error('Der Verein "' . $_POST['name'] . '" existiert bereits'); exit; } render_ajax('club/' . $club->id . '/', ['club' => $club]);
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; utils\csrf_protect(); $u = user\check_current(); $u->require_perm('admin'); utils\require_post_params(['name', 'season_id']); $season = Season::by_id($_POST['season_id']); try { $tournament = Tournament::create($season, $_POST['name']); $tournament->save(); } catch (utils\DuplicateEntryException $e) { render_ajax_error('Ein Turnier mit dem Namen "' . $_POST['name'] . '" existiert bereits'); exit; } render_ajax('t/' . $tournament->id . '/', ['season' => $season, 'tournament' => $tournament]);
$discipline = Discipline::by_id($_GET['discipline_id']); $tournament = $discipline->get_tournament(); $season = $tournament->get_season(); $player = null; $player_club = null; $partner = null; $partner_club = null; if (!empty($_POST['player'])) { $player = $season->get_player_by_input($_POST['player']); if (!empty($_POST['player_club'])) { $player_club = $season->get_club_by_input($_POST['player_club']); } } if (!empty($_POST['partner'])) { $partner = $season->get_player_by_input($_POST['partner']); if (!empty($_POST['partner_club'])) { $partner_club = $season->get_club_by_input($_POST['partner_club']); } } $email = isset($_POST['email']) ? $_POST['email'] : null; $seeding = isset($_POST['seeding']) ? $_POST['seeding'] : null; $memo = isset($_POST['memo']) ? $_POST['memo'] : null; try { $discipline->check_entry($player, $partner); } catch (utils\InvalidEntryException $iee) { render_ajax_error('Meldung kann nicht angenommen werden: ' . $iee->getMessage()); exit; } $entry = Entry::create($discipline, $player, $player_club, $partner, $partner_club, $email, $seeding, $memo); $entry->save(); render_ajax('d/' . $discipline->id . '/', ['entry' => $entry]);
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; $u = user\check_current(); $u->require_perm('admin'); utils\csrf_protect(); utils\require_post_params(['tournament_url']); if (!\preg_match('#^(https?://.*?/)[a-z]+(\\.aspx.*)$#', $_POST['tournament_url'], $m)) { render_ajax_error('Entschuldigung, die turnier-URL "' . $_POST['tournament_url'] . '" kann leider nicht bearbeitet werden.'); exit; } $base_url = $m[1]; $clubs_url = $base_url . 'clubs' . $m[2]; $clubs_content = \file_get_contents($clubs_url); if (!preg_match('#<div id="divTournamentHeader" class="header">\\s*<div class="title"><h3>(.*)</h3>#', $clubs_content, $m)) { throw new \Exception('Cannot find season name'); } $name = \html_entity_decode($m[1], ENT_QUOTES | ENT_HTML5, 'utf-8'); Model::beginTransaction(); $season = Season::fetch_optional('WHERE name=?', [$name]); if (!$season) { $season = Season::create($name, false, $_POST['tournament_url']); $season->save(); } $players = []; if (!\preg_match_all('#<td><a href="club\\.aspx(?P<club_path>\\?id=[^"]+)&club=(?P<club_num>[0-9]+)">(?P<name>[^<]+)</a></td><td class="right">(?P<id>[0-9-]+)</td>#', $clubs_content, $matches, PREG_SET_ORDER)) { throw new \Exception('Cannot find any club entries!'); } foreach ($matches as $m) {
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; utils\csrf_protect(); $u = user\check_current(); $u->require_perm('admin'); utils\require_get_params(['tournament_id']); utils\require_post_params(['name', 'dtype']); $tournament = Tournament::by_id($_GET['tournament_id']); if ($_POST['dtype'] == 'all') { $specs = [['name' => 'HE' . $_POST['name'], 'dtype' => 'MS'], ['name' => 'DE' . $_POST['name'], 'dtype' => 'WS'], ['name' => 'HD' . $_POST['name'], 'dtype' => 'MD'], ['name' => 'DD' . $_POST['name'], 'dtype' => 'WD'], ['name' => 'MX' . $_POST['name'], 'dtype' => 'MX']]; } else { $specs = [['name' => $_POST['name'], 'dtype' => $_POST['dtype']]]; } Model::beginTransaction(); foreach ($specs as $spec) { try { $discipline = Discipline::create($tournament, $spec['name'], $spec['dtype']); $discipline->save(); } catch (utils\DuplicateEntryException $e) { render_ajax_error(sprintf('Disziplin "%s" existiert bereits!', $spec['name'])); exit; } } Model::commit(); render_ajax('d/' . $discipline->id . '/', ['tournament' => $tournament, 'disciplines' => $disciplines]);
<?php namespace bmtmgr; require_once dirname(__DIR__) . '/src/common.php'; utils\csrf_protect(); $u = user\check_current(); $u->require_perm('admin'); utils\require_post_params(['name']); try { $season = Season::create($_POST['name'], false); $season->save(); } catch (utils\DuplicateEntryException $e) { render_ajax_error('Die Liga "' . $_POST['name'] . '" existiert bereits'); exit; } render_ajax('season/' . $season->id . '/', ['season' => $season]);