AnonSec Shell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/atfycaf/www/admin/test.php
<?php
include "globalVars.php";

function maskPageEmail($emailAddress) {
	$maskedEmail = '';
	for ($j = 0; $j < strlen($emailAddress); $j++) {
		$maskedEmail	.= '&#' . ord(substr($emailAddress, $j, 1)) . ';' ;
	}
	$emailHtml = '<a href="m&#' . ord('a') . ';&#' . ord('i') . ';&#' . ord('l') . ';&#' . ord('t') . ';o:' . $maskedEmail . '"><i class="fa fa-envelope" aria-hidden="true"></i> ';
	return $emailHtml;
}

$moduleContent	= '<div class="textBG mainContent">
<div class="container">
<div class="textRow">
<h2>Team Almer&iacute;a</h2>
<p style="text-align: center;">Team Almeria is the Provincial Bowls team for Almeria encompassing players from all the Bowls Clubs in the area.</p>
<p style="text-align: center;">The team plays the Inter-Provincil Championships against Team Malaga annually on a home and away basis.&nbsp; The Inter-Provincial Championships is the most prestigious lawn bowls competition in the south of Spain for which players are selected from the squad to represent Almeria.</p>
<p style="text-align: center;">We are grateful to our sponsors Salas Opticas for their support.</p>
<p style="text-align: center;"><a href="https://www.salasgarciaopticosaudiometria.com/en/optical-center/" target="_blank" rel="nofollow noopener"><img src="/images/pageImages/Picture1.png" alt="Picture1" width="199" height="192" /></a>&nbsp;</p>
<p style="text-align: center;">Team Almeria is led by a committee working with team captains and coaches whose aim is to put together the strongest possible competative team to achieve a positive winning result.</p>
<p style="text-align: center;">For any further information please contact the Team Administrator by <a href="mailto:taadministrator@fabalmeria.es">clicking here</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</div>
</div>';

		if (strstr($moduleContent, '<a href="mailto:')) {
			$emailFrom		= strpos($moduleContent, '<a href="mailto:');
			$emailTo		= strpos($moduleContent, '">', $emailFrom);
			$emailStrLen	= ($emailTo - $emailFrom) + 2;
			$emailLink		= substr($moduleContent, $emailFrom, $emailStrLen);
			$emailAddress	= str_replace(array('<a href="mailto:', '">'), "", $emailLink);
			$replaceEmail	= maskPageEmail($emailAddress);
			$moduleContent	= str_replace($emailLink, $replaceEmail, $moduleContent);
			echo $moduleContent;
		}

