projects
/
cl7.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update to PHP 7.
[cl7.git]
/
php
/
participant.php
diff --git
a/php/participant.php
b/php/participant.php
index
ef92a06
..
e940f74
100644
(file)
--- a/
php/participant.php
+++ b/
php/participant.php
@@
-16,16
+16,30
@@
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
* 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)
{
*/
public function Participant($v1=NULL, $v2=NULL)
{
+ $this->authentifier($v1, $v2);
+ }
+
+ /**
+ * Est-ce que le participant existe ? C-à-d qu'il est inscrit.
+ */
+ public function existe()
+ {
+ return $this->id != 0;
+ }
+
+ private function authentifier($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
{
# 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));
}
else # Sinon c'est l'id
$res = pg_query_params("SELECT id FROM participants WHERE id = $1", array($v1));
@@
-35,18
+49,12
@@
class Participant
$this->id = pg_fetch_object($res)->id;
$this->chargerInfos();
}
$this->id = pg_fetch_object($res)->id;
$this->chargerInfos();
}
- }
-
- /**
- * Est-ce que le participant existe ? C-à-d qu'il est inscrit.
- */
- public function existe()
- {
- return $this->id != 0;
}
}
- public function chargerInfos()
+ public function chargerInfos(
$v1=NULL, $v2=NULL
)
{
{
+ $this->authentifier($v1, $v2);
+
if (!$this->existe())
return;
if (!$this->existe())
return;