X-Git-Url: http://git.euphorik.ch/?p=cl7.git;a=blobdiff_plain;f=php%2Fcontroller.php;h=a42051af08f3d66655e8369167c9ed32374b53fd;hp=41381ac913c97be33ce092037a8dd05b4b960597;hb=424a8f0a34fc72fe64daaac4686f991a298933a3;hpb=912c54815fb34d93de674af2bcf3acc85ce7421d diff --git a/php/controller.php b/php/controller.php index 41381ac..a42051a 100644 --- a/php/controller.php +++ b/php/controller.php @@ -62,7 +62,7 @@ class Controller $this->set_periodes($id); pg_query("COMMIT"); - $this->participant = new participant($_POST['pseudo'], $_POST['pass1']); + $this->participant->chargerInfos($_POST['pseudo'], $_POST['pass1']); setcookie("COOKIE_INFO_PARTICIPANT", $this->participant->info->id, time() + 31104000); $this->nouvel_inscrit = TRUE; } @@ -74,11 +74,12 @@ class Controller return; $this->traiter_donnees_inscription(); - if (!$this->login_deja_pris() && $this->donnees_inscription_valides()) + if (!$this->login_deja_pris() && $this->donnees_inscription_valides(true)) { pg_query("BEGIN"); pg_query_params("UPDATE participants SET pseudo = $1 WHERE id = $2", array($_POST['pseudo'], $this->participant->info->id)); - pg_query_params("UPDATE participants SET password = $1 WHERE id = $2", array(sha1($_POST['pass1']), $this->participant->info->id)); + if ($_POST['pass1'] != '') // Uniquement si un nouveau password est donné. + pg_query_params("UPDATE participants SET password = $1 WHERE id = $2", array(sha1($_POST['pass1']), $this->participant->info->id)); pg_query_params("UPDATE participants SET clan_nom = $1 WHERE id = $2", array($_POST['clan_nom'], $this->participant->info->id)); pg_query_params("UPDATE participants SET clan_tag = $1 WHERE id = $2", array($_POST['clan_tag'], $this->participant->info->id)); pg_query_params("UPDATE participants SET nom = $1 WHERE id = $2", array($_POST['nom'], $this->participant->info->id)); @@ -108,7 +109,7 @@ class Controller $jeu = trim($_POST['jeu']); if ($jeu !== '') { - if(@pg_query_params("INSERT INTO jeux (nom) VALUES ($1)", array($jeu))) + if(@pg_query_params("INSERT INTO jeux (participant_id, nom, type, url) VALUES ($1, $2, $3, $4)", array($this->participant->info->id, $jeu, $_POST['type'], $_POST['url']))) { $row = pg_fetch_row(pg_query("SELECT LASTVAL()")); $id = $row[0]; @@ -163,14 +164,15 @@ class Controller /** * Renvoie TRUE si les données d'une inscription sont valides (POST). + * $maj : égal 'TRUE' si c'est une mise à jour, dans ce cas le password est traité différement */ - private function donnees_inscription_valides() + private function donnees_inscription_valides($maj = FALSE) { return - $_POST['pseudo'] != "" && - $_POST['pass1'] != "" && + $_POST['pseudo'] != "" && + ($maj || $_POST['pass1'] != "") && $_POST['pass1'] == $_POST['pass2'] && - strlen($_POST['pass1']) >= 3 && + (($maj && $_POST['pass1'] == "") || strlen($_POST['pass1']) >= 3) && $_POST['nom'] != "" && $_POST['prenom'] != "" && $_POST['e_mail'] != "";