+ $this->traiter_donnees_inscription();
+ if (!$this->login_deja_pris() && # vérification des données
+ $this->donnees_inscription_valides() &&
+ $_POST['accord'] == "on"
+ )
+ {
+ mysql_query("BEGIN TRANSACTION");
+ mysql_query("
+ INSERT INTO participants
+ (pseudo, password, clan_nom, clan_tag, nom, prenom, age, e_mail, remarques)
+ VALUES (
+ '".addslashes($_POST['pseudo'])."',
+ '".addslashes($_POST['pass1'])."',
+ '".addslashes($_POST['clan_nom'])."',
+ '".addslashes($_POST['clan_tag'])."',
+ '".addslashes($_POST['nom'])."',
+ '".addslashes($_POST['prenom'])."',
+ '".addslashes($_POST['age'])."',
+ '".addslashes($_POST['e_mail'])."',
+ '".addslashes($_POST['remarques'])."'
+ )"
+ );
+ $id = mysql_insert_id();
+ $this->set_periodes($id);
+ mysql_query("COMMIT");
+
+ $this->participant = new participant($_POST['pseudo'], $_POST['pass1']);
+ setcookie("COOKIE_INFO_PARTICIPANT", $this->participant->info->id, time() + 31104000);
+ $this->nouvel_inscrit = TRUE;
+ }
+ }
+ # un participant modifie ses infos
+ else if(isset($_POST['modification_participant']) && $this->participant->valide)
+ {
+ if ($this->config->get("inscription_terminees"))
+ return;
+
+ $this->traiter_donnees_inscription();
+ if (!$this->login_deja_pris() && $this->donnees_inscription_valides())
+ {
+ mysql_query("BEGIN TRANSACTION");
+ mysql_query("UPDATE participants SET pseudo = '".addslashes($_POST['pseudo'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET password = '".addslashes($_POST['pass1'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET clan_nom = '".addslashes($_POST['clan_nom'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET clan_tag = '".addslashes($_POST['clan_tag'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET nom = '".addslashes($_POST['nom'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET prenom = '".addslashes($_POST['prenom'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET age = '".addslashes($_POST['age'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET e_mail = '".addslashes($_POST['e_mail'])."' WHERE id = " . $this->participant->info->id);
+ mysql_query("UPDATE participants SET remarques = '".addslashes($_POST['remarques'])."' WHERE id = " . $this->participant->info->id);
+ $this->set_periodes($this->participant->info->id);
+ mysql_query("COMMIT");
+ //header("Location: /inscrits.html");
+ $this->message_utilisateur = "Les modifications ont été enregistrées";
+ $page = "inscrits"; // TODO : moche car la page ne va plus correspondre à l'url
+ }
+ }
+ # vote pour des jeux (autorisé même lorsque les inscriptions sont terminées)
+ else if (isset($_POST['set_jeux_joues']) && $this->participant->valide)
+ {
+ $votes = $_POST['votes'];
+ if (!$votes)
+ $votes = array();
+
+ mysql_query("BEGIN TRANSACTION");
+
+ # l'utilisateur peut proposer le nom d'un jeu qui ne se trouve pas dans la liste
+ $jeu = trim($_POST['jeu']);
+ if ($jeu !== '')
+ {
+ mysql_query("INSERT INTO jeux (nom) VALUES ('".addslashes($jeu)."')");
+ $id = mysql_insert_id();
+ if ($id != 0) # si le jeu se trouve déjà dans la liste alors $id == 0
+ array_unshift($votes, $id);
+ }
+
+ # suppression des anciens votes (remplacement par les nouveaux)
+ mysql_query("DELETE FROM jeux_choisis WHERE participant_id = " . $this->participant->info->id);
+
+ # traite les trois premiers votes
+ for ($i = 0; $i < count($votes) && $i < $this->config->get('nb_votes_jeux'); $i++)
+ {
+ mysql_query("INSERT INTO jeux_choisis (participant_id, jeu_id) VALUES (".$this->participant->info->id.", ".(int)$votes[$i].")");
+ }
+
+ mysql_query("COMMIT");
+ }
+ }