/*
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Table Test</title>
<link type="text/css" href="https://www.fabalmeria.es/css/stylesheet-v.1.0054.css" rel="stylesheet" />
<style type="text/css">
.knockoutTD {height:49px;}
.knockoutRndConn {width:22px; position:relative;}
.knockoutRndConn span {position:absolute; background:#F1F2F3;}
.hConn {width:calc(50% + 0.5px); height:1px;}
.vConn {width:1px; height:calc(100% - 49px); top:24.5px; left:calc(50% + 0.5px);}
.firstM, .secondM, .preM {left:0;}
.firstM, .preM {top:24.5px;}
.secondM {bottom:24.5px;}
.nextR {top:calc(50% - 0.5px); left:calc(50% + 1.5px);}
.preM {width:100%; height:1px;}
</style>
</head>
<?php
$newTable	= file_get_contents("https://www.fabalmeria.es/knockout-16.html");
echo $newTable;

$newTable2	= file_get_contents("https://www.fabalmeria.es/knockout-pre-16.html");
echo $newTable2;
?>

<body>
</body>
</html>

<?php
/*
?>

	<form action="leagueNew-2.html" method="post">
        <input type="hidden" name="leagueID" value="1">
        <input type="submit" name="getFixtures" value="Reset">
    </form>
<?php


	$htaccess	= createPDFht();
	$siteHT		= $SERVER_ROOT ."/pdf/.htaccess";
	$htFile		= fopen($siteHT, "w");
	fwrite($htFile, $htaccess);
	fclose($htFile);
*/
/*
if (isset($_GET["kSS"])) {

	$shotScoreID	= $_GET["kSS"];
	$thisScore		= $_GET["kTS"];

	$homeAway		= substr($shotScoreID, 0, 4);
	$fixtureID		= substr($shotScoreID, 4);

	mysqli_query($conn, "UPDATE leagueResults SET ". $homeAway ."Score = '$thisScore' WHERE id = '$fixtureID'");

	$fixtureDateQuery = mysqli_query($conn, "SELECT id, weekID, miniLeagueID, fixtureDate FROM leagueResults WHERE id = '$fixtureID'");
	while ($fDQ = mysqli_fetch_array($fixtureDateQuery)) {
		$fixtureID		= $fDQ["id"];
		$roundID		= $fDQ["weekID"];
		$fixtureMLid	= $fDQ["miniLeagueID"];
		$fixtureDate	=  date("d/m/Y", strtotime($fDQ["fixtureDate"]));
	}
	echo "ROUND: $roundID<br>";
	if ($roundID == 99999) {
		$jsonArray	= array("update" => "false");
	} else {
		$roundID	= $roundID + 1;
		$jsonArray	= array("update" => "true", "divID" => "round". $roundID ."Display");

		if ($roundID == 99999) {
			$roundTitle	= "Final";
		} elseif ($roundID == 99998) {
			$roundTitle	= "Semi-Finals";
		} elseif ($roundID == 99997) {
			$roundTitle	= "Quarter-Finals";
		} else {
			$roundID	= ($weekID - $lowestWeek) + 1;
			$roundTitle	= "Round $roundID";
		}

		$fixtureDateQuery = mysqli_query($conn, "SELECT miniLeagueID, fixtureDate FROM leagueResults WHERE id = '$fixtureID'");
		while ($fDQ = mysqli_fetch_array($fixtureDateQuery)) {
			$fixtureMLid	= $fDQ["miniLeagueID"];
			$fixtureDate	=  date("d/m/Y", strtotime($fDQ["fixtureDate"]));
		}
		$drawnTeamsArray	 = array();
		$playoffsSetTeamsQuery = mysqli_query($conn, "SELECT homeTeam, awayTeam FROM leagueResults WHERE miniLeagueID = ('$fixtureMLid') AND (weekID = '$roundID') ORDER BY id ASC");
		while ($pSTQ = mysqli_fetch_array($playoffsSetTeamsQuery)) {
			if (trim($pSTQ["homeTeam"])) {
				$drawnTeamsArray[]	= $pSTQ["homeTeam"];
			}
			if (trim($pSTQ["awayTeam"])) {
				$drawnTeamsArray[]	= $pSTQ["awayTeam"];
			}
		}

		$roundHTML	= '
			<h3>'. $roundTitle .'</h3>
			<div class="roundDateInp">Date: <input type="text" id="fixtureDate'. $fixtureID .'" name="fixtureDate['. $fixtureID .']" class="roundDate" size="50" value="'. $fixtureDate .'"></div>
			<div class="listTitle">Qualified Teams</div>
			<div class="listTitle listTitleW">Round Draw</div>

			<div class="playersListC">
				<ul id="players'. $roundID .'" class="playersSet ui-sortable">';

				$undrawnTeamsQuery = mysqli_query($conn, "SELECT teamName FROM leagueKnockout WHERE leagueID = '$fixtureMLid' AND (weekID = '$roundID') AND teamName NOT IN('". implode("', '", $drawnTeamsArray) ."') ORDER BY id ASC");
				while ($uTQ = mysqli_fetch_array($undrawnTeamsQuery)) {
					$teamName	= $uTQ["teamName"];

					$roundHTML	.= '
					<li><i class="fas fa-grip-horizontal"></i><input type="text" class="teamName" size="50" value="'. $teamName .'" readonly /></li>';

				}
				$roundHTML	.= '
				</ul>
			</div>

			<div class="fixturesListC">';

				$playoffsQuery = mysqli_query($conn, "SELECT * FROM leagueResults WHERE miniLeagueID = '$fixtureMLid' AND (weekID = '$roundID') ORDER BY id ASC");
				$noTeams	= mysqli_num_rows($playoffsQuery) * 2;
				$roundHTML	.= '
				<ul id="fixtures<'. $roundID .'" class="fixtureSet ui-sortable" data-fc="'. $noTeams .'" data-mlid="'. $fixtureMLid .'">';

				while ($pFQ = mysqli_fetch_array($playoffsQuery)) {
					$fixtureID		= $pFQ["id"];
					$weekID			= $pFQ["weekID"];
					$fixtureDate	=  date("d/m/Y", strtotime($pFQ["fixtureDate"]));
					$homeTeam		= $pFQ["homeTeam"];
					$homeScore		= $pFQ["homeScore"];
					$homeRinkPts	= $pFQ["homeRinkPts"];
					$awayTeam		= $pFQ["awayTeam"];
					$awayScore		= $pFQ["awayScore"];
					$awayRinkPts 	= $pFQ["awayRinkPts"];
					$firstLegID 	= $pFQ["firstLegID"];
					if ($homeScore == -1) {
						$homeScore		= "";
						$homeRinkPts	= "";
					}
					if ($awayScore == -1) {
						$awayScore		= "";
						$awayRinkPts	= "";
					}
					if (trim($homeTeam) == "") {
						$roundHTML	.= '
					<li id="home'. $fixtureID .'" class="ui-sortable-placeholder ui-sortable-handle"></li>';

					} else {
						$roundHTML	.= '
					<li id="home'. $fixtureID .'" class="ui-sortable-handle"><input type="text" class="teamName" size="50" value="'. $homeTeam .'" readonly /> <input type="number" class="fixtureRinkPts" placeholder="Rink Points" value="'. $homeRinkPts .'" min="0" max="'. $pointsRink .'" step="1"> <input type="number" class="kFixtureScore" placeholder="Shots" value="'. $homeScore .'" min="0" step="1"></li>';

					}
					if (trim($awayTeam) == "") {
						$roundHTML	.= '
					<li id="away'. $fixtureID .'" class="ui-sortable-placeholder ui-sortable-handle"></li>';

					} else {
						$roundHTML	.= '
					<li id="away'. $fixtureID .'" class="ui-sortable-handle"><input type="text" class="teamName" size="50" value="'. $awayTeam .'" readonly /> <input type="number" class="fixtureRinkPts" placeholder="Rink Points" value="'. $awayRinkPts .'" min="0" max="'. $pointsRink .'" step="1"> <input type="number" class="kFixtureScore" placeholder="Shots" value="'. $awayScore .'" min="0" step="1"></li>';

					}
				}
				$roundHTML	.= '
				</ul>
			</div>';

		$jsonArray["divHTML"]	= addslashes($roundHTML);
	}

	echo json_encode($jsonArray);
}
/*
			$leagueStandings	= array();
			$miniLeaguesArray	= array();
			$i					= 0;
			$miniLeagueQuery = mysqli_query($conn, "SELECT * FROM leagueMiniLeagues WHERE leagueID = '2' ORDER BY id ASC");
			while ($mLQ = mysqli_fetch_array($miniLeagueQuery)) {
				$mLID				= $mLQ["id"];
				$miniLeaguesArray[]	= $mLID;
				if ($i == 0) {
					$playoffMLid	= $mLID;
				}

				$leagueStandings[]	= array();

				$leagueStandingQuery = mysqli_query($conn, "SELECT 
					team, 
					COUNT(*) AS played, 
					COUNT(CASE WHEN homeScore > awayScore THEN 1 END) AS won, 
					COUNT(CASE WHEN homeScore = awayScore THEN 1 END) AS drawn, 
					COUNT(CASE WHEN awayScore> homeScore THEN 1 END) AS lost, 
					SUM(homeScore) AS shotsFor, 
					SUM(awayScore) AS shotsAgainst, 
					SUM(homeScore) - SUM(awayScore) AS shotsDiff,
					SUM(homeRinkPts) AS rinkPts,
					SUM(
						  CASE WHEN homeScore > awayScore THEN 2 ELSE 0 END 
						+ CASE WHEN homeScore = awayScore THEN 1 ELSE 0 END
						+ homeRinkPts
					) AS pts 
				FROM (
					SELECT homeTeam AS team, homeScore, awayScore, homeRinkPts, awayRinkPts from leagueResults WHERE miniLeagueID = '$mLID' AND ((homeTeam != '') AND (awayTeam != '')) AND ((homeScore > 0) AND (awayScore > 0)) AND (weekID < 900)
				  UNION ALL
					SELECT awayTeam AS team, awayScore, homeScore, awayRinkPts, homeRinkPts from leagueResults WHERE miniLeagueID = '$mLID' AND ((homeTeam != '') AND (awayTeam != '')) AND ((homeScore > 0) AND (awayScore > 0)) AND (weekID < 900)
				) AS a 
				GROUP BY team
				ORDER BY pts DESC, shotsDiff DESC") or die (mysqli_error($conn));
				if (mysqli_num_rows($leagueStandingQuery) > 0) {
					$addedTeams	= array();
					while ($lSQ = mysqli_fetch_array($leagueStandingQuery)) {
						$leagueStandings[$i][]	= $lSQ["team"];
						$addedTeams[]			= $lSQ["team"];
					}
				}
				$defaultLeagueQuery = mysqli_query($conn, "SELECT * FROM leagueMiniLeaguesTeams WHERE miniLeagueID = '$mLID' AND (teamName NOT IN ('". implode("', '", $addedTeams) ."')) ORDER BY teamName ASC");
				while ($dLQ = mysqli_fetch_array($defaultLeagueQuery)) {
					$leagueStandings[$i][]	= $dLQ["teamName"];
				}
				$i++;
			}
			foreach($leagueStandings as $groupID => $groupStandings) {
				$firstPlace		= $groupStandings[0];
				$secondPlace	= $groupStandings[1];
				echo "Group $groupID<br>Winners: $firstPlace<br>Second: $secondPlace<br><br>";
			}
			?>
			<textarea style="float:left; width:100%; height:1000px;"><?php print_r($leagueStandings); ?></textarea>
			<?php
*/
/*
if (isset($_GET["sS"])) {
	$shotScoreID	= $_POST["sS"];
	$thisScore		= $_POST["tS"];

	$homeAway		= substr($shotScoreID, 0, 4);
	$fixtureID		= substr($shotScoreID, 4);

	mysqli_query($conn, "UPDATE leagueResults SET ". $homeAway ."Score = '$thisScore' WHERE id = '$fixtureID'");

	/////	CHECK TO SEE IF A PLAYOFF IS REQUIRED AND IF ALL FIXTURES HAVE BEEN PLAYED	\\\\\
	$mlIDQuery = mysqli_query($conn, "SELECT miniLeagueID FROM leagueResults WHERE id = '$fixtureID'");
	while ($mIQ = mysqli_fetch_array($mlIDQuery)) {
		$miniLeagueID	= $mIQ["miniLeagueID"];
	}
	$leagueIDQuery = mysqli_query($conn, "SELECT leagueID FROM leagueMiniLeagues WHERE id = '$miniLeagueID'");
	while ($lIQ = mysqli_fetch_array($leagueIDQuery)) {
		$leagueID	= $lIQ["leagueID"];
	}
	$hasPlayoffQuery = mysqli_query($conn, "SELECT hasPlayoff FROM leagueConfig WHERE id = '$leagueID'");
	while ($hPQ = mysqli_fetch_array($hasPlayoffQuery)) {
		$hasPlayoff	= $hPQ["hasPlayoff"];
	}
	if ($hasPlayoff > 0) {
		/////	PLAYOFF IS NEEDED - CHECK IF SEASON FINISHED	\\\\\
		$seasonFinished		= true;
		$miniLeaguesQuery = mysqli_query($conn, "SELECT * FROM leagueMiniLeagues WHERE leagueID = '$leagueID' ORDER BY id ASC");
		while ($mLQ = mysqli_fetch_array($miniLeaguesQuery)) {
			$miniLeagueID		= $mLQ["id"];
			$matchesToPlayQuery = mysqli_query($conn, "SELECT id from leagueResults WHERE miniLeagueID = '$miniLeagueID' AND ((homeTeam != '') AND (awayTeam != '')) AND ((homeScore = 0) AND (awayScore = 0))");
			$matchesToPlay	= mysqli_num_rows($matchesToPlayQuery);
			if ($matchesToPlay > 0) {
				$seasonFinished	= false;
			}
		}
		if ($seasonFinished == true) {
			/////	SEASON HAS BEEN COMPLETED - GET THE FINALISTS	\\\\\
			$leagueConfigQuery = mysqli_query($conn, "SELECT * FROM leagueConfig WHERE id = '$leagueID'");
			while ($lCQ = mysqli_fetch_array($leagueConfigQuery)) {
				$hasMiniLeagues	= $lCQ["hasMiniLeagues"];
				$noTeams		= $lCQ["noTeams"];
				$hasPlayoff		= $lCQ["hasPlayoff"];
				$pointsWin		= $lCQ["pointsWin"];
				$pointsDraw		= $lCQ["pointsDraw"];
				$pointsRink		= $lCQ["pointsRink"];
			}
			if ($hasPlayoff == 1) {
				/////	TOP TEAM FROM EACH GROUP PLAY HOME AND AWAY	\\\\\
				$advancingTeams	= $hasMiniLeagues;
				$homeAndAway	= true;
			
			} elseif ($hasPlayoff == 2) {
				/////	TOP TEAM FROM EACH GROUP PLAY A ONE-OFF FINAL	\\\\\
				$advancingTeams	= $hasMiniLeagues;
				$homeAndAway	= false;
			
			} elseif ($hasPlayoff == 3) {
				/////	TOP 2 TEAMS FROM EACH GROUP PLAY A KNOCKOUT HOME AND AWAY	\\\\\
				$advancingTeams	= $hasMiniLeagues * 2;
				$homeAndAway	= true;
			
			} elseif ($hasPlayoff == 4) {
				/////	TOP 2 TEAMS FROM EACH GROUP PLAY A KNOCKOUT	\\\\\
				$advancingTeams	= $hasMiniLeagues * 2;
				$homeAndAway	= false;
			
			}

			$leagueStandings	= array();
			$miniLeaguesArray	= array();
			$i					= 0;
			$miniLeagueQuery = mysqli_query($conn, "SELECT * FROM leagueMiniLeagues WHERE leagueID = '$leagueID' ORDER BY id ASC");
			while ($mLQ = mysqli_fetch_array($miniLeagueQuery)) {
				$mLID				= $mLQ["id"];
				$miniLeaguesArray[]	= $mLID;
				if ($i == 0) {
					$playoffMLid	= $mLID;
				}

				$leagueStandings[]	= array();

				$leagueStandingQuery = mysqli_query($conn, "SELECT 
					team, 
					COUNT(*) AS played, 
					COUNT(CASE WHEN homeScore > awayScore THEN 1 END) AS won, 
					COUNT(CASE WHEN homeScore = awayScore THEN 1 END) AS drawn, 
					COUNT(CASE WHEN awayScore> homeScore THEN 1 END) AS lost, 
					SUM(homeScore) AS shotsFor, 
					SUM(awayScore) AS shotsAgainst, 
					SUM(homeScore) - SUM(awayScore) AS shotsDiff,
					SUM(homeRinkPts) AS rinkPts,
					SUM(
						  CASE WHEN homeScore > awayScore THEN $pointsWin ELSE 0 END 
						+ CASE WHEN homeScore = awayScore THEN $pointsDraw ELSE 0 END
						+ homeRinkPts
					) AS pts 
				FROM (
					SELECT homeTeam AS team, homeScore, awayScore, homeRinkPts, awayRinkPts from leagueResults WHERE miniLeagueID = '$mLID' AND ((homeTeam != '') AND (awayTeam != '')) AND ((homeScore > 0) AND (awayScore > 0)) AND (weekID < 900)
				  UNION ALL
					SELECT awayTeam AS team, awayScore, homeScore, awayRinkPts, homeRinkPts from leagueResults WHERE miniLeagueID = '$mLID' AND ((homeTeam != '') AND (awayTeam != '')) AND ((homeScore > 0) AND (awayScore > 0)) AND (weekID < 900)
				) AS a 
				GROUP BY team
				ORDER BY pts DESC, shotsDiff DESC") or die (mysqli_error($conn));
				if (mysqli_num_rows($leagueStandingQuery) > 0) {
					$addedTeams	= array();
					while ($lSQ = mysqli_fetch_array($leagueStandingQuery)) {
						$leagueStandings[$i][]	= $lSQ["team"];
						$addedTeams[]			= $lSQ["team"];
					}
				}
				$defaultLeagueQuery = mysqli_query($conn, "SELECT * FROM leagueMiniLeaguesTeams WHERE miniLeagueID = '$mLID' AND (teamName NOT IN ('". implode("', '", $addedTeams) ."')) ORDER BY teamName ASC");
				while ($dLQ = mysqli_fetch_array($defaultLeagueQuery)) {
					$leagueStandings[$i][]	= $dLQ["teamName"];
				}
				$i++;
			}
			/////	1 LEGGED MATCHES ROUNDS ARE 9990+	\\\\\
			/////	2 LEGGED MATCHES ROUNDS ARE 99990+	\\\\\
			$lastFixtureQuery = mysqli_query($conn, "SELECT fixtureDate FROM leagueResults WHERE miniLeagueID IN ('". implode("', '", $miniLeaguesArray) ."') ORDER BY fixtureDate DESC LIMIT 0,1");
			while ($lFQ = mysqli_fetch_array($lastFixtureQuery)) {
				$lastFixture	= $lFQ["fixtureDate"];
			}
			if ($hasMiniLeagues == 1) {
				$homeTeam	= $leagueStandings[0][1];
				$awayTeam	= $leagueStandings[0][0];
				if ($hasPlayoff == 3) {
					/////	2 LEG FINAL	\\\\\
					$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$fixtureDate', '". addslashes($homeTeam) ."', '". addslashes($awayTeam) ."')");
					$firstLegID	= mysqli_insert_id($conn);

					$returnFixtureDate	= date("Y-m-d", strtotime("$fixtureDate +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, firstLegID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$firstLegID', '$returnFixtureDate', '". addslashes($awayTeam) ."', '". addslashes($homeTeam) ."')");

				} elseif ($hasPlayoff == 4) {
					/////	FINAL	\\\\\
					$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$fixtureDate', '". addslashes($awayTeam) ."', '". addslashes($homeTeam) ."')");
				}

			} elseif ($hasMiniLeagues == 2) {
				/////	SIMPLE. TOP TEAM ONLY PROGRESSES OR TOP TEAM PLAYS 2ND FROM OTHER GROUP	\\\\\
				if ($hasPlayoff == 1 || $hasPlayoff == 2) {
					$homeTeam	= $leagueStandings[0][0];
					$awayTeam	= $leagueStandings[1][0];
				}

				if ($hasPlayoff == 1) {
					/////	2 LEG FINAL	\\\\\
					$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$fixtureDate', '". addslashes($homeTeam) ."', '". addslashes($awayTeam) ."')");
					$firstLegID	= mysqli_insert_id($conn);

					$returnFixtureDate	= date("Y-m-d", strtotime("$fixtureDate +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, firstLegID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$firstLegID', '$returnFixtureDate', '". addslashes($awayTeam) ."', '". addslashes($homeTeam) ."')");

				} elseif ($hasPlayoff == 2) {
					/////	FINAL	\\\\\
					$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$fixtureDate', '". addslashes($homeTeam) ."', '". addslashes($awayTeam) ."')");

				} elseif ($hasPlayoff == 3) {
					/////	2 LEG SEMI-FINAL THEN FINAL	\\\\\
					$home1Team	= $leagueStandings[1][1];
					$away1Team	= $leagueStandings[0][0];
					$home2Team	= $leagueStandings[0][1];
					$away2Team	= $leagueStandings[1][0];

					$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9998', '$fixtureDate', '". addslashes($home1Team) ."', '". addslashes($away1Team) ."')");
					$firstLeg1ID	= mysqli_insert_id($conn);
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9998', '$fixtureDate', '". addslashes($home2Team) ."', '". addslashes($away2Team) ."')");
					$firstLeg2ID	= mysqli_insert_id($conn);

					$returnFixtureDate	= date("Y-m-d", strtotime("$fixtureDate +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, firstLegID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9998', '$firstLeg1ID', '$returnFixtureDate', '". addslashes($away1Team) ."', '". addslashes($home1Team) ."')");
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, firstLegID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9998', '$firstLeg2ID', '$returnFixtureDate', '". addslashes($away2Team) ."', '". addslashes($home2Team) ."')");

					$finalFixtureDate	= date("Y-m-d", strtotime("$returnFixtureDate +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate) VALUES ('$playoffMLid', '9999', '$finalFixtureDate')");
					$firstLegFID	= mysqli_insert_id($conn);

					$finalReturnFixtureDate	= date("Y-m-d", strtotime("$finalFixtureDate +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, firstLegID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9999', '$firstLegFID', '$finalReturnFixtureDate')");

				} elseif ($hasPlayoff == 4) {
					/////	SEMI-FINAL THEN FINAL	\\\\\
					$home1Team	= $leagueStandings[0][0];
					$away1Team	= $leagueStandings[1][1];
					$home2Team	= $leagueStandings[1][0];
					$away2Team	= $leagueStandings[0][0];

					$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9998', '$fixtureDate', '". addslashes($home1Team) ."', '". addslashes($away1Team) ."')");
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate, homeTeam, awayTeam) VALUES ('$playoffMLid', '9998', '$fixtureDate', '". addslashes($home2Team) ."', '". addslashes($away2Team) ."')");

					$finalFixtureDate	= date("Y-m-d", strtotime("$fixtureDate +7 days"));
					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate) VALUES ('$playoffMLid', '9999', '$fixtureDate')");

				}

			} else {
				/////	MORE COMPLICATED - NEEDS A DRAW	\\\\\
				/////	INSERT THE MATCHES NEEDED INTO THE DATABASE AND LEAVE TEAMS EMPTY FOR DRAWING	\\\\\
				$noRounds	= getNoRounds($advancingTeams);
				$roundID	= 100000 - $noRounds;

				$matchesArray	= array();
				$noMatches		= 1;
				for ($w = 1; $w <= $noRounds; $w++) {
					if ($w == 1) {
						$noMatches	= $noMatches;
					} else {
						$noMatches	= $noMatches * 2;
					}
					$matchesArray[]	= $noMatches;
				}
				$matchesArrayR	= array_reverse($matchesArray);
				for ($w = 1; $w <= $noRounds; $w++) {
					$noMatches	= $matchesArrayR[$w];
					for ($m = 1; $m <= $noMatches; $m++) {
						if ($homeAndAway == true) {

							$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
							mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate) VALUES ('$playoffMLid', '$roundID', '$fixtureDate')");
							$firstLegID	= mysqli_insert_id($conn);

							$fixtureDate	= date("Y-m-d", strtotime("$fixtureDate +7 days"));
							mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, firstLegID, fixtureDatem) VALUES ('$playoffMLid', '$roundID', '$firstLegID', '$fixtureDate')");
						
						} else {

							$fixtureDate	= date("Y-m-d", strtotime("$lastFixture +7 days"));
							mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, fixtureDate) VALUES ('$playoffMLid', '$roundID', '$fixtureDate')");
						
						}
					}
					$roundID++;
				}
			}
		}
	}
	
	function getNoRounds($compLeft) {
		$noRounds		= 1;
		if ($compLeft > 2) {
			do {
				$compLeft	= $compLeft / 2;
				$noRounds++;
			} while ($compLeft > 2);
		}

		return $noRounds;
	}
}
/*
if (isset($_POST["save"])) {

	if (isset($_POST["homeTeam"])) {
		foreach($_POST["homeTeam"] as $leagueID => $weekFixtures) {
			foreach($weekFixtures as $weekID => $homeTeams) {
				echo "WEEK $weekID\n";
				foreach($homeTeams as $matchID => $homeTeam) {
					$awayTeam	= $_POST["awayTeam"][$leagueID][$weekID][$matchID];
					echo "MATCH $matchID $homeTeam v $awayTeam\n";
					$homeScore		= mt_rand(0,21);
					$awayScore		= mt_rand(0,21);
					$homeRinkArray	= array(0,2,4,6,8);
					$homeRinkPts	= $homeRinkArray[mt_rand(0,4)];
					$awayRinkPts	= 8 - $homeRinkPts;

					echo "INSERT INTO leagueResults (miniLeagueID, weekID, homeTeam, homeScore, homeRinkPts, awayTeam, awayScore, awayRinkPts) VALUES ('1', '$weekID', '$homeTeam', '$homeScore', '$homeRinkPts', '$awayTeam', '$awayScore', '$awayRinkPts')\n\n";
//					mysqli_query($conn, "INSERT INTO leagueResults (miniLeagueID, weekID, homeTeam, homeScore, homeRinkPts, awayTeam, awayScore, awayRinkPts) VALUES ('1', '$weekID', '$homeTeam', '$homeScore', '$homeRinkPts', '$awayTeam', '$awayScore', '$awayRinkPts')") or die (mysqli_error($conn));
				}
				echo "\n";
			}
		}
	}

} elseif (isset($_GET['teams']) || isset($_GET['names'])) {
	if (isset($_GET["hA"])) {
		$homeAway	= $_GET["hA"];
	} else {
		$homeAway	= 1;
	}
	if (isset($_GET["lID"])) {
		$leagueID	= $_GET["lID"];
	} else {
		$leagueID	= 0;
	}
	?>
	<form action="test.php" method="post">
	<?php
	if (isset($_GET["teams"])) {
		echo createFixtures(intval($_GET['teams']), $homeAway, $leagueID);
	} else {
		echo createFixtures($_GET['names'], $homeAway, $leagueID);
	}
	?>
		<button name="save">Save</button>
	</form>
	<?php
}
if (isset($_POST["save"])) {
	header("Content-Type:text/plain");
//	print_r($_POST);
}

function nums($n) {
	$ns		= array();
	for ($i = 1; $i <= $n; $i++) {
		$ns[]	= $i;
	}
	return $ns;
}

function createFixtures($names, $homeAway, $leagueID) {
	$teams	= sizeof($names);
	$ghost	= false;

	print "<h3>Fixtures</h3>";

	// If odd number of teams add a "ghost".
    if ($teams % 2 == 1) {
		$teams++;
		$ghost		= true;
		$ghostID	= $teams;
	}

	// Generate the fixtures using the cyclic algorithm.
	$totalRounds		= $teams - 1;
	$matchesPerRound	= $teams / 2;
	$rounds				= array();
	for ($i = 0; $i < $totalRounds; $i++) {
		$rounds[$i] = array();
	}

	for ($round = 0; $round < $totalRounds; $round++) {
		for ($match = 0; $match < $matchesPerRound; $match++) {
			$home	= ($round + $match) % ($teams - 1);
			$away	= ($teams - 1 - $match + $round) % ($teams - 1);
			// Last team stays in the same place while the others
			// rotate around it.
			if ($match == 0) {
				$away	= $teams - 1;
			}
			$rounds[$round][$match] = teamName($home + 1, $names) ." v ". teamName($away + 1, $names);
		}
	}

	// Interleave so that home and away games are fairly evenly dispersed.
	$interleaved	= array();
	for ($i = 0; $i < $totalRounds; $i++) {
		$interleaved[$i] = array();
	}

	$evn	= 0;
    $odd	= ($teams / 2);
	for ($i = 0; $i < sizeof($rounds); $i++) {
		if ($i % 2 == 0) {
			$interleaved[$i] = $rounds[$evn++];
		} else {
			$interleaved[$i] = $rounds[$odd++];
		}
	}

	$rounds	= $interleaved;

	// Last team can't be away for every game so flip them
	// to home on odd rounds.
	for ($round = 0; $round < sizeof($rounds); $round++) {
		if ($round % 2 == 1) {
			$rounds[$round][0]	= flip($rounds[$round][0]);
		}
	}
	shuffle($rounds);

	$weekCount	= 1;
	$fixtureID	= 1;

	// Display the fixtures
	for ($i = 0; $i < sizeof($rounds); $i++) {
		print "<p>Round " . ($i + 1) . "</p>\n";
		foreach ($rounds[$i] as $r) {
			$splitTeams		= str_replace(" v ", "|", $r);
			$splitArray		= explode("|", $splitTeams);
			print '<input type="hidden" name="homeTeam['. $leagueID .']['. $weekCount .']['. $fixtureID .']" value="'. str_replace($ghostID, "", $splitArray[0]) .'">';
			print '<input type="hidden" name="awayTeam['. $leagueID .']['. $weekCount .']['. $fixtureID .']" value="'. str_replace($ghostID, "", $splitArray[1]) .'">';
			$isBye	= false;
			if ($ghost == true) {
				if (strstr($r, " v $ghostID") || strstr($r, "$ghostID v ")) {
					$isBye	= true;
				}
				$rDisplay	= str_replace(array(" v $ghostID", "$ghostID v "), "", $r);
			} else {
				$rDisplay	= $r;
			}
			if ($isBye == true) {
				print $rDisplay . " - <strong>Bye week</strong><br />";
			} else {
				print $rDisplay . "<br />";
			}
			$fixtureID++;
		}
		$weekCount++;
		print "<br />";
	}

	if ($homeAway == 1) {
		shuffle($rounds);

		$round_counter = sizeof($rounds) + 1;
		for ($i = sizeof($rounds) - 1; $i >= 0; $i--) {
			print "<p>Round " . $round_counter . "</p>\n";
			$round_counter += 1;
			foreach ($rounds[$i] as $r) {
				$splitTeams		= str_replace(" v ", "|", flip($r));
				$splitArray		= explode("|", $splitTeams);
				print '<input type="hidden" name="homeTeam['. $leagueID .']['. $weekCount .']['. $fixtureID .']" value="'. str_replace($ghostID, "", $splitArray[0]) .'">';
				print '<input type="hidden" name="awayTeam['. $leagueID .']['. $weekCount .']['. $fixtureID .']" value="'. str_replace($ghostID, "", $splitArray[1]) .'">';
				$isBye	= false;
				if ($ghost == true) {
					if (strstr($r, " v $ghostID") || strstr($r, "$ghostID v ")) {
						$isBye	= true;
					}
					$rDisplay	= str_replace(array(" v $ghostID", "$ghostID v "), "", flip($r));
				} else {
					$rDisplay	= flip($r);
				}
				if ($isBye == true) {
					print $rDisplay . " - <strong>Bye week</strong><br />";
				} else {
					print $rDisplay . "<br />";
				}
				$fixtureID++;
			}
			print "<br />";
			$weekCount++;
		}
		print "<br />";
	}
}

function flip($match) {
	$components	= explode(' v ', $match);
	return $components[1] ." v ". $components[0];
}

function teamName($num, $names) {
	$i	= $num - 1;
	if (sizeof($names) > $i && strlen(trim($names[$i])) > 0) {
		return trim($names[$i]);
	} else {
		return $num;
	}
}
*/
?>

Anon7 - 2022
AnonSec Team