@@ -34,6 +34,7 @@ class UtilisateurObject
3434 private string $ email = '' ;
3535 private string $ dateInscription = '' ;
3636 private string $ ipInscription = '' ;
37+ private int $ ipPortInscription = 0 ;
3738 private int $ level = self ::LEVEL_GUEST ;
3839 private int $ id = 0 ;
3940 private bool $ isActif = true ;
@@ -120,6 +121,15 @@ public function getIpInscription(): string
120121 return $ this ->ipInscription ;
121122 }
122123
124+ /**
125+ * Port de l'@ IP d'inscription
126+ * @return int
127+ */
128+ public function getIpPortInscription (): int
129+ {
130+ return $ this ->ipPortInscription ;
131+ }
132+
123133 /**
124134 * Niveau de droits
125135 * @return int
@@ -228,6 +238,15 @@ private function setIpInscription(string $ipInscription): void
228238 $ this ->ipInscription = $ ipInscription ;
229239 }
230240
241+ /**
242+ * Port de l'@ IP d'inscription
243+ * @param int $ipPortInscription
244+ */
245+ private function setIpPortInscription (int $ ipPortInscription ): void
246+ {
247+ $ this ->ipPortInscription = $ ipPortInscription ;
248+ }
249+
231250 /**
232251 * Niveau de droits
233252 * @param int $level
@@ -329,8 +348,9 @@ public function connexion(string $user, string $pwd): bool
329348 $ maSession ->setUserObject ($ this );
330349
331350 // J'enregistre en BDD la connexion réussie
332- $ req = MaBDD::getInstance ()->prepare ('INSERT INTO login (remote_addr, date_action, membres_id) VALUES (:ipLogin, NOW(), :membresId) ' );
351+ $ req = MaBDD::getInstance ()->prepare ('INSERT INTO login (remote_addr, remote_port, date_action, membres_id) VALUES (:ipLogin, :ipPortLogin , NOW(), :membresId) ' );
333352 $ req ->bindValue (':ipLogin ' , $ _SERVER ['REMOTE_ADDR ' ]);
353+ $ req ->bindValue (':ipPortLogin ' , $ _SERVER ['REMOTE_PORT ' ], PDO ::PARAM_INT );
334354 $ req ->bindValue (':membresId ' , $ userID , PDO ::PARAM_INT );
335355
336356 $ req ->execute ();
@@ -365,6 +385,7 @@ private function charger(int $userID): bool
365385 $ this ->setUserName ($ resultat ->login );
366386 $ this ->setDateInscription ($ resultat ->date_action );
367387 $ this ->setIpInscription ($ resultat ->remote_addr );
388+ $ this ->setIpPortInscription ($ resultat ->remote_port );
368389 $ this ->setLevel ($ resultat ->lvl );
369390 $ this ->setPassword ($ resultat ->password );
370391 $ this ->setIsActif ($ resultat ->isActif );
@@ -382,12 +403,13 @@ private function charger(int $userID): bool
382403 */
383404 public function enregistrer (): void
384405 {
385- $ req = MaBDD::getInstance ()->prepare ('INSERT INTO membres (email, login, password, date_action, remote_addr, lvl, isActif, token) VALUES (:email, :login, :password, NOW(), :ipInscription, :lvl, :isActif, :token) ' );
406+ $ req = MaBDD::getInstance ()->prepare ('INSERT INTO membres (email, login, password, date_action, remote_addr, remote_port, lvl, isActif, token) VALUES (:email, :login, :password, NOW(), :ipInscription, :ipPortInscription , :lvl, :isActif, :token) ' );
386407 $ req ->bindValue (':email ' , $ this ->getEmail ());
387408 $ req ->bindValue (':login ' , $ this ->getUserNameBDD ());
388409 $ req ->bindValue (':password ' , $ this ->getPassword ());
389410 // Date est définie par NOW()
390411 $ req ->bindValue (':ipInscription ' , $ _SERVER ['REMOTE_ADDR ' ]);
412+ $ req ->bindValue (':ipPortInscription ' , $ _SERVER ['REMOTE_PORT ' ], PDO ::PARAM_INT );
391413 $ req ->bindValue (':lvl ' , $ this ->getLevel (), PDO ::PARAM_INT );
392414 $ req ->bindValue (':isActif ' , $ this ->getIsActif (), PDO ::PARAM_BOOL );
393415 $ req ->bindValue (':token ' , $ this ->getToken ());
0 commit comments