0d337c148950be538b38f3fc13c0126bd9334b39
3 include_once("participant.php");
6 * Connexion à la base de données et création du participant courant.
10 # Message à destination de l'utilisateur, par exemple pour lui indiquer une erreur.
11 public $message_utilisateur = NULL;
17 if (!file_exists("php/config_bd.php"))
19 echo "Le fichier 'php/config_bd.php' n'existe pas, création en cours...\n";
20 if (!is_writable("."))
22 echo "Le dossier 'php' n'est pas accessible en écriture, veuillez changer les droits et recommencer.";
25 $f = fopen("php/config_bd.php", "w");
26 fwrite($f, '<?php # encoding:utf-8
27 # Parametres de connexion à la BD
28 $SQL_HOTE = "localhost";
31 $NOM_BASE = "corcelles_lan_7";?>'
34 echo "Le fichier a été créé, veuillez le compléter et recommencer.";
38 include_once("config_bd.php");
40 $conn_bd = pg_connect(sprintf("host=%s dbname=%s user=%s password=%s", $SQL_HOTE, $NOM_BASE, $SQL_LOGIN, $SQL_PASS));
43 echo "Connexion à la base de données impossible. Voir le fichier 'php/config_bd.php'";
47 //mysql_set_charset("UTF8");
48 //mysql_query('SET AUTOCOMMIT=0');
50 if (isset($_POST['effacer_cookie'])) # le membre se délogue
52 setcookie("COOKIE_INFO_PARTICIPANT", "", time() - 100); # 'efface' le cookie membre
53 unset($_COOKIE["COOKIE_INFO_PARTICIPANT"]);
56 if (isset($_POST['log'])) # le membre se logue
58 $this->participant
= new Participant($_POST['pseudo'], $_POST['password']);
59 if ($this->participant
->existe())
61 setcookie("COOKIE_INFO_PARTICIPANT", $this->participant
->info
->id
, time() +
31104000);
62 $this->message_utilisateur
= "Loggation ok";
65 $this->message_utilisateur
= "Erreur de loggation";
67 else if (isset($_COOKIE["COOKIE_INFO_PARTICIPANT"])) # le cookie existe deja chez le participant
69 $this->participant
= new Participant($_COOKIE["COOKIE_INFO_PARTICIPANT"]);
73 $this->participant
= new Participant();