Files
ms1inscription-v5/mobile.php

217 lines
7.4 KiB
PHP

<?php
define('MS1_INSCR_GESTION_ENTRY', true);
require_once('php/inc_start_time.php');
require_once('php/inc_fonctions.php');
require_once('php/inc_fx_messages.php');
require_once('php/inc_fx_compte.php');
require_once('php/inc_fx_promoteur.php');
require_once('php/inc_fx_inscriptions_gestion.php');
require_once('php/inc_fx_eve_acces_promoteur.php');
require_once('php/inc_v2_assets.php');
global $objDatabase, $vDomaine, $vPage, $vtexte_page;
if (!empty($_GET['lang'])) {
$strLangue = $_GET['lang'];
} else {
$strLangue = 'fr';
}
fxInscrGestionInitTextes($strLangue);
fxV2RegisterScript('inscr-gestion');
$vPage = 'mobile.php';
$strCode = 'mobile';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !empty($_POST['form_action']) && !isset($_SESSION['com_id'])) {
$strFormAction = base64_decode(urldecode($_POST['form_action']), true);
if ($strFormAction === 'login') {
fxLoginCompte($_POST, $strLangue);
exit;
}
}
if (!isset($_SESSION['com_id'])) {
$_SESSION['redirect_after_login'] = $_SERVER['REQUEST_URI'];
$_SESSION['affiche_pas_connexion'] = 'true';
$strMetaTitle = fxInscrGestionT('inscr_gestion_mobile_title');
$strMetaDescription = '';
$strMetaKeywords = '';
$blnBoutonRetour = false;
$footer_script = true;
require_once('inc_header.php');
?>
<div id="page">
<div id="main">
<div class="container bg-white p-3 p-xl-4">
<?php
if (isset($_SESSION['msg'])) {
echo fxMessage($_SESSION['msg'], '', $strLangue);
}
fxInscrGestionRenderLoginPage($strLangue);
?>
</div>
</div>
</div>
<?php
require_once('inc_footer.php');
exit;
}
// MSIN-4401 — Lien d'invite destiné à un autre compte : forcer déconnexion.
$intInviteCom = intval($_GET['invite_com'] ?? 0);
$strInviteSig = (string)($_GET['invite_sig'] ?? '');
$intEveForInvite = 0;
if (!empty($_GET['promoteur_eve_id'])) {
$intEveForInvite = fxInscrGestionParseEveId($_GET['promoteur_eve_id']);
}
if ($intInviteCom > 0 && $intEveForInvite > 0
&& function_exists('fxEveAccesPromoteurInviteSigValid')
&& fxEveAccesPromoteurInviteSigValid($intInviteCom, $intEveForInvite, $strInviteSig)
&& intval($_SESSION['com_id']) !== $intInviteCom) {
global $objDatabase;
$arrInviteCompte = $objDatabase->fxGetRow(
'SELECT com_id, com_prenom, com_nom, com_courriel, com_login FROM inscriptions_comptes WHERE com_id = '
. $intInviteCom . ' AND com_actif = 1 LIMIT 1'
);
$strSessionLabel = trim(
(string)($_SESSION['com_info']['com_prenom'] ?? $_SESSION['com_prenom'] ?? '')
. ' '
. (string)($_SESSION['com_info']['com_nom'] ?? '')
);
if ($strSessionLabel === '') {
$strSessionLabel = (string)($_SESSION['com_info']['com_courriel'] ?? ('#' . intval($_SESSION['com_id'])));
}
$strTargetLabel = $arrInviteCompte
? trim(($arrInviteCompte['com_prenom'] ?? '') . ' ' . ($arrInviteCompte['com_nom'] ?? ''))
: '';
if ($strTargetLabel === '' && $arrInviteCompte) {
$strTargetLabel = (string)($arrInviteCompte['com_courriel'] ?? $arrInviteCompte['com_login'] ?? ('#' . $intInviteCom));
}
if ($strTargetLabel === '') {
$strTargetLabel = '#' . $intInviteCom;
}
$strTargetMail = $arrInviteCompte ? (string)($arrInviteCompte['com_courriel'] ?? '') : '';
$strReturnPath = (string)(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?: '/mobile');
$strQs = (string)(parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY) ?: '');
if ($strQs !== '') {
$strReturnPath .= '?' . $strQs;
}
$strLogoutUrl = $vDomaine . '/logout.php?lang=' . urlencode($strLangue)
. '&return=' . rawurlencode($strReturnPath);
$strStayUrl = $vDomaine . ($strLangue === 'en' ? '/account' : '/compte');
$strMetaTitle = fxInscrGestionT('inscr_gestion_mobile_title');
$strMetaDescription = '';
$strMetaKeywords = '';
$blnBoutonRetour = false;
$footer_script = false;
$strMailPart = ($strTargetMail !== '')
? ' (' . htmlspecialchars($strTargetMail, ENT_QUOTES, 'UTF-8') . ')'
: '';
$strSignedAs = str_replace(
'%name%',
'<strong>' . htmlspecialchars($strSessionLabel, ENT_QUOTES, 'UTF-8') . '</strong>',
fxInscrGestionT('mobile_invite_conflict_signed_as')
);
$strInviteFor = str_replace(
array('%name%', '%mail_part%'),
array(
'<strong>' . htmlspecialchars($strTargetLabel, ENT_QUOTES, 'UTF-8') . '</strong>',
$strMailPart,
),
fxInscrGestionT('mobile_invite_conflict_for')
);
require_once('inc_header.php');
?>
<div id="page">
<div id="main">
<div class="container bg-white p-3 p-xl-4">
<div class="alert alert-warning" role="alert">
<p class="mb-2"><?php echo $strSignedAs; ?></p>
<p class="mb-3"><?php echo $strInviteFor; ?></p>
<a class="btn btn-primary rounded-0 mr-2" href="<?php echo htmlspecialchars($strLogoutUrl, ENT_QUOTES, 'UTF-8'); ?>">
<?php echo htmlspecialchars(fxInscrGestionT('mobile_invite_conflict_btn_logout'), ENT_QUOTES, 'UTF-8'); ?>
</a>
<a class="btn btn-outline-secondary rounded-0" href="<?php echo htmlspecialchars($strStayUrl, ENT_QUOTES, 'UTF-8'); ?>">
<?php echo htmlspecialchars(fxInscrGestionT('mobile_invite_conflict_btn_stay'), ENT_QUOTES, 'UTF-8'); ?>
</a>
</div>
</div>
</div>
</div>
<?php
require_once('inc_footer.php');
exit;
}
unset($_SESSION['affiche_pas_connexion']);
$intEveId = 0;
if (!empty($_GET['promoteur_eve_id'])) {
$intEveId = fxInscrGestionParseEveId($_GET['promoteur_eve_id']);
}
$tabEveIds = fxInscrGestionGetPromoteurEveIds($_SESSION['com_id']);
if ($intEveId > 0 && !fxInscrGestionCanAccess($_SESSION['com_id'], $intEveId)) {
header('Location: ' . $vDomaine . '/mobile');
exit;
}
if ($intEveId === 0 && count($tabEveIds) === 1) {
header('Location: ' . $vDomaine . '/mobile?promoteur_eve_id=' . urlencode(base64_encode($tabEveIds[0])));
exit;
}
$strMetaTitle = fxInscrGestionT('inscr_gestion_mobile_title');
$strMetaDescription = '';
$strMetaKeywords = '';
$blnBoutonRetour = false;
$footer_script = ($intEveId > 0);
$strSousTitre = '';
if ($intEveId > 0) {
$arrEvenement = fxGetEvenementsId($intEveId);
$strSousTitre = '<br><small class="text-muted">' . fxUnescape($arrEvenement['eve_nom_' . $strLangue]) . '</small>';
}
require_once('inc_header.php');
?>
<div id="page">
<div id="main">
<div class="container bg-white p-3 p-xl-4">
<?php
if (isset($_SESSION['msg'])) {
echo fxMessage($_SESSION['msg'], '', $strLangue);
}
if ($intEveId === 0) {
if (count($tabEveIds) === 0) {
echo '<div class="alert alert-warning" role="alert">';
echo fxInscrGestionEsc(fxInscrGestionT('mobile_no_acces_v2'));
echo '</div>';
} else {
fxInscrGestionRenderEventPicker($tabEveIds, $strLangue, fxInscrGestionBaseUrl($strLangue, true));
}
} else {
include('inc_tableau_inscriptions_gestion.php');
}
?>
</div>
</div>
</div>
<?php
require_once('inc_footer.php');