function content() { $event = NULL; if (isset($_GET['name'])) { $event = new Event($_GET['name']); eventForm($event); } elseif (strcmp($_POST['mode'], "Create New Event") == 0) { if (Player::getSessionPlayer()->isHost()) { if (isset($_POST['insert'])) { insertEvent(); eventList(); } else { eventForm(); } } else { authFailed(); } } elseif (strcmp($_GET['mode'], "create") == 0) { eventForm(); } elseif (isset($_POST['name'])) { $event = new Event($_POST['name']); if (!$event->authCheck($_SESSION['username'])) { authFailed(); } else { if (strcmp($_POST['mode'], "Parse DCI Files") == 0) { dciInput(); } elseif (strcmp($_POST['mode'], "Auto-Input Event Data") == 0) { autoInput(); } elseif (strcmp($_POST['mode'], "Update Registration") == 0) { updateReg(); } elseif (strcmp($_POST['mode'], "Update Match Listing") == 0) { updateMatches(); } elseif (strcmp($_POST['mode'], "Update Medals") == 0) { updateMedals(); } elseif (strcmp($_POST['mode'], "Upload Trophy") == 0) { if (insertTrophy()) { $event->hastrophy = 1; } } elseif (strcmp($_POST['mode'], "Update Event Info") == 0) { $event = updateEvent(); } eventForm($event); } } else { echo "<table style=\"border-width: 0px;\" align=\"center\">"; echo "<tr><td>"; echo "<form action=\"event.php\" method=\"post\">"; echo "<input type=\"submit\" name=\"mode\" value=\"Create New Event\">"; echo "</form></td><td>"; echo "<form action=\"format.php\" method=\"post\">"; echo "<input type=\"submit\" name=\"mode\" value=\"View/Add Formats\">"; echo "</form></td></tr>"; echo "</table><br><br>"; eventList($_POST['series'], $_POST['season']); } }
<?php # Upgrades the database. There are a couple of pretty crude checks for # versions 0 (no database) and 1 (no version table). Hopefully it will # work for you, but you can always just run the schema yourself. # # Use at your own risk! require '../lib.php'; # Need to be logged in as admin before you can even try this. session_start(); $some_admin = Player::getSessionPlayer(); if (!$some_admin->isSuper()) { header("Location: index.php"); exit(0); } $db = Database::getConnection(); function do_query($query) { global $db; echo "Executing Query: {$query} <br />"; $result = $db->query($query); if (!$result) { echo "!!!! - Error: "; echo $db->error; exit(0); } return $result; } function redirect_deck_update($latest_id = 0) { $url = explode('?', $_SERVER['REQUEST_URI']);
<?php session_start(); require_once 'lib.php'; $player = Player::getSessionPlayer(); print_header("Player Control Panel"); ?> <div class="grid_10 suffix_1 prefix_1"> <div id="gatherling_main" class="box"> <div class="uppertitle"> Player Control Panel </div> <?php if ($player == NULL) { echo "<center> You must <a href=\"login.php\">log in</a> to use your player control panel.</center>\n"; } else { // Handle actions if (isset($_POST['action'])) { if ($_POST['action'] == 'setIgnores') { setPlayerIgnores(); } else { if ($_POST['action'] == 'changePassword') { $success = false; if ($_POST['newPassword2'] == $_POST['newPassword']) { if (strlen($_POST['newPassword']) >= 6) { $authenticated = Player::checkPassword($_POST['username'], $_POST['oldPassword']); if ($authenticated) { $player = new Player($_POST['username']); $player->setPassword($_POST['newPassword']); $result = "Password changed."; $success = true; } else { $result = "Password *not* changed, your old password was incorrect!";
function handleActions() { global $hasError; global $errormsg; if (!isset($_POST['series'])) { return; } $seriesname = $_POST['series']; $series = new Series($seriesname); if (!$series) { return; } if (!$series->authCheck(Player::loginName())) { return; } if ($_POST['action'] == "Update Series") { $newactive = $_POST['isactive']; $newtime = $_POST['hour']; $newday = $_POST['start_day']; $prereg = 0; if (isset($_POST['preregdefault'])) { $prereg = $_POST['preregdefault']; } $series = new Series($seriesname); if ($series->authCheck(Player::loginName())) { $series->active = $newactive; $series->start_time = $newtime . ":00:00"; $series->start_day = $newday; $series->prereg_default = $prereg; $series->save(); } } else { if ($_POST['action'] == "Change Logo") { if ($_FILES['logo']['size'] > 0) { $file = $_FILES['logo']; $name = $file['name']; $tmp = $file['tmp_name']; $size = $file['size']; $type = $file['type']; $series->setLogo($tmp, $type, $size); } } else { if ($_POST['action'] == "Update Organizers") { if (isset($_POST['delstewards'])) { $removals = $_POST['delstewards']; foreach ($removals as $deadsteward) { $series->removeSteward($deadsteward); } } if (!isset($_POST['addsteward'])) { return; } $addition = $_POST['addsteward']; $addplayer = Player::findByName($addition); if ($addplayer == NULL) { $hasError = true; $errormsg .= "Can't add {$addition} to stewards, they don't exist!"; return; } if ($addplayer->verified == 0 && Player::getSessionPlayer()->super == 0) { $hasError = true; $errormsg .= "Can't add {$addplayer->name} to stewards, they aren't a verified user!"; return; } $series->addSteward($addplayer->name); } else { if ($_POST['action'] == "Update Points Rules") { $new_rules = $_POST['new_rules']; $series->setSeasonRules($_POST['season'], $new_rules); } } } } }
function print_header($title, $js = null, $extra_head_content = "") { global $CONFIG; echo "<html><head><meta http-equiv=\"X-UA-Compatible\" content=\"IE=8\" />"; echo "<title>{$CONFIG['site_name']} | Gatherling | {$title}</title>"; echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"" . theme_file("css/stylesheet.css") . "\" />"; echo "<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js\"></script>\n"; if ($js) { echo "<script type=\"text/javascript\">"; echo $js; echo "</script>"; } echo $extra_head_content; echo <<<EOT </head> <body> <div id="maincontainer" class="container_12"> <div id="headerimage" class="grid_12"> EOT; echo image_tag("header.png"); echo <<<EOT </div> <div id="mainmenu_submenu" class="grid_12"> <ul> <li><a href="http://pdcmagic.com/">Home</a></li> <li><a href="http://forums.pdcmagic.com/">Forums</a></li> <li><a href="http://pdcmagic.com/articles/">Articles</a></li> <li><a href="series.php">Events</a></li> <li class="current"> <a href="index.php"> Gatherling </a> </li> <li><a href="ratings.php">Ratings</a></li> <li class="last"><a href="http://community.wizards.com/pauperonline/wiki/">Wiki</a></li> </ul> </div> EOT; $player = Player::getSessionPlayer(); $super = false; $host = false; $steward = false; if ($player != NULL) { $host = $player->isHost(); $super = $player->isSuper(); $steward = count($player->stewardsSeries()) > 0; } $tabs = 5; if ($super || $steward) { $tabs += 1; } if ($host) { $tabs += 1; } if ($super) { $tabs += 1; } echo <<<EOT <div id="submenu" class="grid_12 tabs_{$tabs}"> <ul> <li><a href="profile.php">Profile</a></li> <li><a href="player.php">Player CP</a></li> <li><a href="eventreport.php">Metagame</a></li> <li><a href="decksearch.php">Decks</a></li> EOT; if ($host || $super) { echo "<li><a href=\"event.php\">Host CP</a></li>\n"; } if ($steward || $super) { echo "<li><a href=\"seriescp.php\">Series CP</a></li>\n"; } if ($super) { echo "<li><a href=\"admincp.php\">Admin CP</a></li>\n"; } if ($player == NULL) { echo "<li class=\"last\"><a href=\"login.php\">Login</a></li>\n"; } else { echo "<li class=\"last\"><a href=\"logout.php\">Logout [{$player->name}]</a></li>\n"; } echo "</ul> </div>\n"; }
function eventForm($event = NULL, $forcenew = false) { if ($forcenew) { $edit = 0; } else { $edit = $event != NULL; } if (is_null($event)) { $event = new Event(""); } echo "<form action=\"event.php\" method=\"post\" "; echo "enctype=\"multipart/form-data\">"; echo "<table class=\"form\" style=\"border-width: 0px\" align=\"center\">"; $current_year = strftime('%Y', time()); if ($event->start != NULL) { $date = $event->start; preg_match('/([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):.*/', $date, $datearr); $year = $datearr[1]; $month = $datearr[2]; $day = $datearr[3]; $hour = $datearr[4]; $minutes = $datearr[5]; echo "<tr><th>Currently Editing</th>"; echo "<td><i>" . htmlentities($event->name) . "</i>"; echo "<input type=\"hidden\" name=\"name\" value=\"" . htmlentities($event->name) . "\">"; echo "</td>"; echo "</tr><tr><td> </td><td>"; $prevevent = $event->findPrev(); if ($prevevent) { echo $prevevent->makeLink("« Previous"); } $nextevent = $event->findNext(); if ($nextevent) { if ($prevevent) { echo " | "; } echo $nextevent->makeLink("Next »"); } echo "</td></tr>"; } else { echo "<tr><th>Event Name</th>"; echo "<td><input type=\"radio\" name=\"naming\" value=\"auto\" checked>"; echo "Automatically name this event based on Series, Season, and Number."; echo "<br /><input type=\"radio\" name=\"naming\" value=\"custom\">"; echo "Use a custom name: "; echo "<input type=\"text\" name=\"name\" value=\"" . htmlentities($event->name) . "\" "; echo "size=\"40\">"; echo "</td></tr>"; $year = strftime('%Y', time()); $month = strftime('%B', time()); $day = strftime('%e', time()); $hour = strftime('%H', time()); $minutes = strftime('%M', time()); } echo "<tr><th>Date & Time</th><td>"; numDropMenu("year", "- Year -", $current_year + 1, $year, 2005); monthDropMenu($month); numDropMenu("day", "- Day- ", 31, $day, 1); timeDropMenu($hour, $minutes); echo "</td></tr>"; echo "<tr><th>Series</th><td>"; $seriesList = Player::getSessionPlayer()->stewardsSeries(); $seriesList[] = "Other"; Series::dropMenu($event->series, 0, $seriesList); echo "</td></tr>"; echo "<tr><th>Season</th><td>"; seasonDropMenu($event->season); echo "</td></tr>"; echo "<tr><th>Number</th><td>"; numDropMenu("number", "- Event Number -", Event::largestEventNum() + 5, $event->number, 0, "Custom"); echo "</td><tr>"; echo "<tr><th>Format</th><td>"; formatDropMenu($event->format); echo "</td></tr>"; echo "<tr><th>K-Value</th><td>"; kValueDropMenu($event->kvalue); echo "</td></tr>"; echo "<tr><th>Host/Cohost</th><td>"; stringField("host", $event->host, 20); echo " / "; stringField("cohost", $event->cohost, 20); echo "</td></tr>"; echo "<tr><th>Event Thread URL</th><td>"; stringField("threadurl", $event->threadurl, 60); echo "</td></tr>"; echo "<tr><th>Metagame URL</th><td>"; stringField("metaurl", $event->metaurl, 60); echo "</td></tr>"; echo "<tr><th>Report URL</th><td>"; stringField("reporturl", $event->reporturl, 60); echo "</td></tr>"; echo "<tr><th>Main Event Structure</th><td>"; numDropMenu("mainrounds", "- No. of Rounds -", 10, $event->mainrounds, 1); echo " rounds of "; structDropMenu("mainstruct", $event->mainstruct); echo "</td></tr>"; echo "<tr><th>Finals Structure</th><td>"; numDropMenu("finalrounds", "- No. of Rounds -", 10, $event->finalrounds, 0); echo " rounds of "; structDropMenu("finalstruct", $event->finalstruct); echo "</td></tr>"; echo "<tr><th>Allow Pre-Registration</th>"; echo "<td><input type=\"checkbox\" name=\"prereg_allowed\" value=\"1\" "; if ($event->prereg_allowed == 1) { echo "checked=\"yes\" "; } echo "/></td></tr>"; echo "<tr><th>Players Can Report Results</th>"; echo "<td><input type=\"checkbox\" name=\"player_reportable\" value=\"1\" "; if ($event->player_reportable == 1) { echo "checked=\"yes\" "; } echo "/></td></tr>"; if ($edit == 0) { echo "<tr><td> </td></tr>"; echo "<tr><td colspan=\"2\" class=\"buttons\">"; echo "<input type=\"submit\" name=\"mode\" value=\"Create New Event\">"; echo "<input type=\"hidden\" name=\"insert\" value=\"1\">"; echo "</td></tr>"; } else { echo "<tr><th>Players Can Update Decks</th>"; echo "<td><input type=\"checkbox\" name=\"player_editdecks\" value=\"1\" "; if ($event->player_editdecks == 1) { echo "checked=\"yes\" "; } echo "/></td></tr>"; echo "<tr><th>Finalize Event</th>"; echo "<td><input type=\"checkbox\" name=\"finalized\" value=\"1\" "; if ($event->finalized == 1) { echo "checked=\"yes\" "; } echo "/></td></tr>"; trophyField($event); echo "<tr><td> </td></tr>"; echo "<tr><td colspan=\"2\" class=\"buttons\">"; echo " <input type=\"submit\" name=\"mode\" value=\"Update Event Info\" />"; $nexteventname = sprintf("%s %d.%02d", $event->series, $event->season, $event->number + 1); if (!Event::exists($nexteventname)) { echo " <input type=\"submit\" name=\"mode\" value=\"Create Next Event\" />"; } echo "<input type=\"hidden\" name=\"update\" value=\"1\" />"; echo "</td></tr>"; echo "</table>"; echo "</form>"; echo "<table style=\"border-width: 0px\" align=\"center\">"; $view = "reg"; $view = isset($_GET['view']) ? $_GET['view'] : $view; $view = isset($_POST['view']) ? $_POST['view'] : $view; echo "<tr><td colspan=\"2\"> </td></tr>"; controlPanel($event, $view); echo "<tr><td colspan=\"2\"> </td></tr>"; echo "</table>"; if (strcmp($view, "reg") == 0) { playerList($event); } elseif (strcmp($view, "match") == 0) { matchList($event); } elseif (strcmp($view, "standings") == 0) { standingsList($event); } elseif (strcmp($view, "medal") == 0) { medalList($event); } elseif (strcmp($view, "autoinput") == 0) { autoInputForm($event); } elseif (strcmp($view, "fileinput") == 0) { fileInputForm($event); file3InputForm($event); } elseif (strcmp($view, "points_adj") == 0) { pointsAdjustmentForm($event); } } echo "</table>"; }
<?php session_start(); include 'lib.php'; include 'lib_form_helper.php'; $hasError = false; $errormsg = ""; if (!Player::isLoggedIn() || !Player::getSessionPlayer()->isSuper()) { redirect("Location: index.php"); } print_header("Admin Control Panel"); ?> <div class="grid_10 suffix_1 prefix_1"> <div id="gatherling_main" class="box"> <div class="uppertitle"> Admin Control Panel </div> <center> <?php do_page(); ?> </center> <div class="clear"></div> </div></div> <?php print_footer(); ?> <?php function do_page() {