X-Git-Url: http://git.euphorik.ch/?a=blobdiff_plain;f=php%2Fparticipant.php;h=e2b47be621e55ed0e56f5630074c96ff2c82bc04;hb=c75da06bb039de2a43f21b6e853a72745f753dca;hp=9f718b004f83dde8d0644667f5d24abf9fa08ffc;hpb=6b9eac51629ad6fcec7da5f48b92f4c2b54c5901;p=cl7.git diff --git a/php/participant.php b/php/participant.php index 9f718b0..e2b47be 100644 --- a/php/participant.php +++ b/php/participant.php @@ -16,21 +16,25 @@ class Participant * 1) $v1 = NULL, $v2 = NULL : participant non-valide * 2) $v1 = id, $v2 = NULL : la participant existe et est chargé à partir de son id * 3) $v1 = pseudo, $v2 = password : le participant existe et est chargé à partir de son pseudo et de son password + * Le mot de passe est donné en clair. */ public function Participant($v1=NULL, $v2=NULL) { # Aucunes valeurs transmise => ce n'est pas un participant valide. if ($v1 == NULL && $v2 == NULL) return; - + if (is_string($v1) && is_string($v2)) # Aucun des arguments n'est vide alors c'est le pseudo et le password qui ont été transmis - $res = pg_query_params("SELECT id FROM participants WHERE pseudo = $1 AND password = $2", array($v1, $v2)); + { + $res = pg_query_params("SELECT id FROM participants WHERE pseudo = $1 AND password = $2", array($v1, sha1($v2))); + } else # Sinon c'est l'id $res = pg_query_params("SELECT id FROM participants WHERE id = $1", array($v1)); - if (pg_result_status($res) == PGSQL_COMMAND_OK && pg_num_rows($res) === 1) + if (pg_result_status($res) == PGSQL_TUPLES_OK && pg_num_rows($res) === 1) { $this->id = pg_fetch_object($res)->id; + $this->chargerInfos(); } } @@ -49,7 +53,7 @@ class Participant $res = pg_query_params("SELECT * FROM participants WHERE id = $1", array($this->id)); - if (pg_result_status($res) == PGSQL_COMMAND_OK && pg_num_rows($res) === 1) + if (pg_result_status($res) == PGSQL_TUPLES_OK && pg_num_rows($res) === 1) $this->info = pg_fetch_object($res); else $this->id = 0; @@ -74,7 +78,7 @@ class Participant */ static function nombre_participant_max_atteint() { - return $this->nombre_place_restante() <= 0; + return Participant::nombre_place_restante() <= 0; } /**