This commit is contained in:
Francesco Picone
2025-12-09 16:16:06 +01:00
parent 8adfd6a601
commit 2b0880bb2b
2 changed files with 11 additions and 3 deletions

View File

@@ -33,7 +33,11 @@ function is_admin() {
function require_login() {
if (!is_logged_in()) {
$_SESSION['redirect_after_login'] = $_SERVER['REQUEST_URI'];
header('Location: ' . SITE_URL . '/login.php');
// Determina il percorso relativo al login basato sulla directory corrente
$login_path = (strpos($_SERVER['SCRIPT_NAME'], '/admin/') !== false || strpos($_SERVER['SCRIPT_NAME'], '/user/') !== false)
? '../login.php'
: 'login.php';
header('Location: ' . $login_path);
exit;
}
}
@@ -45,7 +49,11 @@ function require_admin() {
require_login();
if (!is_admin()) {
header('Location: ' . SITE_URL . '/index.php');
// Determina il percorso relativo all'index basato sulla directory corrente
$index_path = (strpos($_SERVER['SCRIPT_NAME'], '/admin/') !== false || strpos($_SERVER['SCRIPT_NAME'], '/user/') !== false)
? '../index.php'
: 'index.php';
header('Location: ' . $index_path);
exit;
}
}