Replace individual includes with include/all.php for consistent configuration and add cookie-based authentication in all.php.

This commit is contained in:
2025-09-25 14:10:01 +02:00
parent 878106f83f
commit dcfe098f35
17 changed files with 40 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
<?php
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
$pdo = DB_ZABBIX();

View File

@@ -1,5 +1,5 @@
<?php
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
$pdo = DB_ZABBIX();

View File

@@ -1,5 +1,5 @@
<?php
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
$pdo = DB_ZABBIX();
$server = strtoupper($_GET['c']);

View File

@@ -1,6 +1,6 @@
<?php
header('Content-Type: application/json');
include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ;
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
if (isset($_GET['term'])) {
$term = $_GET['term'];
$query = "SELECT hostname AS serv FROM cmdb_srvall WHERE hostname LIKE '%$term%' UNION SELECT hostname AS serv FROM x_SRVALL WHERE hostname LIKE '%$term%'";

View File

@@ -24,8 +24,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/include/db_connect.php" ; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -27,7 +27,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -27,7 +27,7 @@
</head>
<body>
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -29,10 +29,9 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/preloader.inc.html"; ?> <!-- Preloader -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/../../include/db_connect.php"; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<div class="container-fluid">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Database connexion -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->
<div class="col-auto col-md-2 col-xl-2 px-sm-2 px-0 bg-dark vh-100 position-sticky top-0" style="-ms-flex: 0 0 230px;flex: 0 0 230px;">

View File

@@ -26,8 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/../../include/db_connect.php"; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?>
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,8 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,7 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -26,8 +26,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php //include $_SERVER['DOCUMENT_ROOT']."/include/functions.inc.php" ; ?> <!-- Functions -->
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?> <!-- Include All -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->

View File

@@ -259,6 +259,28 @@
return $pdo;
}
//Set Cookies
$secretKey = 'impossibleatrouvercommeca';
$remoteUser = $_SERVER['REMOTE_USER'] ?? null;
if ($remoteUser) {
$expiration = time() + 3600; // Token is valid for 1 hour
$payload = base64_encode($remoteUser . '|' . $expiration); // Combine user and expiration
$signature = hash_hmac('sha256', $payload, $secretKey);
$cookieValue = $payload . '.' . $signature;
// Set the cookie
setcookie('AuthToken', $cookieValue, [
'expires' => time() + 3600,
'path' => '/',
'domain' => '.appliarmony.net',
'secure' => false, // true quand HTTPS
'httponly' => true,
'samesite' => 'Lax'
]);
}
?>
<!-- MODAL WAIT -->

View File

@@ -25,7 +25,7 @@
</head>
<body class="bg-light text-dark">
<?php include $_SERVER['DOCUMENT_ROOT']."/../../include/db_connect.php" ; ?> <!-- Database connexion -->
<?php include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ; ?> <!-- Database connexion -->
<div class="container-fluid">
<div class="row flex-nowrap">
<!-- Left NAVBAR -->