*/
require_once 'resources/config.php';
require_once 'resources/database.php';
$db = new Database();
$sport = "";
if(isset($_GET["sport"])){
$sport = $_GET["sport"];
}
$allteams = $db->getTeams();
$teams_poules1 = array();
$teams_poules2 = array();
$matchs_poules1 = array();
$matchs_poules2 = array();
$matchs_eight = array();
$matchs_quarters = array();
$matchs_semis = array();
$matchs_final = array();
$matchs_little_final = array();
if($sport != "leaderboard"){
if($sport == "badminton"){
$matchs_eight1 = array();
$matchs_eight2 = array();
$matchs_quarters1 = array();
$matchs_quarters2 = array();
$matchs_semis1 = array();
$matchs_semis2 = array();
$matchs_final1 = array();
$matchs_final2 = array();
$matchs_final3 = array();
foreach($db->getMatches() as $match){
if(strtolower($match["sport_name"]) == strtolower($sport)."1"){
switch($match["type"]){
case 0:
break;
case 1:
array_push($matchs_final3, $match);
break;
case 2:
array_push($matchs_final1, $match);
break;
case 3:
array_push($matchs_semis1, $match);
break;
case 4:
array_push($matchs_little_final, $match);
break;
case 5:
array_push($matchs_quarters1, $match);
break;
case 6:
array_push($matchs_eight1, $match);
break;
default:
break;
}
}
if(strtolower($match["sport_name"]) == strtolower($sport)."2"){
switch($match["type"]){
case 0:
break;
case 1:
break;
case 2:
array_push($matchs_final2, $match);
break;
case 3:
array_push($matchs_semis2, $match);
break;
case 4:
break;
case 5:
array_push($matchs_quarters2, $match);
break;
case 6:
array_push($matchs_eight2, $match);
break;
default:
break;
}
}
}
array_push($matchs_eight, $matchs_eight1);
array_push($matchs_eight, $matchs_eight2);
array_push($matchs_quarters, $matchs_quarters1);
array_push($matchs_quarters, $matchs_quarters2);
array_push($matchs_semis, $matchs_semis1);
array_push($matchs_semis, $matchs_semis2);
array_push($matchs_final, $matchs_final1);
array_push($matchs_final, $matchs_final2);
array_push($matchs_final, $matchs_final3);
}
else{
foreach($db->getMatches() as $match){
if(strtolower($match["sport_name"]) == strtolower($sport)){
switch($match["type"]){
case 0:
array_push($matchs_poules1, $match);
break;
case 1:
array_push($matchs_final, $match);
break;
case 2:
array_push($matchs_semis, $match);
break;
case 3:
array_push($matchs_quarters, $match);
break;
case 4:
array_push($matchs_little_final, $match);
break;
case 7:
array_push($matchs_poules2, $match);
break;
default:
break;
}
}
}
}
foreach($allteams as $team){
$found1 = false;
$found2 = false;
foreach($matchs_poules1 as $match){
if(json_decode($match["teams_id"])[0] == $team["id"] || json_decode($match["teams_id"])[1] == $team["id"]){
$found1 = true;
}
}
foreach($matchs_poules2 as $match){
if(json_decode($match["teams_id"])[0] == $team["id"] || json_decode($match["teams_id"])[1] == $team["id"]){
$found2 = true;
}
}
if($found1){
array_push($teams_poules1, $team);
}
if($found2){
array_push($teams_poules2, $team);
}
}
}
else{
$leader = array(
"A1" => array(2, 10, 10, 3, 1, 3, 1, 30, 4),
"A2" => array(5, 7, 5, 5, 7, 7, 3, 39, 3),
"A3" => array(7, 5, 7, 10, 5, 7, 2, 43, 1),
"A4" => array(10, 3, 3, 7, 10, 10, 0, 43, 1),
"A5" => array(1, 0, 0, 0, 0, 0, 0, 1, 6),
"Permanents" => array(0, 0, 0, 0, 0, 2, 0, 2, 5)
);
}
?>
0 || sizeof($matchs_final) == 0 && sizeof($matchs_semis) == 0 && sizeof($matchs_little_final) == 0){
?>
Quarts de finale
";
if(sizeof($matchs_quarters) >= $i + 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_quarters[$i]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_quarters[$i]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_quarters[$i]["scores"])[1]){
echo " winner";
}
elseif(json_decode($matchs_quarters[$i]["scores"])[0] < json_decode($matchs_quarters[$i]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_quarters[$i]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_quarters[$i]["scores"])[0]){
echo " winner";
}
elseif(json_decode($matchs_quarters[$i]["scores"])[1] < json_decode($matchs_quarters[$i]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_quarters[$i]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
}
?>
Demi-finales
";
if(sizeof($matchs_semis) >= $i + 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_semis[$i]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_semis[$i]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_semis[$i]["scores"])[1]){
echo " winner";
}
elseif(json_decode($matchs_semis[$i]["scores"])[0] < json_decode($matchs_semis[$i]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_semis[$i]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_semis[$i]["scores"])[0]){
echo " winner";
}
elseif(json_decode($matchs_semis[$i]["scores"])[1] < json_decode($matchs_semis[$i]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_semis[$i]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
}
?>
Finale
";
if(sizeof($matchs_final) >= 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_final[0]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_final[0]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_final[0]["scores"])[1]){
echo " gold-medal winner";
}
elseif(json_decode($matchs_final[0]["scores"])[0] < json_decode($matchs_final[0]["scores"])[1]){
echo " silver-medal loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_final[0]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_final[0]["scores"])[0]){
echo " gold-medal winner";
}
elseif(json_decode($matchs_final[0]["scores"])[1] < json_decode($matchs_final[0]["scores"])[0]){
echo " silver-medal loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_final[0]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
?>
Petite finale
";
if(sizeof($matchs_little_final) >= 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_little_final[0]["scores"])[1]){
echo " bronze-medal winner";
}
elseif(json_decode($matchs_little_final[0]["scores"])[0] < json_decode($matchs_little_final[0]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_little_final[0]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_little_final[0]["scores"])[0]){
echo " bronze-medal winner";
}
elseif(json_decode($matchs_little_final[0]["scores"])[1] < json_decode($matchs_little_final[0]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_little_final[0]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
?>
16èmes de finale
";
if($i != 1 && $i != 6){
$del_elems++;
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
elseif(sizeof($matchs_eight[$k-1]) >= $i - $del_elems + 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_eight[$k-1][$i - $del_elems]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_eight[$k-1][$i - $del_elems]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1]){
echo " winner";
}
elseif(json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0] < json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0]){
echo " winner";
}
elseif(json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1] < json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_eight[$k-1][$i - $del_elems]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
}
?>
8èmes de finale
";
switch($i){
case 0:
$jj = 2;
break;
case 1:
$jj = 0;
break;
case 2:
$jj = 1;
break;
case 3:
$jj = 3;
break;
}
if(sizeof($matchs_quarters[$k-1]) >= $jj + 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_quarters[$k-1][$jj]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_quarters[$k-1][$jj]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_quarters[$k-1][$jj]["scores"])[1]){
echo " winner";
}
elseif(json_decode($matchs_quarters[$k-1][$jj]["scores"])[0] < json_decode($matchs_quarters[$k-1][$jj]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_quarters[$k-1][$jj]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_quarters[$k-1][$jj]["scores"])[0]){
echo " winner";
}
elseif(json_decode($matchs_quarters[$k-1][$jj]["scores"])[1] < json_decode($matchs_quarters[$k-1][$jj]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_quarters[$k-1][$jj]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
}
?>
Quarts de finale
";
if(sizeof($matchs_semis[$k-1]) >= $i + 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_semis[$k-1][$i]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_semis[$k-1][$i]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_semis[$k-1][$i]["scores"])[1]){
echo " winner";
}
elseif(json_decode($matchs_semis[$k-1][$i]["scores"])[0] < json_decode($matchs_semis[$k-1][$i]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_semis[$k-1][$i]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_semis[$k-1][$i]["scores"])[0]){
echo " winner";
}
elseif(json_decode($matchs_semis[$k-1][$i]["scores"])[1] < json_decode($matchs_semis[$k-1][$i]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_semis[$k-1][$i]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
}
?>
Demi-finales
";
if(sizeof($matchs_final[$k-1]) >= 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_final[$k-1][0]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_final[$k-1][0]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_final[$k-1][0]["scores"])[1]){
echo " winner";
}
elseif(json_decode($matchs_final[$k-1][0]["scores"])[0] < json_decode($matchs_final[$k-1][0]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_final[$k-1][0]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_final[$k-1][0]["scores"])[0]){
echo " winner";
}
elseif(json_decode($matchs_final[$k-1][0]["scores"])[1] < json_decode($matchs_final[$k-1][0]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_final[$k-1][0]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
?>
Finale
";
if(sizeof($matchs_final[2]) >= 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_final[2][0]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_final[2][0]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_final[2][0]["scores"])[1]){
echo " gold-medal winner";
}
elseif(json_decode($matchs_final[2][0]["scores"])[0] < json_decode($matchs_final[2][0]["scores"])[1]){
echo " silver-medal loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_final[2][0]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_final[2][0]["scores"])[0]){
echo " gold-medal winner";
}
elseif(json_decode($matchs_final[2][0]["scores"])[1] < json_decode($matchs_final[2][0]["scores"])[0]){
echo " silver-medal loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_final[2][0]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
?>
Petite finale
";
if(sizeof($matchs_little_final) >= 1){
$team1;
$team2;
foreach($allteams as $team){
if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[0]){
$team1 = $team;
}
if($team["id"] == json_decode($matchs_little_final[0]["teams_id"])[1]){
$team2 = $team;
}
}
echo "
json_decode($matchs_little_final[0]["scores"])[1]){
echo " bronze-medal winner";
}
elseif(json_decode($matchs_little_final[0]["scores"])[0] < json_decode($matchs_little_final[0]["scores"])[1]){
echo " loser";
}
echo "\">";
echo "
".$team1["name"]."
";
echo "
".json_decode($matchs_little_final[0]["scores"])[0]."
";
echo "
";
echo "
json_decode($matchs_little_final[0]["scores"])[0]){
echo " bronze-medal winner";
}
elseif(json_decode($matchs_little_final[0]["scores"])[1] < json_decode($matchs_little_final[0]["scores"])[0]){
echo " loser";
}
echo "\">";
echo "
".$team2["name"]."
";
echo "
".json_decode($matchs_little_final[0]["scores"])[1]."
";
echo "
";
}
else{
echo "
";
echo "
-
";
echo "
-
";
echo "
";
echo "
";
echo "
-
";
echo "
-
";
echo "
";
}
echo "
";
?>
| Poule A |
".$team["name"]."";
}
?>
";
echo "".$team["name"]." | ";
foreach($teams_poules1 as $team2){
echo "";
if($team2 != $team){
$found = false;
foreach($matchs_poules1 as $match){
if(json_decode($match["teams_id"])[1] == $team["id"] && json_decode($match["teams_id"])[0] == $team2["id"]){
echo json_decode($match["scores"])[1]." - ".json_decode($match["scores"])[0];
$found = true;
}
if(json_decode($match["teams_id"])[0] == $team["id"] && json_decode($match["teams_id"])[1] == $team2["id"]){
echo json_decode($match["scores"])[0]." - ".json_decode($match["scores"])[1];
$found = true;
}
}
if(!$found){
echo "-";
}
}
else{
echo "X";
}
echo " | ";
}
echo "";
$i++;
}
?>
| Poule B |
".$team["name"]."";
}
?>
";
echo "".$team["name"]." | ";
foreach($teams_poules2 as $team2){
echo "";
if($team2 != $team){
$found = false;
foreach($matchs_poules2 as $match){
if(json_decode($match["teams_id"])[1] == $team["id"] && json_decode($match["teams_id"])[0] == $team2["id"]){
echo json_decode($match["scores"])[1]." - ".json_decode($match["scores"])[0];
$found = true;
}
if(json_decode($match["teams_id"])[0] == $team["id"] && json_decode($match["teams_id"])[1] == $team2["id"]){
echo json_decode($match["scores"])[0]." - ".json_decode($match["scores"])[1];
$found = true;
}
}
if(!$found){
echo "-";
}
}
else{
echo "X";
}
echo " | ";
}
echo "";
$i++;
}
?>
|
Badminton |
Futsal |
Basket |
Handball |
Volley |
Bear & Run |
Spectateurs |
TOTAL |
Rang |
$values){
if($i % 2 == 0){
echo "";
}
else{
echo "
";
}
echo "| ".$key." | ";
$j = 0;
foreach($values as $val){
if($j != 8){
echo "".$val." | ";
}
else{
$rank = "";
switch($val){
case 1:
$rank = " gold-leader";
break;
case 2:
$rank = " silver-leader";
break;
case 3:
$rank = " bronze-leader";
break;
default:
break;
}
echo "#".$val." | ";
}
$j++;
}
echo "
";
$i++;
}
?>