Improve inventory handling and cookie management:
- Replace old cookie logic with `Set_Cookie()` for enhanced security (SameSite, Secure, HttpOnly). - Add dynamic AIX/Linux filtering on `/X/Inventory.php` with checkbox-driven UI and adjusted SQL queries. - Expand `/X/Inventory.php` table with additional columns (`BES`, `FI`) and enhance data validation/styling. - Add `decypher()` function in `Z_data_linux.php` to support OpenSSL-based file decryption with error handling.
This commit is contained in:
@@ -1,5 +1,48 @@
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
|
||||
function decypher(string $name): ?string {
|
||||
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
|
||||
$cmsFile = "F:\\Include\\dat\\$name.p7m";
|
||||
$certPem = "F:\\Include\\certs\\cert_only.pem";
|
||||
$keyPem = "F:\\Include\\certs\\key_only.pem";
|
||||
|
||||
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
|
||||
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
|
||||
}
|
||||
|
||||
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
|
||||
. ' -in ' . escapeshellarg($cmsFile)
|
||||
. ' -recip ' . escapeshellarg($certPem)
|
||||
. ' -inkey ' . escapeshellarg($keyPem)
|
||||
. ' -out -';
|
||||
|
||||
$spec = [
|
||||
0 => ['pipe','r'], // stdin (unused)
|
||||
1 => ['pipe','w'], // stdout -> texte déchiffré
|
||||
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
|
||||
];
|
||||
$proc = proc_open($cmd, $spec, $pipes);
|
||||
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
|
||||
fclose($pipes[0]); // rien à envoyer en stdin
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
|
||||
$code = proc_close($proc);
|
||||
|
||||
if ($code !== 0) {
|
||||
error_log("OpenSSL failed (code $code): $stderr");
|
||||
return null;
|
||||
}
|
||||
return $stdout;
|
||||
}
|
||||
function DB_ZABBIX()
|
||||
{
|
||||
$host = 'aztprdzabbix52.armony.net';
|
||||
$dbname = 'zabbix';
|
||||
$user = 'patrick';
|
||||
$pass = decypher( 'zabbix');
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
|
||||
return $pdo;
|
||||
}
|
||||
$pdo = DB_ZABBIX();
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,48 @@
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
|
||||
function decypher(string $name): ?string {
|
||||
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
|
||||
$cmsFile = "F:\\Include\\dat\\$name.p7m";
|
||||
$certPem = "F:\\Include\\certs\\cert_only.pem";
|
||||
$keyPem = "F:\\Include\\certs\\key_only.pem";
|
||||
|
||||
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
|
||||
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
|
||||
}
|
||||
|
||||
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
|
||||
. ' -in ' . escapeshellarg($cmsFile)
|
||||
. ' -recip ' . escapeshellarg($certPem)
|
||||
. ' -inkey ' . escapeshellarg($keyPem)
|
||||
. ' -out -';
|
||||
|
||||
$spec = [
|
||||
0 => ['pipe','r'], // stdin (unused)
|
||||
1 => ['pipe','w'], // stdout -> texte déchiffré
|
||||
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
|
||||
];
|
||||
$proc = proc_open($cmd, $spec, $pipes);
|
||||
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
|
||||
fclose($pipes[0]); // rien à envoyer en stdin
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
|
||||
$code = proc_close($proc);
|
||||
|
||||
if ($code !== 0) {
|
||||
error_log("OpenSSL failed (code $code): $stderr");
|
||||
return null;
|
||||
}
|
||||
return $stdout;
|
||||
}
|
||||
function DB_ZABBIX()
|
||||
{
|
||||
$host = 'aztprdzabbix52.armony.net';
|
||||
$dbname = 'zabbix';
|
||||
$user = 'patrick';
|
||||
$pass = decypher( 'zabbix');
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
|
||||
return $pdo;
|
||||
}
|
||||
$pdo = DB_ZABBIX();
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,48 @@
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT']."/include/all.php" ;
|
||||
function decypher(string $name): ?string {
|
||||
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
|
||||
$cmsFile = "F:\\Include\\dat\\$name.p7m";
|
||||
$certPem = "F:\\Include\\certs\\cert_only.pem";
|
||||
$keyPem = "F:\\Include\\certs\\key_only.pem";
|
||||
|
||||
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
|
||||
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
|
||||
}
|
||||
|
||||
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
|
||||
. ' -in ' . escapeshellarg($cmsFile)
|
||||
. ' -recip ' . escapeshellarg($certPem)
|
||||
. ' -inkey ' . escapeshellarg($keyPem)
|
||||
. ' -out -';
|
||||
|
||||
$spec = [
|
||||
0 => ['pipe','r'], // stdin (unused)
|
||||
1 => ['pipe','w'], // stdout -> texte déchiffré
|
||||
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
|
||||
];
|
||||
$proc = proc_open($cmd, $spec, $pipes);
|
||||
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
|
||||
fclose($pipes[0]); // rien à envoyer en stdin
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
|
||||
$code = proc_close($proc);
|
||||
|
||||
if ($code !== 0) {
|
||||
error_log("OpenSSL failed (code $code): $stderr");
|
||||
return null;
|
||||
}
|
||||
return $stdout;
|
||||
}
|
||||
function DB_ZABBIX()
|
||||
{
|
||||
$host = 'aztprdzabbix52.armony.net';
|
||||
$dbname = 'zabbix';
|
||||
$user = 'patrick';
|
||||
$pass = decypher( 'zabbix');
|
||||
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
|
||||
return $pdo;
|
||||
}
|
||||
$pdo = DB_ZABBIX();
|
||||
|
||||
$server = strtoupper($_GET['c']);
|
||||
|
||||
@@ -1,6 +1,48 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
|
||||
function decypher(string $name): ?string {
|
||||
$openssl = 'C:\Program Files\FireDaemon OpenSSL 3\bin\openssl.exe';
|
||||
$cmsFile = "F:\\Include\\dat\\$name.p7m";
|
||||
$certPem = "F:\\Include\\certs\\cert_only.pem";
|
||||
$keyPem = "F:\\Include\\certs\\key_only.pem";
|
||||
|
||||
foreach ([$openssl,$cmsFile,$certPem,$keyPem] as $p) {
|
||||
if (!is_file($p)) { error_log("Missing file: $p"); return null; }
|
||||
}
|
||||
|
||||
$cmd = '"' . $openssl . '" cms -decrypt -inform PEM'
|
||||
. ' -in ' . escapeshellarg($cmsFile)
|
||||
. ' -recip ' . escapeshellarg($certPem)
|
||||
. ' -inkey ' . escapeshellarg($keyPem)
|
||||
. ' -out -';
|
||||
|
||||
$spec = [
|
||||
0 => ['pipe','r'], // stdin (unused)
|
||||
1 => ['pipe','w'], // stdout -> texte déchiffré
|
||||
2 => ['pipe','w'], // stderr -> erreurs OpenSSL
|
||||
];
|
||||
$proc = proc_open($cmd, $spec, $pipes);
|
||||
if (!is_resource($proc)) { error_log('proc_open failed'); return null; }
|
||||
fclose($pipes[0]); // rien à envoyer en stdin
|
||||
|
||||
$stdout = stream_get_contents($pipes[1]); fclose($pipes[1]);
|
||||
$stderr = stream_get_contents($pipes[2]); fclose($pipes[2]);
|
||||
$code = proc_close($proc);
|
||||
|
||||
if ($code !== 0) {
|
||||
error_log("OpenSSL failed (code $code): $stderr");
|
||||
return null;
|
||||
}
|
||||
return $stdout;
|
||||
}
|
||||
function DB_INFRA() {
|
||||
$user="INFRA_dbo";
|
||||
$pwd=decypher("infra");
|
||||
$server="DUN-PRD-R1MSSQL.armony.net\PRD";
|
||||
$database="INFRA";
|
||||
$conn = odbc_connect("Driver={SQL Server};Server=$server;Database=$database;", $user, $pwd);
|
||||
return $conn ;
|
||||
}
|
||||
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%'";
|
||||
|
||||
281
X/Inventory.php
281
X/Inventory.php
@@ -2,22 +2,18 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-t">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- Page Title -->
|
||||
<title>Web Infra Reports</title>
|
||||
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
|
||||
|
||||
<!-- JQuery -->
|
||||
<script src="/js/jquery-3.6.1.min.js"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/css/bootstrap-icons/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="/css/preloader.css">
|
||||
<script src="/js/bootstrap.bundle.min.js"></script>
|
||||
<!-- Bootstrap-tables -->
|
||||
<link rel="stylesheet" href="/css/bootstrap-table.min.css">
|
||||
<script src="/js/bootstrap-table.min.js"></script>
|
||||
<script src="/js/bootstrap-table-fr-FR.min.js"></script>
|
||||
@@ -28,35 +24,79 @@
|
||||
</head>
|
||||
|
||||
<body class="bg-light text-dark">
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/global.php"; ?>
|
||||
<?php // DATA
|
||||
$servers = Invoke_Infra("select * from x_inventory where type is not null");
|
||||
<?php
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/include/global.php";
|
||||
|
||||
// NOUVEAU : Gérer les filtres
|
||||
// Par défaut, tout est coché (true)
|
||||
// On vérifie si un paramètre est passé dans l'URL pour décocher une case
|
||||
$show_aix = isset($_GET['show_aix']) ? $_GET['show_aix'] === '1' : true;
|
||||
$show_linux = isset($_GET['show_linux']) ? $_GET['show_linux'] === '1' : true;
|
||||
|
||||
// Construction de la requête SQL
|
||||
$base_sql = "SELECT * FROM x_inventory WHERE type IS NOT NULL and hostname not in ('DUNAPPDNIM51','DUNAPPDNIM52') ";
|
||||
$conditions = [];
|
||||
|
||||
if ($show_aix) {
|
||||
// La condition pour AIX est simple
|
||||
$conditions[] = "type = 'AIX'";
|
||||
}
|
||||
if ($show_linux) {
|
||||
// D'après votre code, tout ce qui n'est pas 'AIX' est considéré comme Linux
|
||||
$conditions[] = "type <> 'AIX'";
|
||||
}
|
||||
|
||||
if (!empty($conditions)) {
|
||||
// On ajoute les conditions à la requête de base
|
||||
$sql = $base_sql . " AND (" . implode(' OR ', $conditions) . ")";
|
||||
} else {
|
||||
// Si rien n'est coché, on ne retourne aucun résultat
|
||||
$sql = $base_sql . " AND 1=0";
|
||||
}
|
||||
|
||||
|
||||
// DATA
|
||||
$servers = Invoke_Infra($sql); // On utilise la nouvelle requête
|
||||
$UTDS1 = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 's1'"))[0]['utd'];
|
||||
$UTDNessus = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 'nessus'"))[0]['utd'];
|
||||
$UTDZabbix = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 'zabbix'"))[0]['utd'];
|
||||
?>
|
||||
$rows = Invoke_Infra("SELECT DISTINCT(Ver) FROM X_cmdb_Product WHERE Name='bes'");
|
||||
$versions = array_map(fn ($r) => $r['Ver'] ?? null, $rows);
|
||||
$versions = array_values(array_filter($versions));
|
||||
usort($versions, 'version_compare');
|
||||
$UTDBES = end($versions);
|
||||
$UTDFI = (Invoke_Infra("select max(Ver) as utd from X_cmdb_Product where Name = 'fi'"))[0]['utd'];
|
||||
?>
|
||||
|
||||
<!-- HTML -->
|
||||
<div class="container-fluid" id="content">
|
||||
|
||||
<div class="container-fluid" id="content">
|
||||
<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;">
|
||||
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
|
||||
</div>
|
||||
<!-- Display -->
|
||||
<div class="col py-3">
|
||||
<!-- Page Title -->
|
||||
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;">AIX / Linux inventory</span></h1>
|
||||
|
||||
<!-- Main content -->
|
||||
<div class="container-fluid">
|
||||
<!-- TABLE -->
|
||||
<div class="d-flex justify-content-start align-items-center mb-2 p-2 rounded bg-secondary-subtle">
|
||||
<form class="form-inline d-flex gap-4">
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="showAix" <?php echo $show_aix ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="showAix"><strong>AIX</strong></label>
|
||||
</div>
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="showLinux" <?php echo $show_linux ? 'checked' : ''; ?>>
|
||||
<label class="form-check-label" for="showLinux"><strong>Linux</strong></label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<table class='table table-bordered table-hover table-sm' id='t1' data-height="620" data-toggle="table" data-search="true" data-show-columns="true" data-export-types="['xlsx','csv','json']" data-show-export="true" data-sortable="true" data-sort-name="VM">
|
||||
<thead> <!-- Header -->
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-field="Name" data-sortable="true">Name</th>
|
||||
<th data-field="Heartbeat" data-sortable="true" data-visible="false" >Heartbeat</th>
|
||||
<th data-field="Heartbeat" data-sortable="true" data-visible="false">Heartbeat</th>
|
||||
<th data-field="Host" data-sortable="true">Host</th>
|
||||
<th data-field="OS" data-sortable="true">OS Type</th>
|
||||
<th data-field="distrib" data-sortable="true">Distrib</th>
|
||||
@@ -66,17 +106,21 @@
|
||||
<th data-field="SentinelOne" data-sortable="true">SentinelOne</th>
|
||||
<th data-field="Nessus" data-sortable="true">Nessus</th>
|
||||
<th data-field="Zabbix" data-sortable="true">Zabbix</th>
|
||||
<th data-field="BES" data-sortable="true" data-visible="false">BES</th>
|
||||
<th data-field="FI" data-sortable="true" data-visible="false">Fusion Inv.</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody> <!-- Body -->
|
||||
<tbody>
|
||||
<?php
|
||||
$total = 0;
|
||||
foreach ($servers as $s) {
|
||||
$total++;
|
||||
echo "<tr>";
|
||||
//name
|
||||
$name = $s['hostname']; $heartbeat = $s['Heartbeat']; $statusClass = '';
|
||||
$name = $s['hostname'];
|
||||
$heartbeat = $s['Heartbeat'];
|
||||
$statusClass = '';
|
||||
$heartbeatDate = new DateTime($heartbeat);
|
||||
$now = new DateTime();
|
||||
$interval = $now->diff($heartbeatDate);
|
||||
@@ -88,137 +132,185 @@
|
||||
} else {
|
||||
$statusClass = 'table-danger';
|
||||
}
|
||||
echo "<td class='{$statusClass}'>";
|
||||
echo "<td class='$statusClass'>";
|
||||
echo " <a href='/inventory/server-detail.php?s={$name}' target='_blank'>{$name}</a>";
|
||||
echo "</td>";
|
||||
|
||||
//heartbeat
|
||||
echo "<td>".$s["Heartbeat"]."</td>";
|
||||
echo "<td>" . $s["Heartbeat"] . "</td>";
|
||||
|
||||
//Host
|
||||
echo "<td>".$s['Owner']."</td>";
|
||||
echo "<td>" . $s['Owner'] . "</td>";
|
||||
//OS Type
|
||||
$typ = match ($s['type'] ?? null) {
|
||||
'AIX' => 'AIX',
|
||||
null, '' => '',
|
||||
default => 'LINUX',
|
||||
};
|
||||
echo "<td>".$s['type']."</td>";
|
||||
echo "<td>" . $s['type'] . "</td>";
|
||||
|
||||
//Distrib
|
||||
$Distrib = "";
|
||||
if($typ == "AIX"){
|
||||
if ($typ == "AIX") {
|
||||
$Distrib = $s['osversion'];
|
||||
}
|
||||
if($typ == "LINUX"){
|
||||
$Distrib = $s['osversion']." <small>(".str_replace(".x86_64","",$s['kernel']).")</small>";
|
||||
if ($typ == "LINUX") {
|
||||
$Distrib = $s['osversion'] . " <small>(" . str_replace(".x86_64", "", $s['kernel']) . ")</small>";
|
||||
}
|
||||
echo "<td>$Distrib</td>";
|
||||
|
||||
//LastReboot
|
||||
$lr = $s['lastboot'] ?? ""; $lrDate="";
|
||||
$lr = $s['lastboot'] ?? "";
|
||||
$lrDate = "";
|
||||
try {
|
||||
$lrDate = new DateTime($lr);
|
||||
} catch (DateMalformedStringException $e) {}
|
||||
} catch (DateMalformedStringException $e) {
|
||||
}
|
||||
$interval = (new DateTime())->diff($lrDate);
|
||||
if($interval->days > 60){
|
||||
if ($interval->days > 60) {
|
||||
echo "<td class='table-danger'>$lr</td>";
|
||||
}else{
|
||||
if($interval->days > 1){
|
||||
} else {
|
||||
if ($interval->days > 1) {
|
||||
echo "<td>$lr</td>";
|
||||
}else{
|
||||
} else {
|
||||
echo "<td class='table-success'>$lr</td>";
|
||||
}
|
||||
}
|
||||
|
||||
//LastBackup
|
||||
$lr = explode(".",$s['backuplast'] ?? "")[0];
|
||||
$lr = explode(".", $s['backuplast'] ?? "")[0];
|
||||
$size = 0;
|
||||
if($s['backuplog'] != "") {
|
||||
if (str_contains($s['backuplog'],"Length")) {
|
||||
if ($s['backuplog'] != "") {
|
||||
if (str_contains($s['backuplog'], "Length")) {
|
||||
$size = explode(" ", $s['backuplog'])[1];
|
||||
} else {
|
||||
$size = explode(" ", $s['backuplog'])[3];
|
||||
}
|
||||
$size = floor($size / 1024 / 1024 / 1024);
|
||||
}
|
||||
if($size >= 15){
|
||||
if ($size >= 15) {
|
||||
$size = "<span class='text-danger'><b>$size GB</b></span>";
|
||||
}else{
|
||||
} else {
|
||||
$size = "$size GB";
|
||||
}
|
||||
try {
|
||||
$lrDate = new DateTime($lr);
|
||||
} catch (DateMalformedStringException $e) {}
|
||||
} catch (DateMalformedStringException $e) {
|
||||
}
|
||||
$interval = (new DateTime())->diff($lrDate);
|
||||
if($interval->days > 7 || $s['backuplast'] == ""){
|
||||
echo "<td class='table-danger'>$lr"." ".$size."</td>";
|
||||
}else{
|
||||
if($interval->days > 1){
|
||||
echo "<td>".date_format($lrDate,"Y-m-d H:i:s")." - ".$size."</td>";
|
||||
}else{
|
||||
echo "<td class='table-success'>$lr"." - ".$size."</td>";
|
||||
if ($interval->days > 7 || $s['backuplast'] == "") {
|
||||
echo "<td class='table-danger'>$lr" . " " . $size . "</td>";
|
||||
} else {
|
||||
if ($interval->days > 1) {
|
||||
echo "<td>" . date_format($lrDate, "Y-m-d H:i:s") . " - " . $size . "</td>";
|
||||
} else {
|
||||
echo "<td class='table-success'>$lr" . " - " . $size . "</td>";
|
||||
}
|
||||
}
|
||||
|
||||
//Auth
|
||||
echo "<td>".$s['auth']."</td>";
|
||||
echo "<td>" . $s['auth'] . "</td>";
|
||||
|
||||
//SentinelOne
|
||||
$s1s = $s['S1State']; $s1v = $s['S1Version'];
|
||||
if($typ == "LINUX"){
|
||||
if($s1s == "YY"){
|
||||
if($s1v == $UTDS1) {
|
||||
$s1s = $s['S1State'];
|
||||
$s1v = $s['S1Version'];
|
||||
if ($typ == "LINUX") {
|
||||
if ($s1s == "YY") {
|
||||
if ($s1v == $UTDS1) {
|
||||
echo "<td class='table-success'>$s1v $s1s</td>";
|
||||
}else{
|
||||
} else {
|
||||
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
|
||||
}
|
||||
}else{
|
||||
if($s1v == "") {
|
||||
echo "<td class='table-danger text-center'>MISSING</td>";
|
||||
}else{
|
||||
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
//Nessus
|
||||
$s1s = $s['NessusState']; $s1v = $s['NessusVersion'];
|
||||
if($typ == "LINUX"){
|
||||
if($s1s == "YYY_YYY"){
|
||||
if($s1v == $UTDNessus) {
|
||||
echo "<td class='table-success'>$s1v $s1s</td>";
|
||||
}else{
|
||||
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
if ($s1v == "") {
|
||||
echo "<td class='table-danger text-center'>MISSING</td>";
|
||||
} else {
|
||||
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
//Nessus
|
||||
$s1s = $s['NessusState'];
|
||||
$s1v = $s['NessusVersion'];
|
||||
if ($typ == "LINUX") {
|
||||
if ($s1s == "YYY_YYY") {
|
||||
if ($s1v == $UTDNessus) {
|
||||
echo "<td class='table-success'>$s1v $s1s</td>";
|
||||
} else {
|
||||
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
|
||||
}
|
||||
} else {
|
||||
if ($s1v == "") {
|
||||
echo "<td class='table-danger text-center'>MISSING</td>";
|
||||
} else {
|
||||
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
//Zabbix
|
||||
$s1s = $s['ZabbixState']; $s1v = $s['ZabbixVersion'];
|
||||
if($s1s == "Y"){
|
||||
if($s1v == $UTDZabbix) {
|
||||
$s1s = $s['ZabbixState'];
|
||||
$s1v = $s['ZabbixVersion'];
|
||||
if ($typ == "AIX" && str_starts_with($s['osversion'], '6')) {
|
||||
echo "<td></td>";
|
||||
} else {
|
||||
if ($s1s == "Y") {
|
||||
if ($s1v == $UTDZabbix) {
|
||||
echo "<td class='table-success'>$s1v $s1s</td>";
|
||||
}else{
|
||||
} else {
|
||||
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
|
||||
}
|
||||
}else{
|
||||
if($s1v == "") {
|
||||
} else {
|
||||
if ($s1v == "") {
|
||||
echo "<td class='table-danger text-center'>MISSING</td>";
|
||||
}else{
|
||||
} else {
|
||||
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BES
|
||||
$s1s = $s['BESState'];
|
||||
$s1v = $s['BESVersion'];
|
||||
if ($s1s == "Y") {
|
||||
if ($s1v == $UTDBES) {
|
||||
echo "<td class='table-success'>$s1v $s1s</td>";
|
||||
} else {
|
||||
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
|
||||
}
|
||||
} else {
|
||||
if ($s1v == "") {
|
||||
echo "<td class='table-danger text-center'>MISSING</td>";
|
||||
} else {
|
||||
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
|
||||
}
|
||||
}
|
||||
|
||||
//FI
|
||||
$s1s = $s['FIState'];
|
||||
$s1v = $s['FIVersion'];
|
||||
if ($typ == "LINUX") {
|
||||
if ($s1s == "Y") {
|
||||
if ($s1v == $UTDFI) {
|
||||
echo "<td class='table-success'>$s1v $s1s</td>";
|
||||
} else {
|
||||
echo "<td class='table-warning'><b>$s1v</b> $s1s</td>";
|
||||
}
|
||||
} else {
|
||||
if ($s1v == "") {
|
||||
echo "<td class='table-danger text-center'>MISSING</td>";
|
||||
} else {
|
||||
echo "<td class='table-danger'>$s1v <b>$s1s</b></td>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "<td></td>";
|
||||
}
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
@@ -229,11 +321,34 @@
|
||||
<h5 class="text-center"><?php echo $total; ?> servers</h5>
|
||||
</div>
|
||||
</div>
|
||||
<!-- End of main content -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script src="/js/switch.js"></script>
|
||||
|
||||
<script>
|
||||
// This function will be executed when the document is ready
|
||||
$(function() {
|
||||
// Add an event listener to both checkboxes
|
||||
$('#showAix, #showLinux').on('change', function() {
|
||||
// Get the current state of the checkboxes (checked or not)
|
||||
// '1' for checked, '0' for unchecked
|
||||
const showAix = $('#showAix').is(':checked') ? '1' : '0';
|
||||
const showLinux = $('#showLinux').is(':checked') ? '1' : '0';
|
||||
|
||||
// Create a URL object to easily manipulate query parameters
|
||||
const url = new URL(window.location.href);
|
||||
|
||||
// Set the parameters based on checkbox states
|
||||
url.searchParams.set('show_aix', showAix);
|
||||
url.searchParams.set('show_linux', showLinux);
|
||||
|
||||
// Reload the page with the new URL
|
||||
window.location.href = url.toString();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</HTML>
|
||||
<script src="/js/tableResize.js"></script>
|
||||
@@ -69,26 +69,14 @@
|
||||
<div>
|
||||
<?php
|
||||
$aix = $linux = $dun = $azt = $other = "Checked";
|
||||
$where = " and OS_TYPE IN (";
|
||||
if (isset($_GET['AIX'])) {
|
||||
if ($_GET['AIX'] == 1) {
|
||||
$where .= "'AIX',";
|
||||
} else {
|
||||
$aix = "Unchecked";
|
||||
}
|
||||
} else {
|
||||
$aix = "Unchecked";
|
||||
}
|
||||
if (isset($_GET['linux'])) {
|
||||
if ($_GET['linux'] == 1) {
|
||||
$where .= "'LINUX',";
|
||||
} else {
|
||||
$linux = "Unchecked";
|
||||
}
|
||||
} else {
|
||||
$linux = "Unchecked";
|
||||
}
|
||||
$where = rtrim($where, ',') . ")";
|
||||
$where = "";
|
||||
if (!isset($_GET['AIX'])){$aix = "Unchecked";}
|
||||
if (!isset($_GET['linux'])){$linux = "Unchecked";}
|
||||
|
||||
if($linux=="Unchecked" && $aix=="Unchecked"){ $where = " and 1=2 ";}
|
||||
if($linux=="Unchecked" && $aix=="Checked"){ $where = " and Type ='AIX' ";}
|
||||
if($linux=="Checked" && $aix=="Unchecked"){ $where = " and not Type ='AIX' ";}
|
||||
|
||||
$site = "";
|
||||
if (isset($_GET['DUN'])) {
|
||||
if ($_GET['DUN'] == 1) {
|
||||
@@ -120,8 +108,9 @@
|
||||
$site = " and (" . ltrim($site, ' or') . ") ";
|
||||
$where .= $site;
|
||||
|
||||
$sql = "select hostname, os_type from srvall where decomtime is null and (ucase(filter) not like 'X_%' or filter is null) $where order by hostname";
|
||||
$hosts = Invoke_aixcmdb($sql);
|
||||
$sql = "select HOSTNAME, Type, OSVersion from x_srvall where Decom is null $where order by hostname";
|
||||
$hosts = Invoke_Infra($sql);
|
||||
//print_r($hosts);exit;
|
||||
|
||||
$taix = $aixok = $aixko = $tlinux = $linuxok = $linuxko = 0;
|
||||
$resultsByHost = [];
|
||||
@@ -178,6 +167,7 @@
|
||||
<thead> <tr>
|
||||
<th data-field='host' data-sortable='true'>Host</th>
|
||||
<th data-field='OS' data-sortable='true'>OS</th>
|
||||
<th data-field='OSVer' data-sortable='true'>Distrib</th>
|
||||
<th data-field='TimeStamp' data-sortable='true'>TimeStamp</th>
|
||||
<th data-field='RC' data-sortable='true'>RC</th>
|
||||
<th data-field='Result' data-sortable='true'>StdOut</th>
|
||||
@@ -186,7 +176,8 @@
|
||||
<tbody> <?php
|
||||
foreach ($hosts as $h) {
|
||||
$host = strtoupper($h['HOSTNAME']);
|
||||
$os = strtoupper($h['OS_TYPE']);
|
||||
$os = strtoupper($h['Type']);
|
||||
$osver = strtoupper($h['OSVersion']);
|
||||
|
||||
if ($os == "AIX") {
|
||||
$taix++;
|
||||
@@ -220,6 +211,7 @@
|
||||
|
||||
echo "<tr><td><b>$host</b></td>";
|
||||
echo "<td>$os</td>";
|
||||
echo "<td>$osver</td>";
|
||||
echo "<td>" . $ts . "</td>";
|
||||
if ($rc == 0 && (string)$rc <> "") {
|
||||
echo "<td class='table-success'>" . $rc . "</td>";
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
<body class="bg-light text-dark">
|
||||
<?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 -->
|
||||
|
||||
@@ -259,27 +259,78 @@
|
||||
return $pdo;
|
||||
}
|
||||
|
||||
//Cookie//
|
||||
function Set_Cookie() {
|
||||
// --- paramètres ---
|
||||
$cookieName = 'UserInfo';
|
||||
$cookieLife = 86400 * 365; // 1 an
|
||||
$cookieDomain = '.appliarmony.net';
|
||||
$secureFlag = true;
|
||||
$httpOnly = true;
|
||||
$sameSite = 'Lax';
|
||||
|
||||
// --- helpers ---
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
//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;
|
||||
// IP client: XFF (première IP) -> fallback REMOTE_ADDR
|
||||
$ip = '';
|
||||
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$parts = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
|
||||
$cand = trim($parts[0]);
|
||||
if (filter_var($cand, FILTER_VALIDATE_IP)) $ip = $cand;
|
||||
}
|
||||
if (!$ip && !empty($_SERVER['REMOTE_ADDR'])) $ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Set the cookie
|
||||
setcookie('AuthToken', $cookieValue, [
|
||||
'expires' => time() + 3600,
|
||||
// User Windows (SSO)
|
||||
$user = $_SERVER['REMOTE_USER'] ?? null;
|
||||
$hasUser = !empty($user);
|
||||
|
||||
// --- lecture éventuelle du cookie existant ---
|
||||
$cookie = [];
|
||||
if (!empty($_COOKIE[$cookieName])) {
|
||||
$decoded = json_decode($_COOKIE[$cookieName], true);
|
||||
if (is_array($decoded)) $cookie = $decoded;
|
||||
}
|
||||
|
||||
// --- écriture/MAJ SEULEMENT si on a un REMOTE_USER ---
|
||||
if ($hasUser) {
|
||||
if (empty($cookie) || ($cookie['user'] ?? null) !== $user) {
|
||||
// Nouveau cookie ou changement d’utilisateur → reset
|
||||
$cookie = [
|
||||
'user' => $user,
|
||||
'ip' => $ip,
|
||||
'created' => $now,
|
||||
'last' => $now
|
||||
];
|
||||
} else {
|
||||
// Même user → on rafraîchit last + IP
|
||||
$cookie['ip'] = $ip ?: ($cookie['ip'] ?? '');
|
||||
$cookie['last'] = $now;
|
||||
}
|
||||
|
||||
// Écrire le cookie (évite d’écrire si headers déjà envoyés)
|
||||
if (!headers_sent()) {
|
||||
setcookie($cookieName, json_encode($cookie), [
|
||||
'expires' => time() + $cookieLife,
|
||||
'path' => '/',
|
||||
'domain' => '.appliarmony.net',
|
||||
'secure' => false, // true quand HTTPS
|
||||
'httponly' => true,
|
||||
'samesite' => 'Lax'
|
||||
'domain' => $cookieDomain,
|
||||
'secure' => $secureFlag,
|
||||
'httponly' => $httpOnly,
|
||||
'samesite' => $sameSite
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// --- exposer des constantes pour le reste du code ---
|
||||
// Priorité: si on a REMOTE_USER on l’utilise; sinon on retombe sur le cookie existant; sinon vide/anonyme.
|
||||
$currentUser = $hasUser ? $user : ($cookie['user'] ?? 'Anonymous');
|
||||
$currentIp = $hasUser ? $ip : ($cookie['ip'] ?? ($_SERVER['HTTP_X_FORWARDED_FOR'] ?? $_SERVER['REMOTE_ADDR'] ?? ''));
|
||||
|
||||
if (!defined('CURRENT_USER')) define('CURRENT_USER', $currentUser);
|
||||
if (!defined('CURRENT_IP')) define('CURRENT_IP', $currentIp);
|
||||
if (!defined('COOKIE_INFO')) define('COOKIE_INFO', $cookie);
|
||||
}
|
||||
Set_Cookie();
|
||||
|
||||
?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user