function grille_admin ($gr_champ)
{
$query="SELECT phpl_clubs.nom, CLEXT.nom, phpl_matchs.buts_dom, phpl_matchs.buts_ext, phpl_matchs.id, phpl_matchs.date_reelle, phpl_journees.numero
FROM phpl_clubs, phpl_clubs as CLEXT, phpl_matchs, phpl_journees, phpl_equipes, phpl_equipes as EXT, phpl_gr_championnats
WHERE phpl_clubs.id=phpl_equipes.id_club
AND CLEXT.id=EXT.id_club
AND phpl_equipes.id=phpl_matchs.id_equipe_dom
AND EXT.id=phpl_matchs.id_equipe_ext
AND phpl_matchs.id_journee=phpl_journees.id
AND phpl_journees.id_champ=phpl_gr_championnats.id_champ
AND phpl_gr_championnats.id='$gr_champ'
AND phpl_matchs.buts_dom is null
AND phpl_matchs.buts_ext is null
AND phpl_clubs.nom!='exempte'
AND CLEXT.nom!='exempte'
ORDER by phpl_matchs.date_reelle, phpl_clubs.nom
LIMIT 0, 10";

$i=0;
$result=mysql_query($query) or die ("probleme " .mysql_error());

while ($row=mysql_fetch_array($result) and $i<10)
  {
$clubs_nom = stripslashes($row[0]);
$clubs_nom1 = stripslashes($row[1]);
$query2= "SELECT pronostic FROM phpl_pronostics, phpl_gr_championnats WHERE phpl_pronostics.id_match='$row[4]' AND phpl_gr_championnats.id='$gr_champ' AND id_membre=id_master";
$result2=mysql_query($query2) or die ("probleme " .mysql_error());
$nb_pronos= mysql_num_rows($result2);

if ($nb_pronos == "0") {$prono="0";}
{
  while ($row2=mysql_fetch_array($result2))
  {
    $prono=$row2["0"];
    if ($row2["0"] == ""){$prono="0";}
  }
}
  $date=format_date_fr_red($row[5]);



  echo "<tr><td><div class=\"blanc\">$row[6]</div></td>";
  echo "<td><div class=\"blanc\">$date</div></td>";
  echo "<td align=\"right\"><div class=\"blanc\">$clubs_nom</div></td>";

  echo "<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" >";
  echo "<tr>";
  echo "<td width=\"45\" height=\"10\" valign=\"middle\" align=\"center\">";
  echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\" width=\"50\"><tr><td>";

         if ($prono=="1")
           {
           ?>
             <img src="barre.gif" border="no" alt=""> <img src="N.gif" border="no" alt=""> <img src="2.gif"  border="no" alt="">
           <?php
           }

         if ($prono=="N")
           {
           ?>
             <img src="1.gif" border="no" alt=""> <img src="barre.gif" border="no" alt=""> <img src="2.gif"  border="no" alt="">
           <?php
           }

         if ($prono=="2")
         {
         ?>
             <img src="1.gif" border="no" alt=""> <img src="N.gif" border="no" alt=""> <img src="barre.gif"  border="no" alt="">
         <?php
         }
  
         if ($prono=="0")
         {
          ?> 
             <img src="1.gif" border="no" alt=""> <img src="N.gif" border="no" alt=""> <img src="2.gif"  border="no" alt="">
          <?php
         }
  echo "</td></tr></table>";

  echo "</td></tr></table></td>";

  echo "<td><div class=\"blanc\">$clubs_nom1</div></td>";

  $requete2="SELECT tps_avant_prono FROM phpl_gr_championnats WHERE id='$gr_champ'";
  $resultats2=mysql_query($requete2) or die ("probleme " .mysql_error());
   while ($row2=mysql_fetch_array($resultats2))
   {
    $temps_avantmatch=$row2[0];
   }

  $date_match_timestamp=format_date_timestamp($row[5]);
  $date_actuelle=time();
  $ecart_secondes=$date_match_timestamp-$date_actuelle;
  $ecart_heures = floor($ecart_secondes / (60*60))-$temps_avantmatch;
  $ecart_minutes = floor($ecart_secondes / 60)-$temps_avantmatch*60;
  $ecart_jours = floor($ecart_secondes / (60*60*24)-$temps_avantmatch/60);
  $date=format_date_fr_red($row[5]);

  echo "<td align=\"center\">";
  if ($ecart_heures>48) echo "<div class=\"blanc\">$ecart_jours jours</div>";
  elseif ($ecart_heures>0) echo "<div class=\"blanc\">$ecart_heures h</div>";
  elseif ($ecart_heures == 0) echo "<div class=\"blanc\">$ecart_minutes min</div>";
  else {echo"<div class=\"blanc\">expiré</div>";}
  echo "</td>";
  echo "</tr>";
  $i++;
}

}
Example #2
0
												}
								
											}
										}
							

										// requete pour recuperer le temps avant la fin du prono
										$requete2="SELECT tps_avant_prono FROM phpl_gr_championnats WHERE id='$gr_champ'";
										$resultat2=mysql_query($requete2) or die ("probleme " .mysql_error());
								
										while ($row2=mysql_fetch_array($resultat2))
										{
											$temps_avantmatch=$row2[0];
										}
								
										$date_match_timestamp=format_date_timestamp($row[3]);
										$date_actuelle=time();
										$ecart_secondes=$date_match_timestamp-$date_actuelle;
										$ecart_heures = floor($ecart_secondes / (60*60))-$temps_avantmatch;
										$ecart_minutes = floor($ecart_secondes / 60)-$temps_avantmatch*60;
										$ecart_jours = floor($ecart_secondes / (60*60*24)-$temps_avantmatch/60);
										$date=format_date_fr_red($row[3]);
										$class = "noir";		
									   
										// debut d'affichage de la ligne du prono (numero de la journee, date, club receveur)
										echo "<tr class=\"".$styleClass."\">";
										if ($prono=="0")
										{
											echo "<td id=\"imgok_prono_accueil\"><img src='ico/ko_pt.png'></td>";
											$bolOk=0;
										}
 function post($request, $user)
 {
     ouverture();
     $response = new Response($request);
     if (!$this->isSecured($user)) {
         $response->body = "401";
         return $response;
     }
     $json = file_get_contents('php://input');
     if (empty($json)) {
         $response->body = "500:NO_DATA";
         return $response;
     }
     $pronos = json_decode($json);
     // récupération de l'id du championnat
     $requete = "SELECT phpl_gr_championnats.id FROM phpl_gr_championnats WHERE phpl_gr_championnats.activ_prono='1' ORDER by id desc";
     $resultat = mysql_query($requete) or die("probleme " . mysql_error());
     $row = mysql_fetch_array($resultat);
     $gr_champ = $row[0];
     foreach ($pronos as $prono) {
         $valeur_prono = $prono->prono;
         $id_match = $prono->id;
         // on récupère la date du match
         $requete = "SELECT phpl_matchs.date_reelle FROM phpl_matchs WHERE phpl_matchs.id='{$id_match}'";
         $resultat = mysql_query($requete);
         while ($row = mysql_fetch_array($resultat)) {
             $date_relle = $row[0];
         }
         // on récupère le temps avant l'expiration des pronos
         $requete = "SELECT tps_avant_prono FROM phpl_gr_championnats WHERE id='{$gr_champ}'";
         $resultat = mysql_query($requete);
         while ($row = mysql_fetch_array($resultat)) {
             $temps_avant_prono = $row[0];
         }
         $date_match_timestamp = format_date_timestamp($date_relle);
         $date_actuelle = time();
         if ($valeur_prono !== "undefined") {
             mysql_query("DELETE FROM phpl_pronostics WHERE pronostic=' '") or die("probleme " . mysql_error());
             $requete = "SELECT * FROM phpl_matchs, phpl_pronostics, phpl_membres \n\t       \t\t\t\t\t WHERE phpl_membres.pseudo='{$user}'\n\t\t\t                   AND phpl_membres.id=phpl_pronostics.id_membre\n\t\t\t                   AND phpl_pronostics.id_match=phpl_matchs.id\n\t\t\t                   AND phpl_pronostics.id_match='{$id_match}'";
             $resultat = mysql_query($requete);
             $nb_prono = mysql_num_rows($resultat);
             $requete = "SELECT id FROM phpl_membres WHERE pseudo='{$user}'";
             $resultat = mysql_query($requete);
             while ($row = mysql_fetch_array($resultat)) {
                 $id = $row["id"];
             }
             // on prend en compte le prono si la date d'expiration n'est pas passée
             if ($date_actuelle < $date_match_timestamp + $temps_avant_prono * 60) {
                 // si l'utilisateur avait déjà pronostiqué ce match...
                 if ($nb_prono == "1") {
                     if ($valeur_prono == "0") {
                         mysql_query("DELETE FROM phpl_pronostics WHERE phpl_pronostics.id_match='{$id_match}' AND phpl_pronostics.id_membre='{$id}' AND phpl_pronostics.id_champ='{$gr_champ}'") or die("probleme " . mysql_error());
                     } else {
                         mysql_query("UPDATE phpl_pronostics SET pronostic='{$valeur_prono}'\n\t\t\t\t                        WHERE phpl_pronostics.id_membre='{$id}'\n\t\t\t\t                        AND phpl_pronostics.id_match='{$id_match}'") or die("probleme " . mysql_error());
                     }
                 }
                 if ($nb_prono == "0" && $valeur_prono != "0") {
                     mysql_query("INSERT INTO phpl_pronostics (id_membre, pronostic, id_match, id_champ) VALUES ('{$id}','{$valeur_prono}','{$id_match}', '{$gr_champ}')") or die("probleme " . mysql_error());
                 } elseif ($nb_prono != "1" and $nb_prono != "0") {
                     $response->body = "500:DATA_ERROR";
                     return $response;
                 }
             }
         }
     }
     $response->code = Response::OK;
     $response->addHeader('content-type', 'text/plain');
     return $response;
 }