This commit introduces a new function, `fxSuperadmRedirectToLoginIfNeeded`, to streamline the login redirection process for superadmin users. It enhances session management by checking for user authentication and allowing legacy account access under specific conditions. Additionally, the login flow is updated to ensure users are redirected appropriately after login, improving the overall security and user experience in the superadmin interface. These changes aim to enhance maintainability and clarity in session handling across various superadmin pages.
95 lines
3.2 KiB
PHP
95 lines
3.2 KiB
PHP
<?php
|
|
|
|
$strLangue = 'fr';
|
|
$strPage = 'documentation.php';
|
|
$strAction = $_GET['p'] ?? 'list';
|
|
|
|
require_once('php/inc_start_time.php');
|
|
require_once('php/inc_functions.php');
|
|
require_once('php/inc_fx_doc_admin.php');
|
|
|
|
global $objDatabase, $vDomaine, $vblnEnvironementDev, $vblnEnvironementPreProd;
|
|
|
|
fxSuperadmRedirectToLoginIfNeeded(false);
|
|
$blnLogged = fxSuperadmIsLoggedIn();
|
|
|
|
$strFlash = '';
|
|
$strError = '';
|
|
$strModClef = isset($_GET['mod']) ? preg_replace('/[^a-z0-9_]/i', '', $_GET['mod']) : '';
|
|
|
|
if ($blnLogged && $_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
if (!fxDocAdminIsDevPreprod()) {
|
|
$strError = 'La création est réservée aux environnements dev/préprod.';
|
|
} else {
|
|
$strPostAction = $_POST['action'] ?? '';
|
|
|
|
if ($strPostAction === 'addmodule') {
|
|
$arrResult = fxDocAdminCreateModule(
|
|
$_POST['doc_mod_clef'] ?? '',
|
|
$_POST['doc_mod_titre'] ?? '',
|
|
$_POST['doc_mod_prg'] ?? 'compte.php'
|
|
);
|
|
if ($arrResult['state'] === 'ok') {
|
|
header('Location: documentation.php?p=pages&mod=' . urlencode($arrResult['mod']) . '&ok=1');
|
|
exit;
|
|
}
|
|
$strError = $arrResult['message'];
|
|
} elseif ($strPostAction === 'addpage') {
|
|
$arrResult = fxDocAdminCreatePage(
|
|
$_POST['mod'] ?? '',
|
|
$_POST['doc_page_clef'] ?? '',
|
|
$_POST['doc_prg'] ?? 'compte.php'
|
|
);
|
|
if ($arrResult['state'] === 'ok') {
|
|
header('Location: ' . fxDocAdminEditUrl($arrResult['mod'], $arrResult['prg']));
|
|
exit;
|
|
}
|
|
$strError = $arrResult['message'];
|
|
$strAction = 'pages';
|
|
$strModClef = preg_replace('/[^a-z0-9_]/i', '', $_POST['mod'] ?? '');
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!empty($_GET['ok'])) {
|
|
$strFlash = 'Enregistré.';
|
|
}
|
|
|
|
include('inc_header.php');
|
|
?>
|
|
<div class="container-fluid" id="main">
|
|
<div class="row">
|
|
<div class="col-md-9 col-lg-10 order-first order-md-last py-3">
|
|
<?php
|
|
if ($blnLogged) {
|
|
if ($strFlash !== '' && $strError === '') {
|
|
echo '<div class="alert alert-success">' . fxDocAdminEsc($strFlash) . '</div>';
|
|
}
|
|
if ($strError !== '') {
|
|
echo '<div class="alert alert-danger">' . fxDocAdminEsc($strError) . '</div>';
|
|
}
|
|
|
|
if (!fxDocAdminSchemaReady()) {
|
|
echo '<div class="alert alert-warning">Les tables de documentation (doc_mod / doc_page) ne sont pas installées sur cet environnement.</div>';
|
|
} else {
|
|
switch ($strAction) {
|
|
case 'pages':
|
|
fxDocAdminRenderPages($strModClef);
|
|
break;
|
|
case 'list':
|
|
default:
|
|
fxDocAdminRenderModulesList();
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
echo '<h1>Accès refusé!</h1>';
|
|
}
|
|
?>
|
|
<p> </p>
|
|
</div>
|
|
<?php require_once('inc_droite.php'); ?>
|
|
</div>
|
|
</div>
|
|
<?php require_once('inc_footer.php'); ?>
|