Grosse évolution avec, entre autres, l'implémentation des alertes par SMS et email

This commit is contained in:
2026-10-07 10:06:20 +00:00
parent 0a2ec261ec
commit 2c1d1a51e4
17 changed files with 1551 additions and 11 deletions
+171 -3
View File
@@ -29,7 +29,7 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
if (!isset($_SESSION['Bateaux']['origine'])) $_SESSION['Bateaux']['origine'] = "";
if (!isset($_SESSION['Bateaux']['tri_liste'])) $_SESSION['Bateaux']['tri_liste'] = "Flotte";
if (!isset($_SESSION['Bateaux']['sens_tri_liste'])) $_SESSION['Bateaux']['sens_tri_liste'] = "ASC";
if (!isset($_SESSION['Bateaux']['type_details_bateau'])) $_SESSION['Bateaux']['type_details_bateau'] = "resume"; // 'resume' ou 'gerer_les_acces'
if (!isset($_SESSION['Bateaux']['type_details_bateau'])) $_SESSION['Bateaux']['type_details_bateau'] = "resume"; // 'resume', 'gerer_les_acces' ou 'alertes'
if (!isset($_SESSION['Bateaux']['bateau']['Cle_primaire'])) $_SESSION['Bateaux']['bateau']['Cle_primaire'] = 0;
if (!isset($_SESSION['Bateaux']['bateau']['Nom'])) $_SESSION['Bateaux']['bateau']['Nom'] = "";
if (!isset($_SESSION['Bateaux']['bateau']['ID_Flotte'])) $_SESSION['Bateaux']['bateau']['ID_Flotte'] = 0;
@@ -148,7 +148,7 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
//===================================
case "type_details_bateau":
{
if (isset($_GET['type']) && in_array($_GET['type'], array('resume', 'gerer_les_acces'), true)) $_SESSION['Bateaux']['type_details_bateau'] = $_GET['type'];
if (isset($_GET['type']) && in_array($_GET['type'], array('resume', 'gerer_les_acces', 'alertes'), true)) $_SESSION['Bateaux']['type_details_bateau'] = $_GET['type'];
$_SESSION['Bateaux']['ancre'] = "";
break;
}
@@ -530,6 +530,53 @@ $requete .= ' TB_Bateaux.Date_derniere_maj AS Date_derniere_maj, ';
exit();
}
//------------------------------------------------------------------------------------------------------------
// Alertes (synthèse §51, étape E) : chacun ne règle que SES préférences et SON numéro ; réactivation d'une
// suspension : administrateur, ou droit d'inviter sur ce bateau (Creation_profils). Redirection après action.
if (isset($_POST['enregistrer_preferences_alertes']) || isset($_POST['enregistrer_telephone']) || isset($_POST['envoyer_code_telephone'])
|| isset($_POST['verifier_code_telephone']) || isset($_POST['reactiver_suspension']))
{
$id_sm = (int)$_SESSION['shipmember']['Cle_primaire'];
if (isset($_POST['enregistrer_preferences_alertes']))
{
$sms = !empty($_POST['alertes_sms']);
Enregistrer_preferences_alertes($id_sm, $bateau['Cle_primaire'], !empty($_POST['alertes_email']), $sms);
$_SESSION['Bateaux']['flash_information'] = t("Vos préférences d'alerte sont enregistrées.");
if ($sms && !Telephone_shipmember($id_sm)['verifie'])
$_SESSION['Bateaux']['flash_information'] .= ' '.t("Les SMS ne partiront qu'une fois votre numéro vérifié (ci-dessous).");
}
else if (isset($_POST['enregistrer_telephone']))
{
$erreur = Enregistrer_telephone($id_sm, (string)($_POST['telephone'] ?? ''), Telephone_shipmember($id_sm)['id_pays']);
if ($erreur == '') $_SESSION['Bateaux']['flash_information'] = t("Numéro enregistré.");
else $_SESSION['Bateaux']['flash_erreur'] = $erreur;
}
else if (isset($_POST['envoyer_code_telephone']))
{
$resultat = Envoyer_code_telephone($id_sm);
$_SESSION['Bateaux'][$resultat['ok'] ? 'flash_information' : 'flash_erreur'] = $resultat['message'];
}
else if (isset($_POST['verifier_code_telephone']))
{
$erreur = Verifier_code_telephone($id_sm, (string)($_POST['code_telephone'] ?? ''));
if ($erreur == '') $_SESSION['Bateaux']['flash_information'] = t("Votre numéro est vérifié : vous recevrez les alertes par SMS.");
else $_SESSION['Bateaux']['flash_erreur'] = $erreur;
}
else
{
if ($est_administrateur || (int)($acces_profil['Creation_profils'] ?? 0) == 1)
{
if (Reactiver_suspension((int)$_POST['reactiver_suspension'], $bateau['Cle_primaire'], $id_sm)) $_SESSION['Bateaux']['flash_information'] = t("Alertes réactivées pour tous les destinataires.");
else $_SESSION['Bateaux']['flash_erreur'] = t("Cette suspension n'existe pas ou a déjà été levée.");
}
else $_SESSION['Bateaux']['flash_erreur'] = t("Votre type d'accès ne permet pas de réactiver les alertes.");
}
$_SESSION['Bateaux']['type_details_bateau'] = "alertes";
Fermeture_bdd();
header('Location: bateaux.php');
exit();
}
if (isset($_POST['creer_invitation']))
{
if (!$peut_inviter) $_SESSION['Bateaux']['flash_erreur'] = t("Vous n'avez pas le droit d'inviter sur ce bateau.");
@@ -644,6 +691,19 @@ $requete .= ' TB_Bateaux.Date_derniere_maj AS Date_derniere_maj, ';
Liberation_jeu_de_resultat_bdd($reponse);
break;
}
//-------------------------------------------------------------------------------------------------------
// Alertes (synthèse §51, étape E) :
case "alertes":
{
$vue_alertes = array(
'preferences' => Preferences_alertes($_SESSION['shipmember']['Cle_primaire'], $bateau['Cle_primaire']),
'telephone' => Telephone_shipmember($_SESSION['shipmember']['Cle_primaire']),
'alertes' => Alertes_bateau($bateau['Cle_primaire'], 30),
'suspensions' => Suspensions_actives($bateau['Cle_primaire']),
'peut_reactiver' => ($est_administrateur || (int)($acces_profil['Creation_profils'] ?? 0) == 1));
break;
}
//-------------------------------------------------------------------------------------------------------
// Données du bateau (synthèse §50) : lues dans la base de la génération consultée (active par défaut), par
// une connexion dédiée - la connexion principale du site n'est pas touchée.
@@ -886,13 +946,121 @@ $requete .= ' TB_Bateaux.Date_derniere_maj AS Date_derniere_maj, ';
echo '<div class="boutons_haut_de_page">';
echo '<div>';
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=resume"';
if ($_SESSION['Bateaux']['type_details_bateau'] != "gerer_les_acces") echo ' class="actif" '; echo '>'.t("Données du bateau").'</a>';
if ($_SESSION['Bateaux']['type_details_bateau'] == "resume") echo ' class="actif" '; echo '>'.t("Données du bateau").'</a>';
echo '</div>';
echo '<div>';
echo '<a title="" href="bateaux.php?action=type_details_bateau&type=alertes"';
if ($_SESSION['Bateaux']['type_details_bateau'] == "alertes") echo ' class="actif" '; echo '>'.t("Alertes").'</a>';
echo '</div>';
echo '</div>';
echo '<div class="corps_details_bateau">';
switch($_SESSION['Bateaux']['type_details_bateau'])
{
//===========================================================
// Alertes (synthèse §51, étape E)
case "alertes":
{
$p = $vue_alertes['preferences'];
$tel = $vue_alertes['telephone'];
echo '<div class="alertes">';
// --- Mes alertes pour ce bateau ---
echo '<section class="bloc_alertes">';
echo '<h2>'.t("Mes alertes pour ce bateau").'</h2>';
if (!$p['a_un_acces']) echo '<p>'.t("Vous n'avez pas d'accès à ce bateau : vous ne recevez pas ses alertes.").'</p>';
else
{
echo '<p class="explication">'.t("Vous recevez les alarmes prévues par e-mail ou par SMS dans la configuration du bateau, sur les moyens cochés ci-dessous, ainsi que la perte et le retour de sa connexion.").'</p>';
echo '<form action="bateaux.php" method="post" class="preferences_alertes">'.Champ_jeton_csrf();
echo '<label><input type="checkbox" name="alertes_email" value="1"'.($p['email'] ? ' checked' : '').'> '.t("Par e-mail").'</label>';
echo '<label><input type="checkbox" name="alertes_sms" value="1"'.($p['sms'] ? ' checked' : '').'> '.t("Par SMS").'</label>';
echo '<button type="submit" name="enregistrer_preferences_alertes">'.t("Enregistrer").'</button>';
echo '</form>';
if ($p['sms'] && !$tel['verifie']) echo '<p class="avertissement">'.t("SMS en attente : votre numéro doit être vérifié pour que les SMS partent.").'</p>';
}
echo '</section>';
// --- Mon numéro de téléphone (dès que les SMS sont cochés, ou qu'un numéro existe) ---
if ($p['a_un_acces'] && ($p['sms'] || $tel['telephone'] != ''))
{
echo '<section class="bloc_alertes">';
echo '<h2>'.t("Mon numéro pour les SMS").'</h2>';
echo '<form action="bateaux.php" method="post" class="telephone_alertes">'.Champ_jeton_csrf();
echo '<input type="tel" name="telephone" value="'.htmlspecialchars($tel['telephone']).'" placeholder="+33 6 12 34 56 78" maxlength="24">';
echo '<button type="submit" name="enregistrer_telephone">'.t("Enregistrer").'</button>';
echo $tel['verifie'] ? '<span class="statut statut_actif">'.t("Vérifié").'</span>' : '<span class="statut statut_suspendu">'.t("Non vérifié").'</span>';
echo '</form>';
if (!$tel['verifie'] && $tel['telephone'] != '')
{
echo '<form action="bateaux.php" method="post" class="code_telephone">'.Champ_jeton_csrf();
echo '<button type="submit" name="envoyer_code_telephone">'.($tel['code_en_cours'] ? t("Renvoyer un code") : t("Recevoir un code par SMS")).'</button>';
echo '</form>';
if ($tel['code_en_cours'])
{
echo '<form action="bateaux.php" method="post" class="code_telephone">'.Champ_jeton_csrf();
echo '<input type="text" name="code_telephone" inputmode="numeric" autocomplete="one-time-code" maxlength="6" placeholder="123456">';
echo '<button type="submit" name="verifier_code_telephone">'.t("Valider le code").'</button>';
echo '</form>';
}
}
echo '<p class="explication">'.t("Ce numéro est celui de votre profil : le modifier ici ou dans votre profil demande une nouvelle vérification.").'</p>';
echo '</section>';
}
// --- Alertes suspendues ---
if (count($vue_alertes['suspensions']) > 0)
{
echo '<section class="bloc_alertes">';
echo '<h2>'.t("Alertes suspendues").'</h2>';
echo '<p class="explication">'.t("Une alarme qui se déclenche et s'arrête trop souvent suspend ses alertes (e-mail et SMS) pour tous les destinataires : sa configuration est à vérifier. Le son, la LED et les messages à bord ne sont pas concernés.").'</p>';
echo '<table>';
foreach ($vue_alertes['suspensions'] as $suspension)
{
echo '<tr><td class="date_alerte"><span data-date-utc="'.htmlspecialchars(str_replace(' ', 'T', $suspension['Date_suspension']).'Z').'"></span></td>';
echo '<td class="nom_alerte">'.htmlspecialchars((string)$suspension['Nom_event']).'</td><td>'.htmlspecialchars($suspension['Motif']).'</td><td>';
if ($vue_alertes['peut_reactiver'])
{
echo '<form action="bateaux.php" method="post">'.Champ_jeton_csrf()
.'<button type="submit" name="reactiver_suspension" value="'.(int)$suspension['ID'].'">'.t("Réactiver").'</button></form>';
}
echo '</td></tr>';
}
echo '</table>';
echo '</section>';
}
// --- Alertes envoyées ---
echo '<section class="bloc_alertes">';
echo '<h2>'.t("Dernières alertes").'</h2>';
if (count($vue_alertes['alertes']) == 0) echo '<p class="explication">'.t("Aucune alerte pour ce bateau.").'</p>';
else
{
$libelles_types = array('declenchement' => t("Alarme"), 'fin' => t("Fin d'alarme"), 'perte_connexion' => t("Connexion perdue"),
'retour_connexion' => t("Connexion rétablie"), 'suspension' => t("Alertes suspendues"));
$libelles_statuts = array('a_envoyer' => t("en cours d'envoi"), 'envoyee' => t("envoyée"), 'pendant_coupure' => t("pendant une coupure (comptée)"),
'suspendue' => t("non envoyée (suspendue)"), 'sans_destinataire' => t("sans destinataire"));
echo '<table>';
echo '<tr><th>'.t("Date").'</th><th>'.t("Type").'</th><th>'.t("Alarme").'</th><th>'.t("Envoi").'</th></tr>';
foreach ($vue_alertes['alertes'] as $alerte)
{
$envoi = $libelles_statuts[$alerte['Statut']] ?? $alerte['Statut'];
if ($alerte['Statut'] == 'envoyee') $envoi .= ' ('.(int)$alerte['Envoyes'].((int)$alerte['Echecs'] > 0 ? ', '.(int)$alerte['Echecs'].' '.t("échec(s)") : '').')';
echo '<tr class="alerte_'.htmlspecialchars($alerte['Type']).'">';
echo '<td class="date_alerte"><span data-date-utc="'.htmlspecialchars(str_replace(' ', 'T', $alerte['Date_evenement']).'Z').'"></span></td>';
echo '<td>'.($libelles_types[$alerte['Type']] ?? htmlspecialchars($alerte['Type'])).'</td>';
echo '<td class="nom_alerte">'.htmlspecialchars((string)$alerte['Nom_event']).'</td>';
echo '<td>'.$envoi.'</td>';
echo '</tr>';
}
echo '</table>';
}
echo '</section>';
echo '</div>';
break;
}
//===========================================================
case "gerer_les_acces":
{
+233
View File
@@ -77,6 +77,19 @@ Fichier bateaux.php
background-color: var(--bleu_koriolan);
color: var(--bleu_koriolan_fonce);
}
#Bateaux #details_bateau .graphique .top_part_graph .vars .var{
cursor: pointer;
}
#Bateaux #details_bateau .graphique .top_part_graph .vars .var.actif {
border-radius: 5px;
background-color: var(--bleu_koriolan_transparent);
color: var(--bleu_koriolan_fonce);
font-weight: 600;
}
.page_principale {
width: 80% !important;
max-width: unset !important;
@@ -109,6 +122,23 @@ Fichier bateaux.php
padding: 0px;
}
#Bateaux #details_bateau .onglets a {
background-color: var(--bleu_koriolan_fonce);
border-radius: 1em 1em 0 0;
color: var(--blanc);
display: inline-block;
padding: 3px 20px;
margin: 1px 1px 0px 1px;
}
#Bateaux #details_bateau .onglets a:hover {
color: var(--bleu_koriolan);
background-color: var(--bleu_koriolan_fonce);
}
#Bateaux #details_bateau .onglets a.actif {
background-color: var(--bleu_koriolan);
color: var(--bleu_koriolan_fonce);
}
#Bateaux #details_bateau .corps_details_bateau {
background-color: var(--blanc_casse);
}
@@ -132,6 +162,105 @@ Fichier bateaux.php
text-align: left;
/* background-color: var(--blanc_casse); */
}
.red {
color: red;
}
.orange {
color: #ffa600;
}
.green {
color: #02a602;
}
.capteur_state{
display: block;
padding: 0px;
height: 60px;
line-height: 60px;
width: 80px;
text-align: center !important;
font-size: 1.5em;
border-radius: 5px;
}
.capteur_off{
background-color: rgba(255, 30, 0, 0.2);
color: rgb(255,30,0);
}
.consommation_instantanee {
font-size: 1em;
padding: 6px;
background-image: url(images/icone_consommation_electrique.png);
background-size: contain;
background-position: center;
background-repeat: no-repeat;
margin-right: 5px;
}
.capteur_on{
background-color: rgba(177, 251, 23, 0.3);
color: rgb(177, 251, 23);
}
#Bateaux #details_bateau .corps_details_bateau .champs .champs_description {
grid-column: 1 / span 2;
text-align: justify;
font-size:0.8em;
}
#Bateaux #details_bateau .boutons_graphique {
text-align: center;
display: grid;
grid-template-columns: 1fr ;
grid-column-gap: 20px;
align-items: center;
margin: 20px 0px 20px 0px;
}
#Bateaux #details_bateau .boutons_graphique a {
background-color: var(--bleu_koriolan_fonce);
color: var(--blanc);
width: 300px;
margin: auto;
}
#Bateaux #details_bateau .boutons_graphique a:hover {
color: var(--bleu_koriolan);
background-color: var(--bleu_koriolan_fonce);
}
#Bateaux #details_bateau .boutons_graphique a.actif {
background-color: var(--bleu_koriolan);
color: var(--bleu_koriolan_fonce);
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant {
display: grid;
grid-template-columns: 2fr 3fr 60px;
/* height: 70px; */
padding: 15px 0px 15px 0px;
margin: 2em 0px 0.2em 0px;
border-top: 1px solid var(--bleu_koriolan_fonce);
border-bottom: 1px solid var(--bleu_koriolan_fonce);
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant p{
margin: unset;
text-align : unset;
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant .titre_text{
font-size: 1.8em;
font-weight: 500;
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant .titre_desc{
/* font-size: 1.8em; */
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant .titre_capt{
display: flex;
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant .titre_icon {
background-size: contain;
background-repeat: no-repeat;
cursor: pointer;
background-position: center;
margin-right: 10px;
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant .more {
background-image: url("images/show_more.png");
}
#Bateaux #details_bateau .corps_details_bateau .titre_composant .less {
background-image: url("images/show_less.png");
}
#Bateaux #creation_bateau .champs {
display: grid;
grid-template-columns: 1fr;
@@ -143,6 +272,10 @@ Fichier bateaux.php
#Bateaux #creation_bateau .champs .champs_valeur {
text-align: left;
}
#Bateaux #creation_bateau .champs .champs_valeur select option.selection_actuelle {
color: var(--bleu_koriolan_fonce);
font-weight: bold;
}
#Bateaux #creation_bateau .champs .champs_valeur select option[disabled] {
color: var(--gris_tres_pale);
background-color: var(--gris_tres_tres_pale);
@@ -193,9 +326,18 @@ Fichier bateaux.php
height: unset !important;
margin: 20px 0px 20px 0px !important;
}
.graphique .graph {
width: 100%;
height: 100%;
position: relative;
}
.graphique .titre{
margin-bottom: 20px;
}
.top_part_graph {
display: flex;
height: 100%;
}
.var {
/* display: flex; */
flex-direction: row;
@@ -207,6 +349,36 @@ Fichier bateaux.php
.var label{
display: unset !important;
}
.date_pick form{
display: flex;
flex-direction: column;
}
.date_pick input {
width: 100%;
position: relative;
margin: auto;
}
.date_pick label {
display: grid;
grid-template-columns: 2fr 3fr;
}
.date_pick span {
position: relative;
margin: auto;
}
.date_maj_version{
display: flex;
}
.date_maj_version input,.date_maj_version select{
width: 200px !important;
margin-left: 30px !important;
margin-right: 30px !important;
}
.gestion_acces{
/* height: 100; */
@@ -231,6 +403,17 @@ Fichier bateaux.php
padding: 3px 10px;
font-size: 0.9em;
}
.download{
font-weight: 800;
padding: 0;
color: red;
}
.download:hover {
background: red;
color: var(--blanc_casse);
}
#type_acces {
height: unset;
}
@@ -284,6 +467,10 @@ form.variables input{
padding-bottom: 20px;
z-index: 50;
}
#maCarte {
height: 600px;
z-index: 1;
}
/* --------------------- POP UP EDIT ACCESS----------------------*/
#popUpAcces{
@@ -358,6 +545,9 @@ form.variables input{
font-weight: 600;
background-color: white;
}
#popUpAccesModal form .buttons_acces{
display: grid;
}
/* --------------------- GESTION DES ACCÈS (synthèse §48) ----------------------*/
@@ -498,7 +688,14 @@ form.variables input{
}
/* ------------------ Autres ---------------- */
#dateSlider{
margin-bottom: 50px !important;
margin-top: 50px !important;
}
#dateSlider .noUi-connect{
background-color: var(--bleu_koriolan);
}
@media only screen and (max-width: 580px) {
#Bateaux .boutons_haut_de_page {
grid-template-columns: minmax(50px, auto);
@@ -509,6 +706,10 @@ form.variables input{
flex-direction: column;
padding : 0;
}
.vars {
display: grid !important;
grid-template-columns: 1fr !important;
}
#popUpAccesModal{
width: 95% !important;
height: 60% !important;
@@ -520,6 +721,13 @@ form.variables input{
}
@media only screen and (max-width: 850px) {
.top_part_graph {
flex-direction: column-reverse;
}
.vars {
display: grid !important;
grid-template-columns: 1fr 1fr;
}
.page_principale {
width: 96% !important;
}
@@ -541,6 +749,10 @@ form.variables input{
width: 80%;
height: 40%;
}
#dateSlider{
margin: auto;
width: 80%;
}
}
/* Petits écrans : formulaire d'invitation sur une colonne. Placé EN FIN de fichier : le bloc "max-width: 850px"
@@ -659,3 +871,24 @@ form.variables input{
#Bateaux .entete_bateau .info_mise_a_jour.en_cours::before { content: "\21BB\00A0"; display: inline-block; animation: rotation_mise_a_jour 1.5s linear infinite; }
@keyframes rotation_mise_a_jour { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
#Bateaux .entete_bateau { height: auto; min-height: 60px; } /* place pour la ligne d'information ci-dessus */
/* --------------------- ALERTES (synthèse §51) ----------------------*/
#Bateaux .alertes .bloc_alertes { margin-bottom: 30px; text-align: left; }
#Bateaux .alertes .bloc_alertes h2 { text-align: left; margin-bottom: 10px; }
#Bateaux .alertes .explication { font-size: 0.85em; color: var(--gris_pale); text-align: left; }
#Bateaux .alertes .avertissement { color: #8a6d00; background-color: var(--jaune_post_it_transparent); padding: 6px 12px; border-radius: 8px; }
#Bateaux .alertes form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 8px 0px; }
#Bateaux .alertes form label { display: inline-flex; align-items: center; gap: 6px; margin: 0px; }
#Bateaux .alertes form input[type="checkbox"] { width: auto; margin: 0px; }
#Bateaux .alertes form input[type="tel"], #Bateaux .alertes form input[type="text"] { width: 14em; margin: 0px; }
#Bateaux .alertes form button { padding: 2px 16px; line-height: 1.8em; border-radius: 0.8em; }
#Bateaux .alertes .statut { display: inline-block; padding: 2px 10px; border-radius: 1em; font-size: 0.85em; }
#Bateaux .alertes .statut_actif { background-color: rgba(2, 166, 2, 0.12); color: #027a02; }
#Bateaux .alertes .statut_suspendu { background-color: var(--jaune_post_it_transparent); color: #8a6d00; }
#Bateaux .alertes table { width: 100%; }
#Bateaux .alertes th { text-align: left; padding: 4px 8px; font-size: 0.85em; }
#Bateaux .alertes td { text-align: left; padding: 4px 8px; border-top: 1px solid var(--gris_tres_tres_pale); font-size: 0.9em; vertical-align: middle; }
#Bateaux .alertes td.date_alerte { white-space: nowrap; width: 1%; }
#Bateaux .alertes td.nom_alerte { font-weight: 600; }
#Bateaux .alertes tr.alerte_declenchement td.nom_alerte, #Bateaux .alertes tr.alerte_perte_connexion td { color: #b71c1c; }
#Bateaux .alertes td form { margin: 0px; }
+16 -4
View File
@@ -132,6 +132,10 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
$_SESSION['shipmember']['ID_Pays'] = $_POST['ID_Pays'];
$_SESSION['shipmember']['Telephone'] = trim($_POST['Telephone']);
$_SESSION['shipmember']['Email'] = strtolower(trim($_POST['Email']));
// Numéro normalisé au format international (synthèse §51) - un seul numéro par ShipMember, utilisé pour les SMS :
$telephone_normalise = Normaliser_telephone($_SESSION['shipmember']['Telephone'], $_SESSION['shipmember']['ID_Pays']);
if ($telephone_normalise === false) $message_erreur .= t("Numéro de téléphone invalide : saisissez-le au format international (par exemple +33 6 12 34 56 78).");
else $_SESSION['shipmember']['Telephone'] = $telephone_normalise;
// Vérifications :
$message_erreur .= check_longueur_champ('prenom_titre', $_SESSION['shipmember']['Prenom'], MIN_LONGUEUR_PRENOM, MAX_LONGUEUR_PRENOM);
@@ -171,7 +175,7 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
// Création du ShipMember :
$requete = 'INSERT INTO TB_Shipmembers(Nom, Prenom, Entreprise, Rue, Code_postal, Ville, ID_PAYS, Telephone, Email, ID_LANGUAGES, Commentaires, Mdp, Date_creation_compte) VALUES (?,?,?,?,?,?,?,?,?,(SELECT ID FROM TB_Langues WHERE Prefix=?),?,?,?)';
$requete = 'INSERT INTO TB_Shipmembers(Nom, Prenom, Entreprise, Rue, Code_postal, Ville, ID_PAYS, Telephone, Email, ID_LANGUAGES, Mdp, Date_creation_compte) VALUES (?,?,?,?,?,?,?,?,?,(SELECT ID FROM TB_Langues WHERE Prefix=?),?,?)';
Requete_preparee_bdd($requete,
array(
array('s', $_SESSION['shipmember']['Nom']),
@@ -184,7 +188,6 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
array('s', $_SESSION['shipmember']['Telephone']),
array('s', $_SESSION['shipmember']['Email']),
array('s', $_SESSION['langue']),
array('s', ""),
array('s', password_hash($password, PASSWORD_DEFAULT)),
array('s', date("Y-m-d H:i:s"))),
__FILE__, __LINE__);
@@ -608,6 +611,10 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
$_SESSION['shipmember']['ID_Pays'] = $_POST['ID_Pays'];
$_SESSION['shipmember']['Telephone'] = trim($_POST['Telephone']);
$_SESSION['shipmember']['Email'] = strtolower(trim($_POST['Email']));
// Numéro normalisé au format international (synthèse §51) - un seul numéro par ShipMember, utilisé pour les SMS :
$telephone_normalise = Normaliser_telephone($_SESSION['shipmember']['Telephone'], $_SESSION['shipmember']['ID_Pays']);
if ($telephone_normalise === false) $message_erreur .= t("Numéro de téléphone invalide : saisissez-le au format international (par exemple +33 6 12 34 56 78).");
else $_SESSION['shipmember']['Telephone'] = $telephone_normalise;
if ($old_email != $_SESSION['shipmember']['Email']) $flag_new_email = true;
else $flag_new_email = false;
@@ -658,7 +665,10 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
// Si les contrôles ne sont pas invalides, on met à jour le ShipMember :
if ($message_erreur == "")
{
$requete = 'UPDATE TB_Shipmembers SET Prenom=?, Nom=?, Entreprise=?, Rue=?, Code_postal=?, Ville=?, ID_Pays=?, Telephone=?, Email=? WHERE ID=?';
// Numéro MODIFIÉ : il n'est plus vérifié pour les SMS d'alerte (synthèse §51) - affectation évaluée avant celle du numéro :
$requete = 'UPDATE TB_Shipmembers SET Prenom=?, Nom=?, Entreprise=?, Rue=?, Code_postal=?, Ville=?, ID_Pays=?,
Telephone_verifie=IF(Telephone <=> ?, Telephone_verifie, 0), Code_telephone_empreinte=IF(Telephone <=> ?, Code_telephone_empreinte, NULL),
Telephone=?, Email=? WHERE ID=?';
Requete_preparee_bdd($requete,
array(
array('s', $_SESSION['shipmember']['Prenom']),
@@ -669,6 +679,8 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
array('s', $_SESSION['shipmember']['Ville']),
array('i', $_SESSION['shipmember']['ID_Pays']),
array('s', $_SESSION['shipmember']['Telephone']),
array('s', $_SESSION['shipmember']['Telephone']),
array('s', $_SESSION['shipmember']['Telephone']),
array('s', Protection_mysql($_SESSION['shipmember']['Email'])), // On protège l'Email contre les injections car c'est lui qui va servir aux requetes tant qu'on n'a pas la Clé_primaire.
array('i', $_SESSION['shipmember']['Cle_primaire'])),
__FILE__, __LINE__);
@@ -679,7 +691,7 @@ Init_session(basename($_SERVER['SCRIPT_NAME'])); // Fonction ouvrant la session
$requete = 'UPDATE TB_Shipmembers SET Mdp=? WHERE ID=?';
Requete_preparee_bdd($requete,
array(
array('s', password_hash(Protection_mysql($_POST['Mot_de_passe_1']), PASSWORD_DEFAULT)),
array('s', password_hash($_POST['Mot_de_passe_1'], PASSWORD_DEFAULT)), // Haché tel quel (et non échappé : synthèse §47, §51)
array('i', $_SESSION['shipmember']['Cle_primaire'])),
__FILE__, __LINE__);