Merge branch 'master' of ssh://git@localhost/cl7
[cl7.git] / php / connexion.php
index e35e7fa..1bd4f92 100644 (file)
@@ -7,11 +7,15 @@ include_once("participant.php");
  */
 class Connexion
 {
+   # Message à destination de l'utilisateur, par exemple pour lui indiquer une erreur.
+   public $message_utilisateur = NULL;
+
    public $participant;
    
-   funtion Connexion()
+   function Connexion()
    {
-      if (!file_exists("php/config_bd.php")) {
+      if (!file_exists("php/config_bd.php"))
+      {
          echo "Le fichier 'php/config_bd.php' n'existe pas, création en cours...\n";
          if (!is_writable("."))
          {
@@ -45,22 +49,24 @@ class Connexion
 
       if (isset($_POST['effacer_cookie'])) # le membre se délogue
       {
-         setcookie("COOKIE_INFO_PATICIPANT", "", time() - 100); # 'efface' le cookie membre
-         unset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]);
-         unset($log);
+         setcookie("COOKIE_INFO_PARTICIPANT", "", time() - 100); # 'efface' le cookie membre
+         unset($_COOKIE["COOKIE_INFO_PARTICIPANT"]);
       }
 
       if (isset($_POST['log'])) # le membre se logue
-      {                
+      {
          $this->participant = new Participant($_POST['pseudo'], $_POST['password']);
          if ($this->participant->valide)
          {
-            setcookie ("COOKIE_INFO_PATICIPANT", $this->participant->info->id, time() + 31104000);             
+            setcookie("COOKIE_INFO_PARTICIPANT", $this->participant->info->id, time() + 31104000);
+            $this->message_utilisateur = "Loggation ok";
          }
+         else
+            $this->message_utilisateur = "Erreur de loggation";
       }
-      else if (isset($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"])) # le cookie existe deja chez le participant
+      else if (isset($_COOKIE["COOKIE_INFO_PARTICIPANT"])) # le cookie existe deja chez le participant
       {
-         $this->participant = new Participant($HTTP_COOKIE_VARS["COOKIE_INFO_PATICIPANT"]);
+         $this->participant = new Participant($_COOKIE["COOKIE_INFO_PARTICIPANT"]);
       }
       else
       {