if (($e - $nb_row_winner) % pow(2, $f - $col) == pow(2, $f - 1 - $col)) { if ($finale >= 1) { $numero = ++${"numeroL{$finale}"}; $numero2 = $numero + $finale; echo '<td align=left>'; // case match looser 1 echo '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>'; echo '<td>'; $id = id_match_finale('L', $finale, $numero, $s_tournois, $op, $status); show_match_finale($id, $op); echo '</td>'; // end case match 1 echo '<td valign="bottom"><img src="images/arbre_ligneH2.gif"></td>'; // case match looser 2 echo '<td align="left">'; $id = id_match_finale('L', $finale, $numero2, $s_tournois, $op, $status); show_match_finale($id, $op); echo '</td>'; // end match echo '</td>'; if ($numero % 2 == 1) { echo '<td background="images/arbre_ligneH.gif" style="background-repeat: repeat-x;background-position: bottom;" width=100%><img src="images/spacer.gif"></td>'; } else { echo '<td background="images/arbre_ligneH.gif" style="background-repeat: repeat-x;background-position: top;" width=100%><img src="images/spacer.gif"></td>'; } echo '</tr></table>'; // end case match 2 echo '</td>'; // calcul du tree apres un match if ($finale > 1) { if ($numero % 2 == 1) {
function calcul_finales($id) { global $db, $dbprefix, $s_tournois, $modeelimination_tournois, $nb_finales_winner_tournois, $nb_finales_looser_tournois; /*** verification securite ***/ //verif_admin_tournois($s_joueur,$s_tournois); /*** creation du match suivant ***/ $type_match = type_match($id); if (match_fini($id) && $type_match != 'P') { $n_finale = no_finale($id); $no = no_match($id); $equipe_g = equipe_gagnante($id); $equipe_p = equipe_perdante($id); $forfait_perdant = 0; /** pour ne pas envoyer le perdant disqualifié/forfait winner dans le looser **/ if (status_participe($equipe_p, $s_tournois) != 'P') { $forfait_perdant = 1; } /*echo "final: 1/$n_finale $type_match<BR>"; echo "n°: $no<BR>"; echo "equipe gagnante: $equipe_g<BR>"; echo "equipe perdante: $equipe_p<BR><BR>"; */ // si le match n'est pas nul if (!($equipe_g == 0 && $equipe_p == 0)) { // si le match est dans le winner if ($type_match == 'W') { // pour les matchs gagnants du winner if (!($modeelimination_tournois == 'S' && $n_finale == 1) && !($modeelimination_tournois == 'D' && $n_finale == 0)) { $next_finale = floor($n_finale / 2); $next_no = round($no / 2); if ($no % 2 == 1) { $next_pos = 1; } else { $next_pos = 2; } /* echo "equipe gagnante: $equipe_g<BR>"; echo "next final: 1/$next_finale W <BR>"; echo "next n°: $next_no<BR>"; echo "next pos°: $next_pos<BR>"; */ $next_id = id_match_finale('W', $next_finale, $next_no, $s_tournois, 'admin'); //echo "next id: $next_id<BR><BR>"; $db->update("{$dbprefix}matchs"); $db->set("equipe{$next_pos} = {$equipe_g}"); $db->where("id = {$next_id}"); $db->exec(); } // pour les perdants des matchs du winner du 1er tour if ($modeelimination_tournois == 'D' && $n_finale == $nb_finales_looser_tournois) { $next_finale = $n_finale / 2; $next_no = $n_finale / 2 + 1 - round($no / 2); if ($no % 2 == 0) { $next_pos = 1; } else { $next_pos = 2; } /*echo "equipe perdante: $equipe_p<BR><BR>"; echo "next final: 1/$next_finale L<BR>"; echo "next n°: $next_no<BR>"; echo "next pos°: $next_pos<BR>"; */ $next_id = id_match_finale('L', $next_finale, $next_no, $s_tournois, 'admin'); //echo "next id: $next_id<BR><BR>"; $db->update("{$dbprefix}matchs"); $db->set("equipe{$next_pos} = {$equipe_p}"); if ($forfait_perdant) { $db->set("statusequipe = 'F{$next_pos}'"); } $db->where("id = {$next_id}"); $db->exec(); } elseif ($modeelimination_tournois == 'D' && $n_finale < $nb_finales_looser_tournois && $n_finale != 0) { $next_finale = $n_finale; $next_no = $no + $n_finale; $next_pos = 1; /*echo "equipe perdante: $equipe_p<BR><BR>"; echo "next final: 1/$next_finale L<BR>"; echo "next n°: $next_no<BR>"; echo "next pos°: $next_pos<BR>"; */ $next_id = id_match_finale('L', $next_finale, $next_no, $s_tournois, 'admin'); //echo "next id: $next_id<BR><BR>"; $db->update("{$dbprefix}matchs"); $db->set("equipe{$next_pos} = {$equipe_p}"); if ($forfait_perdant) { $db->set("statusequipe = 'F{$next_pos}'"); } $db->where("id = {$next_id}"); $db->exec(); } } else { // pour les matchs gagnants du looser autre que la finale (la L 1.2) if ($n_finale != 1 || $no != 2) { // si c le 1er tour if ($no <= $n_finale) { $next_finale = $n_finale; $next_no = $no + $n_finale; $next_pos = 2; /*echo "equipe gagnante: $equipe_g<BR>"; echo "next final: 1/$next_finale L <BR>"; echo "next n°: $next_no<BR>"; echo "next pos°: $next_pos<BR>"; */ $next_id = id_match_finale('L', $next_finale, $next_no, $s_tournois, 'admin'); //echo "next id: $next_id<BR><BR>"; $db->update("{$dbprefix}matchs"); $db->set("equipe{$next_pos} = {$equipe_g}"); $db->where("id = {$next_id}"); $db->exec(); } else { $next_finale = floor($n_finale / 2); $next_no = round(($no - $n_finale) / 2); if ($no % 2 == 1) { $next_pos = 1; } else { $next_pos = 2; } /*echo "equipe gagnante: $equipe_g<BR>"; echo "next final: 1/$next_finale L <BR>"; echo "next n°: $next_no<BR>"; echo "next pos°: $next_pos<BR>"; */ $next_id = id_match_finale('L', $next_finale, $next_no, $s_tournois, 'admin'); //echo "next id: $next_id<BR><BR>"; $db->update("{$dbprefix}matchs"); $db->set("equipe{$next_pos} = {$equipe_g}"); $db->where("id = {$next_id}"); $db->exec(); } } elseif ($n_finale == 1 && $no == 2) { $next_finale = 0; $next_no = 1; $next_pos = 2; /*echo "equipe gagnante: $equipe_g<BR>"; echo "next final: GRAND FINAL W <BR>"; echo "next n°: $next_no<BR>"; */ $next_id = id_match_finale('W', $next_finale, $next_no, $s_tournois, 'admin'); //echo "next id: $next_id<BR><BR>"; $db->update("{$dbprefix}matchs"); $db->set("equipe{$next_pos} = {$equipe_g}"); $db->where("id = {$next_id}"); $db->exec(); } } } } }