Server IP : 149.202.105.228 / Your IP : 216.73.216.18 Web Server : Apache System : Linux webm129.cluster030.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64 User : atfycaf ( 116275) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/atfycaf/www/admin/ |
Upload File : |
<?php $thisCheckID = 5; include "globalVars.php"; if (!isset($_POST["tournID"])) { header("Location:/admin/knockoutEdit.html"); } else { $tournamentID = $_POST["tournID"]; } $tournamentBasicsQuery = mysqli_query($conn, "SELECT pageURL, tournTitle, tournType, tournStartDate, tournLocation FROM knockoutConfig WHERE id = '$tournamentID'"); while ($sQ = mysqli_fetch_array($tournamentBasicsQuery)) { $tournURL = $sQ["pageURL"]; $tournType = $sQ["tournType"]; $tournTitle = $sQ["tournTitle"]; $tournStartDate = $sQ["tournStartDate"]; $tStartMonth = date("F", strtotime($tournStartDate)); $tStartYear = date("Y", strtotime($tournStartDate)); $tournLocation = $sQ["tournLocation"]; } if (trim($tournTitle) == "") { $tournTitle = "$tournLocation $tStartMonth $tStartYear"; } $tournTypeURLQuery = mysqli_query($conn, "SELECT pageURL FROM knockoutGroups WHERE id = '$tournType'"); while ($tTQ = mysqli_fetch_array($tournTypeURLQuery)) { $tournTypeURL = $tTQ["pageURL"]; } include "header.php"; ?> <h2>Update the <?php echo $tournTitle ?> Tournament - Details</h2> <div class="formContainer"> <div class="functionButtons"> <form action="knockoutEdit-1.html" method="post"> <input type="hidden" name="tournID" value="<?php echo $tournamentID ?>" /> <input type="submit" class="functionSelected" name="getLeague" value="Tournament Details" /> </form> <form action="knockoutEdit-2.html" method="post"> <input type="hidden" name="tournID" value="<?php echo $tournamentID ?>" /> <input type="submit" name="getLeague" value="Page Content" /> </form> </div> </div> <?php if (isset($_POST["updateTourney"])) { $tournType = cleanPost($_POST["tournType"], $conn); $tournTitle = cleanPost($_POST["tournTitle"], $conn); $tournStartDate = cleanPost($_POST["tournStartDate"], $conn); list($startDay, $startMonth, $startYear) = explode("/", $tournStartDate); $tournStartDate = $startYear ."-". $startMonth ."-". $startDay; $tournEndDate = cleanPost($_POST["tournEndDate"], $conn); list($endDay, $endMonth, $endYear) = explode("/", $tournEndDate); $tournEndDate = $endYear ."-". $endMonth ."-". $endDay; $tournLocation = cleanPost($_POST["tournLocation"], $conn); $tStartMonth = date("F", strtotime($tournStartDate)); if ($_POST["customRules"] == 1) { $additonalRules = $_POST["additonalRules"]; } else { $additonalRules = ""; } if (isset($_POST["showScores"])) { $showScores = 1; } else { $showScores = 0; } mysqli_query($conn, "UPDATE knockoutConfig SET tournType = '$tournType', tournTitle = '". addslashes($tournTitle) ."', tournStartDate = '$tournStartDate', tournEndDate = '$tournEndDate', tournLocation = '". addslashes($tournLocation) ."', showScores = '$showScores', customRules = '". addslashes($additonalRules) ."' WHERE id = '$tournamentID'"); $trackDate = date("Y-m-d H:i:s"); $trackTitle = "$tournLocation $tStartMonth $tStartYear"; mysqli_query($conn, "INSERT INTO userActions (dateCreated, adminID, pageTracking, databaseUpdated, updateDetails) VALUES ('$trackDate', '$adminID', 'admin/knockoutEdit-1.html', 'knockoutConfig', 'The User ". addslashes($adminName) ." <$adminEmail> updated the details of the knockout tournament ID: $tournamentID (". addslashes($trackTitle) .")')"); if (isset($_POST["playerNames"])) { $playersArray = $_POST["playerNames"]; $scoresArray = $_POST["playerScore"]; $matchDatesArray = $_POST["roundDate"]; foreach($playersArray as $round => $roundMatch) { mysqli_query($conn, "DELETE FROM knockoutRounds WHERE tournID = '$tournamentID' AND (roundID = '$round') AND (matchNo = '0')"); foreach($roundMatch as $matchNo => $roundPlayers) { if ($matchNo == 9999) { // $roundDate = "0000-00-00 00:00:00"; } else { $roundDate = date("Y-m-d H:i:s", strtotime($matchDatesArray[$round][$matchNo][0])); } if ($matchNo != 9999) { $updateOrInsertQuery = mysqli_query($conn, "SELECT id FROM knockoutRounds WHERE tournID = '$tournamentID' AND (roundID = '$round') AND (matchNo = '$matchNo') ORDER BY id ASC"); $updateOrInsert = mysqli_num_rows($updateOrInsertQuery); if ($updateOrInsert > 0) { $updateIDs = array(); while ($uIQ = mysqli_fetch_array($updateOrInsertQuery)) { $updateIDs[] = $uIQ["id"]; } } if ( (isset($roundPlayers[0])) && (trim($roundPlayers[0]) != "") ) { $thisScore = $scoresArray[$round][$matchNo][0]; if (strtoupper($thisScore) == "W" || strtoupper($thisScore) == "WD") { $thisScore = 999999; } elseif (strtoupper($thisScore) == "B" || strtoupper($thisScore) == "BY" || strtoupper($thisScore) == "BYE") { $thisScore = 9999; } elseif ( ($thisScore == 0 || trim($thisScore) == "") && ($scoresArray[$round][$matchNo][1] == 0 || trim($scoresArray[$round][$matchNo][1]) == "") ) { $thisScore = -1; } if ($updateOrInsert > 0) { if (array_key_exists(0, $updateIDs)) { if (trim($roundPlayers[0]) != "") { // echo "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[0]) ."', matchScore = '". $thisScore ."' WHERE id = '". $updateIDs[0] ."'<br>"; mysqli_query($conn, "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[0]) ."', matchScore = '". $thisScore ."' WHERE id = '". $updateIDs[0] ."'"); } } } else { if (array_key_exists(1, $roundPlayers)) { if (trim($roundPlayers[0]) != "") { // echo "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '$matchNo', '". addslashes($roundPlayers[0]) ."', '". $thisScore ."')<br>"; mysqli_query($conn, "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '$matchNo', '". addslashes($roundPlayers[0]) ."', '". $thisScore ."')"); } } } } if ( (isset($roundPlayers[1])) && (trim($roundPlayers[1]) != "") ) { $thisAScore = $scoresArray[$round][$matchNo][1]; if (strtoupper($thisAScore) == "W" || strtoupper($thisAScore) == "WD") { $thisAScore = 999999; } elseif (strtoupper($thisAScore) == "B" || strtoupper($thisAScore) == "BY" || strtoupper($thisAScore) == "BYE") { $thisAScore = 9999; } elseif ( ($scoresArray[$round][$matchNo][0] == 0 || trim($scoresArray[$round][$matchNo][0]) == "") && ($thisAScore == 0 || trim($thisAScore) == "") ) { $thisAScore = -1; } if ($updateOrInsert > 0) { if (array_key_exists(1, $updateIDs)) { if (trim($updateIDs[1]) != "") { // echo "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[1] ."'<br>"; mysqli_query($conn, "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[1] ."'"); } } elseif (trim($roundPlayers[0]) == "") { if (array_key_exists(0, $updateIDs)) { if (trim($updateIDs[0]) != "") { // echo "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[0] ."'<br>"; mysqli_query($conn, "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[0] ."'"); } else { // echo "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[1] ."'<br>"; mysqli_query($conn, "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[1] ."'"); } } else { // echo "KEY 0 DOES NOT EXIST<br>"; } } else { // echo "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '$matchNo', '". addslashes($roundPlayers[1]) ."', '". $thisAScore ."')<br>"; mysqli_query($conn, "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '$matchNo', '". addslashes($roundPlayers[1]) ."', '". $thisAScore ."')"); } } else { if (array_key_exists(1, $roundPlayers)) { if (trim($roundPlayers[1]) != "") { // echo "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '$matchNo', '". addslashes($roundPlayers[1]) ."', '". $thisAScore ."')<br>"; mysqli_query($conn, "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '$matchNo', '". addslashes($roundPlayers[1]) ."', '". $thisAScore ."')"); } } elseif (trim($roundPlayers[0]) != "") { if (array_key_exists(0, $updateIDs)) { if (trim($updateIDs[0]) != "") { // echo "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[1] ."'<br>"; mysqli_query($conn, "UPDATE knockoutRounds SET roundDate = '$roundDate', participantName = '". addslashes($roundPlayers[1]) ."', matchScore = '". $thisAScore ."' WHERE id = '". $updateIDs[1] ."'"); } } } } } } else { ///// TIE NOT YET DRAWN \\\\\ foreach($roundPlayers as $undrawnPlayer) { echo "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '0', '". addslashes($undrawnPlayer) ."', '0')<br>"; // mysqli_query($conn, "INSERT INTO knockoutRounds (tournID, roundID, roundDate, matchNo, participantName, matchScore) VALUES ('$tournamentID', '$round', '$roundDate', '0', '". addslashes($undrawnPlayer) ."', '-1')"); } } } } } echo "<p>The $tournTitle Tournament has been successfully updated.</p>"; } if (isset($_POST["tournID"])) { $tournamentQuery = mysqli_query($conn, "SELECT * FROM knockoutConfig WHERE id = '$tournamentID'"); while ($tQ = mysqli_fetch_array($tournamentQuery)) { $tournType = $tQ["tournType"]; $tournTitle = $tQ["tournTitle"]; $tournStartDate = date("d/m/Y", strtotime($tQ["tournStartDate"])); $tournEndDate = date("d/m/Y", strtotime($tQ["tournEndDate"])); $tournLocation = $tQ["tournLocation"]; $noCompetitors = $tQ["noCompetitors"]; $hasPrelims = $tQ["hasPrelims"]; $showScores = $tQ["showScores"]; $customRules = $tQ["customRules"]; $photoGallery = $tQ["photoGallery"]; } $playerNames = array(); $playerScores = array(); $roundDates = array(); $p = 0; $tournamentResultsQuery = mysqli_query($conn, "SELECT * FROM knockoutRounds WHERE tournID = '$tournamentID' ORDER BY id ASC"); while ($tRQ = mysqli_fetch_array($tournamentResultsQuery)) { $matchNo = $tRQ["matchNo"]; $roundDates[$tRQ["roundID"]][$matchNo] = $tRQ["roundDate"]; if ($matchNo == 0) { $playerNames[$tRQ["roundID"]][$tRQ["matchNo"]][$p] = $tRQ["participantName"]; $playerScores[$tRQ["roundID"]][$tRQ["matchNo"]][$p] = $tRQ["matchScore"]; $p++; } else { $playerNames[$tRQ["roundID"]][$tRQ["matchNo"]][$p] = $tRQ["participantName"]; $playerScores[$tRQ["roundID"]][$tRQ["matchNo"]][$p] = $tRQ["matchScore"]; if ($p == 1) { $p = 0; } else { $p = 1; } } } if (trim($photoGallery) == 0) { $hasGalleryQuery = mysqli_query($conn, "SELECT id FROM photoGalleryCats WHERE tournLeague = '1' AND (compID = '$tournamentID')"); if (mysqli_num_rows($hasGalleryQuery) == 0) { $photoGallery = 0; } else { while ($hGQ = mysqli_fetch_array($hasGalleryQuery)) { $photoGallery = $hGQ["id"]; } } } ?> <form action="knockoutEdit-1.html" method="post"> <input type="hidden" name="tournID" id="tournID" value="<?php echo $tournamentID ?>"> <div class="descStTab"> <div class="pFormRow"> <div class="pFormTitle">Knockout Group:</div> <div class="pFormSelect"> <select name="tournType" id="tournType"> <?php $groupQuery = mysqli_query($conn, "SELECT * FROM knockoutGroups ORDER BY id ASC"); while ($gQ = mysqli_fetch_array($groupQuery)) { $groupID = $gQ["id"]; $groupName = $gQ["groupTitle"]; ?> <option value="<?php echo $groupID ?>"<?php if ($groupID == $tournType) {?> selected<?php } ?>><?php echo $groupName ?></option> <?php } ?> </select> <div class="pFormLabel"> <label class="labelName">Knockout Group:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Custom Tournament Rules?:</div> <div class="pFormSelect"> <select name="customRules" id="customRules"> <option value="0"<?php if (trim($customRules) == "") {?> selected<?php } ?>>No, Standard tournament rules</option> <option value="1"<?php if (trim($customRules) != "") {?> selected<?php } ?>>Yes</option> </select> <div class="pFormLabel"> <label class="labelName">Custom Tournament Rules?:</label> </div> </div> </div> <div class="pFormRow" id="addRules"<?php if (trim($customRules) != "") {?> style="display:block"<?php } ?>> <div class="pFormRow pFormTxtRow"> <div class="pFormTitle">Custom Rules:</div> <div id="additonalRules" class="tinyTxtEditor"><?php echo $customRules ?></div> <div class="pFormLabel"> <label class="labelName">Custom Rules:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Tournament Start Date</div> <div class="pFormInput"> <input type="text" name="tournStartDate" id="tournStartDate" size="50" required value="<?php echo $tournStartDate ?>" /> <div class="pFormLabel"> <label class="labelName">Tournament Start Date:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Tournament Final Date</div> <div class="pFormInput"> <input type="text" name="tournEndDate" id="tournEndDate" size="50" required value="<?php echo $tournEndDate ?>" /> <div class="pFormLabel"> <label class="labelName">Tournament Final Date:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Tournament Name:</div> <div class="pFormInput"> <input type="text" name="tournTitle" size="50" value="<?php echo $tournTitle ?>" /> <div class="pFormLabel"> <label class="labelName">Tournament Name:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Tournament Location:</div> <div class="pFormInput"> <input type="text" name="tournLocation" size="50" required value="<?php echo $tournLocation ?>" /> <div class="pFormLabel"> <label class="labelName">Tournament Location:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Nº of Participants:</div> <div class="pFormInput"> <input type="number" name="noCompetitors" id="noCompetitors" min="2" step="1" value="<?php echo $noCompetitors ?>" readonly> <div class="pFormLabel"> <label class="labelName">Nº of Participants:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Has Preliminary Rounds?:</div> <div class="pFormFilterInput"> <input type="checkbox" name="hasPreliminary" id="hasPreliminary" value="1"<?php if ($hasPrelims == 1) {?> checked<?php } ?>> <div class="pFormLabel"> <label class="labelName">Has Preliminary Rounds?:</label> </div> </div> </div> <div class="pFormRow"> <div class="pFormTitle">Show Scores on the website?:</div> <div class="pFormFilterInput"> <input type="checkbox" name="showScores" value="1"<?php if ($showScores == 1) {?> checked<?php } ?>> <div class="pFormLabel"> <label class="labelName">Show Scores on the website?:</label> </div> </div> </div> <div class="pFormRow"> <?php if ($photoGallery == 0) { if (in_array(34, $adminPriv)) { ?> <button type="button" class="submitButton galleryBtn" id="photoGallery" data-gid="<?php echo $photoGallery ?>">Create a Photo Gallery for this tournament</button> <?php } } else { if (in_array(35, $adminPriv)) { ?> <button type="button" class="submitButton galleryBtn" id="photoGalleryU" data-gid="<?php echo $photoGallery ?>">Update the Photo Gallery for this tournament</button> <?php } } ?> </div> </div> <a href="/pdf/<?php echo $tournTypeURL ?>-<?php echo $tournURL ?>-tournament-fixtures.pdf" class="submitButton" target="_blank">Print Fixtures</a> <div class="descStTab" id="competitorDisplay"> <?php $htmlTemplate = "knockout-"; $fixturesCSS = "knockout"; if ($hasPrelims == 1) { $htmlTemplate .= "pre-"; $fixturesCSS .= "Pre"; } if ($noCompetitors <= 4) { $htmlTemplate .= "4"; $fixturesCSS .= "4"; if ($hasPrelims == 1) { $roundsArray = array(0 => 2, 1 => 2, 2 => 1); } else { $roundsArray = array(1 => 2, 2 => 1); } } elseif ($noCompetitors <= 8) { $htmlTemplate .= "8"; $fixturesCSS .= "8"; if ($hasPrelims == 1) { $roundsArray = array(0 => 4, 1 => 4, 2 => 2, 3 => 1); } else { $roundsArray = array(1 => 4, 2 => 2, 3 => 1); } } elseif ($noCompetitors <= 16) { $htmlTemplate .= "16"; $fixturesCSS .= "16"; if ($hasPrelims == 1) { $roundsArray = array(0 => 8, 1 => 8, 2 => 4, 3 => 2, 4 => 1); } else { $roundsArray = array(1 => 8, 2 => 4, 3 => 2, 4 => 1); } } elseif ($noCompetitors <= 32) { $htmlTemplate .= "32"; $fixturesCSS .= "32"; if ($hasPrelims == 1) { $roundsArray = array(0 => 16, 1 => 16, 2 => 8, 3 => 4, 4 => 2, 5 => 1); } else { $roundsArray = array(1 => 16, 2 => 8, 3 => 4, 4 => 2, 5 => 1); } } elseif ($noCompetitors <= 64) { $htmlTemplate .= "64"; $fixturesCSS .= "64"; if ($hasPrelims == 1) { $roundsArray = array(0 => 32, 1 => 32, 2 => 16, 3 => 8, 4 => 4, 5 => 2, 6 => 1); } else { $roundsArray = array(1 => 32, 2 => 16, 3 => 8, 4 => 4, 5 => 2, 6 => 1); } } $rawTemplate = file_get_contents($SERVER_ROOT ."/". $htmlTemplate .".html"); foreach($roundsArray as $roundID => $noMatches) { for ($m = 1; $m <= $noMatches; $m++) { $replaceTD = "[[ROUND_". $roundID ."_". $m ."]]"; if (isset($playerNames[$roundID][$m][0])) { $playerName = $playerNames[$roundID][$m][0]; $playerScore = $playerScores[$roundID][$m][0]; } else { $playerName = ""; $playerScore = ""; } if (isset($playerNames[$roundID][$m][1])) { $opponentName = $playerNames[$roundID][$m][1]; $opponentScore = $playerScores[$roundID][$m][1]; } else { $opponentName = ""; $opponentScore = ""; } if (isset($roundDates[$roundID][$m])) { $roundDate = $roundDates[$roundID][$m]; } else { $roundDate = ""; } if ($playerScore == -1) { $playerScore = ""; } if ($opponentScore == -1) { $opponentScore = ""; } $matchReplace = '<span class="fixtureDateTime"><label>Date:</label><input type="datetime-local" class="roundDate" name="roundDate['. $roundID .']['. $m .'][]" value="'. $roundDate .'"></span> <input type="text" id="player_'. $roundID .'_'. $m .'_1" class="playerName" name="playerNames['. $roundID .']['. $m .'][]" size="50" placeholder="Player Name" value="'. $playerName .'" /> <input type="text" class="scoreInput" name="playerScore['. $roundID .']['. $m .'][]" size="50" placeholder="Score" data-m="'. $m .'" data-r="'. $roundID .'" value="'. $playerScore .'" /> <input type="text" id="player_'. $roundID .'_'. $m .'_2" class="playerName" name="playerNames['. $roundID .']['. $m .'][]" size="50" placeholder="Player Name" value="'. $opponentName .'" /> <input type="text" class="scoreInput" name="playerScore['. $roundID .']['. $m .'][]" size="50" placeholder="Score" data-m="'. $m .'" data-r="'. $roundID .'" value="'. $opponentScore .'" />'; $rawTemplate = str_replace($replaceTD, $matchReplace, $rawTemplate); } } echo $rawTemplate; ?> </div> <input type="submit" class="submitButton" name="updateTourney" value="Update this Tournament" /> </form> <?php } ?> <?php include "footer.php"; ?>