Centralisation des constantes
This commit is contained in:
+7
-3
@@ -17,10 +17,14 @@ function require_login(?string $loginPage = '/login.php'): void
|
||||
}
|
||||
|
||||
if (empty($_SESSION['user'])) {
|
||||
// URL de la page courante (ex: /gift-list.php?foo=bar)
|
||||
$currentUrl = $_SERVER['REQUEST_URI'] ?? '/';
|
||||
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) || (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false)) {
|
||||
header('Content-Type: application/json');
|
||||
http_response_code(401);
|
||||
echo json_encode(['success' => false, 'error' => 'Session expirée. Veuillez vous reconnecter.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// On redirige vers la page de login en ajoutant ?redirect=...
|
||||
$currentUrl = $_SERVER['REQUEST_URI'] ?? '/';
|
||||
$redirectParam = urlencode($currentUrl);
|
||||
$target = ($loginPage ?? '/login.php') . '?redirect=' . $redirectParam;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
// PachaFamily Config - Version sans erreur
|
||||
if (!defined('ID_ALEX')) {
|
||||
define('ID_ALEX', 2);
|
||||
define('ID_LAIA', 3);
|
||||
define('CURRENCY', '€');
|
||||
define('ZONE_SCOLAIRE', 'C');
|
||||
}
|
||||
+3
-1
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
if (file_exists(__DIR__ . '/config.php')) {
|
||||
require_once __DIR__ . '/config.php';
|
||||
}
|
||||
// Activer erreurs
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
|
||||
Reference in New Issue
Block a user