- Modified VM queries in `SYN-VMList.php` to remove unnecessary cluster filtering. - Adjusted page titles for better context in `SYN-VMList.php`. - Updated `dhcp_servers.php` with enhanced table export and added new JavaScript (`switch.js`). - Extended French translations in `fr.php` with new VM-related terms. - Enhanced KPI calculations in `Crossover-KPI.js` with improved checks and parameter handling. - Refactored and streamlined `GlobalCrossover.php` for cleaner and more efficient code, improving readability and maintainability.
365 lines
18 KiB
PHP
365 lines
18 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
|
|
<title>Web Infra Reports IT</title>
|
|
<link rel="shortcut icon" type="image/png" href="/include/favicon-32x32.png">
|
|
|
|
<script src="/js/jquery-3.6.1.min.js"></script>
|
|
<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>
|
|
<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>
|
|
<script src="/js/tableExport.min.js"></script>
|
|
<script src="/js/bootstrap-table-export.min.js"></script>
|
|
<script src="/js/libs/js-xlsx/xlsx.core.min.js"></script>
|
|
</head>
|
|
|
|
<body class="bg-light text-dark">
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php"; ?>
|
|
<div class="container-fluid">
|
|
<div class="row flex-nowrap">
|
|
<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>
|
|
<div class="col py-3">
|
|
<h1><span class="badge text-bg-secondary font-weight-bold" style="width:100%;"><?php echo $ti_3; ?></span></h1>
|
|
|
|
<div class="row" style="zoom: 80%">
|
|
<table class='table table-bordered table-hover table-sm' id='t1' data-toggle="table" data-search="true"
|
|
data-show-columns="true" data-export-types="['xlsx','csv','json']"
|
|
data-loading-template="loadingTemplate"
|
|
data-show-export="true" data-sortable="true">
|
|
<thead>
|
|
<tr>
|
|
<th data-field="Name" data-sortable="true"><?php echo $w_name; ?></th>
|
|
<th data-field="OS" data-sortable="true"><?php echo $w_os; ?></th>
|
|
<th data-field="Criticity" data-sortable="true"><?php echo $w_crit; ?></th>
|
|
<th data-field="AD" data-sortable="true"><?php echo $w_ad; ?></th>
|
|
<th data-field="ADlu" data-sortable="true" data-visible="false"><?php echo $w_adlu; ?></th>
|
|
<th data-field="GLPI" data-sortable="true">GLPI</th>
|
|
<th data-field="GLPIlu" data-sortable="true" data-visible="false" data-footer-formatter="FI"><?php echo $w_filu; ?></th>
|
|
<th data-field="SCCM" data-sortable="true">SCCM<br></th>
|
|
<th data-field="SCCMlu" data-sortable="true" data-visible="false"><?php echo $w_sccmlu; ?></th>
|
|
<th data-field="NESSUS" data-sortable="true">NESSUS</th>
|
|
<th data-field="Backup" data-sortable="true"><?php echo $w_backup; ?></th>
|
|
<th data-field="NBUlu" data-sortable="true" data-visible="false"><?php echo $w_backuplu; ?></th>
|
|
<th data-field="SCOM" data-sortable="true">SCOM</th>
|
|
<th data-field="Zabbix" data-sortable="true">Zabbix</th>
|
|
<th data-field="S1" data-sortable="true">SentinelOne</th>
|
|
<th data-field="S1lu" data-sortable="true" data-visible="false"><?php echo $w_s1lu; ?></th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
<?php
|
|
$conn = DB_ENTRY02();
|
|
$sql = "SELECT * FROM GlobalCrossover";
|
|
$whereClauses = ["server NOT LIKE 'WS%'"];
|
|
|
|
if (isset($_GET['filter'])) {
|
|
$filter = $_GET['filter'];
|
|
$filterTitle = "$w_filter : " . htmlspecialchars($filter) . " $w_nonCompliant";
|
|
switch ($filter) {
|
|
case "AD": $whereClauses[] = "AD IS NULL OR (ADlu IS NOT NULL AND DATEDIFF(now(), ADlu) > 45)"; break;
|
|
case "OS": $whereClauses[] = "OS LIKE '%2003%' OR OS LIKE '%2008%'"; break;
|
|
case "GLPI": $whereClauses[] = "GLPI IS NULL OR GLPIlu IS NULL OR DATEDIFF(now(), GLPIlu) > 7"; break;
|
|
case "SCCM": $whereClauses[] = "SCCM IS NULL OR (SCCMlu IS NOT NULL AND DATEDIFF(now(), SCCMlu) > 7)"; break;
|
|
case "NESSUS": $whereClauses[] = "EPO IS NULL"; break;
|
|
case "NBU": $whereClauses[] = "NBU IS NULL OR (NBUlu IS NOT NULL AND DATEDIFF(now(), NBUlu) > 30)"; break;
|
|
case "SCOM": $whereClauses[] = "SCOM IS NULL"; break;
|
|
case "zabbix": $whereClauses[] = "zabbix IS NULL"; break;
|
|
case "S1": $whereClauses[] = "S1 IS NULL OR (S1lu IS NOT NULL AND DATEDIFF(now(), S1lu) > 7)"; break;
|
|
default: $filterTitle = null; break;
|
|
}
|
|
if ($filterTitle) {
|
|
echo "<h2><div style=\"text-align: center;\"><span class='badge text-bg-danger font-weight-bold'>$filterTitle</span></div></h2>";
|
|
}
|
|
}
|
|
|
|
if (!empty($whereClauses)) { $sql .= " WHERE " . implode(' AND ', $whereClauses); }
|
|
$sql .= " ORDER BY server";
|
|
|
|
$stmt = $conn->prepare($sql);
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
// --- PART 2: HELPER FUNCTIONS ---
|
|
function renderStatusCellWithDate(?string $status, ?string $lastUpdate, int $daysThreshold, string $okText = 'OK'): string {
|
|
$status = htmlspecialchars($status ?? '', ENT_QUOTES, 'UTF-8');
|
|
$lastUpdate = htmlspecialchars($lastUpdate ?? '', ENT_QUOTES, 'UTF-8');
|
|
$okText = htmlspecialchars($okText, ENT_QUOTES, 'UTF-8');
|
|
|
|
if ($status === 'Y') {
|
|
if (empty($lastUpdate)) {
|
|
return "<td class='text-white' style='background: linear-gradient(90deg, rgba(25,135,84,1) 50%, rgba(255,193,7,1) 100%);'>$okText</td><td class='bg-warning text-black'>Missing</td>";
|
|
}
|
|
try {
|
|
$diff = date_diff(date_create($lastUpdate), date_create());
|
|
$days = (int) $diff->format("%R%a");
|
|
if ($days > $daysThreshold) {
|
|
return "<td class='text-white' style='background: linear-gradient(90deg, rgba(25,135,84,1) 50%, rgba(220,53,69,1) 100%);'>$okText</td><td class='bg-danger text-white'>$lastUpdate ($days days)</td>";
|
|
} else {
|
|
return "<td class='bg-success text-white'>$okText</td><td class='bg-success text-white'>$lastUpdate</td>";
|
|
}
|
|
} catch (Exception) {
|
|
return "<td class='bg-danger text-white'>Invalid Date</td><td class='bg-danger text-white'>$lastUpdate</td>";
|
|
}
|
|
}
|
|
if ($status !== '') {
|
|
return "<td class='bg-secondary'><small>$status</small></td><td class='bg-secondary text-secondary'> </td>";
|
|
}
|
|
return "<td class='bg-warning text-black'>Missing</td><td class='bg-warning text-warning'> </td>";
|
|
}
|
|
|
|
// --- PART 3: DATA PROCESSING & DISPLAY ---
|
|
$counters = [
|
|
'total' => 0, 'ok' => 0, 'nOS' => 0, 'nAD' => 0, 'nSCCM' => 0, 'nGLPI' => 0,
|
|
'nFI' => 0, 'nNESSUS' => 0, 'nNBU' => 0, 'nDPM' => 0, 'nS1' => 0,
|
|
'nzabbix' => 0, 'nSCOM' => 0
|
|
];
|
|
|
|
$maxS1Win = "0"; $maxS1Lin = "0";
|
|
$dataRows = [];
|
|
|
|
while ($row = $result->fetch_assoc()) {
|
|
$dataRows[] = $row;
|
|
$currentV = $row['S1'] ?? '';
|
|
$os = $row['OS'] ?? '';
|
|
if (str_contains($currentV, '.')) {
|
|
if (stripos($os, 'Windows') !== false) {
|
|
if (version_compare($currentV, $maxS1Win, '>')) { $maxS1Win = $currentV; }
|
|
} else {
|
|
if (version_compare($currentV, $maxS1Lin, '>')) { $maxS1Lin = $currentV; }
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach ($dataRows as $row) {
|
|
// KPI Calculation
|
|
$counters['total']++;
|
|
$isCompliant = isset($row['AD'], $row['GLPI'], $row['SCCM'], $row['EPO']) && (isset($row['NBU']) || isset($row['DPM'])) && isset($row['SCOM']);
|
|
if ($isCompliant) { $counters['ok']++; }
|
|
if (!empty($row['OS']) && !preg_match('(XP|2003|2000|2008|Windows 7|2012)', $row['OS'])) { $counters['nOS']++; }
|
|
if (!isset($row['AD'])) $counters['nAD']++;
|
|
if (!isset($row['SCCM'])) $counters['nSCCM']++;
|
|
if (!isset($row['GLPI'])) $counters['nGLPI']++;
|
|
if (!isset($row['EPO'])) $counters['nNESSUS']++;
|
|
if (!isset($row['NBU']) && !isset($row['DPM'])) $counters['nNBU']++;
|
|
if (!isset($row['SCOM'])) $counters['nSCOM']++;
|
|
if (!isset($row['zabbix'])) $counters['nzabbix']++;
|
|
if (!isset($row['S1'])) $counters['nS1']++;
|
|
|
|
// Row Rendering
|
|
$serverName = htmlspecialchars($row['Server'] ?? '', ENT_QUOTES, 'UTF-8');
|
|
$serverUrl = urlencode($row['Server'] ?? '');
|
|
if ($isCompliant) {
|
|
$serverCell = "<td class='bg-success text-white'><b><a href='/crossover/Detail.php?server=$serverUrl' target='_blank' class='link-light'>$serverName</a></b></td>";
|
|
} else {
|
|
$serverCell = "<td><b><a href='/crossover/Detail.php?server=$serverUrl' target='_blank'>$serverName</a></b></td>";
|
|
}
|
|
|
|
$osCell = "<td class='bg-warning'> </td>";
|
|
if (!empty($row['OS'])) {
|
|
$os = htmlspecialchars($row['OS']);
|
|
$osCell = preg_match('(XP|2003|2000|2008|Windows 7|2012)', $row['OS']) ? "<td class='bg-warning text-black'>$os</td>" : "<td>$os</td>";
|
|
}
|
|
|
|
echo "<tr>";
|
|
echo $serverCell . $osCell;
|
|
echo "<td>" . htmlspecialchars($row['crit'] ?? '') . "</td>";
|
|
echo renderStatusCellWithDate($row['AD'], $row['ADlu'], 45);
|
|
echo renderStatusCellWithDate($row['GLPI'], $row['GLPIlu'], 7);
|
|
echo renderStatusCellWithDate($row['SCCM'], $row['SCCMlu'], 7);
|
|
|
|
// NESSUS
|
|
if (str_contains($row['EPO'] ?? '', '.')) { echo "<td class='bg-success text-white'>".htmlspecialchars($row['EPO'])."</td>"; }
|
|
elseif (isset($row['EPO']) && !in_array($row['EPO'], ['Y', 'N'])) { echo "<td class='bg-secondary'><small>".htmlspecialchars($row['EPO'])."</small></td>"; }
|
|
else { echo "<td class='bg-warning text-black'>Missing</td>"; }
|
|
|
|
// BACKUP
|
|
if (($row['NBU'] ?? '') === 'Y') { echo renderStatusCellWithDate($row['NBU'], $row['NBUlu'], 30, 'OK (NBU)'); }
|
|
elseif (($row['DPM'] ?? '') === 'Y') { echo renderStatusCellWithDate($row['DPM'], $row['DPMlu'], 30, 'OK (DPM)'); }
|
|
else { echo renderStatusCellWithDate($row['NBU'] ?? $row['DPM'] ?? null, null, 30); }
|
|
|
|
// SCOM
|
|
if (($row['SCOM'] ?? '') === 'Y') { echo "<td class='bg-success text-white'>OK</td>"; }
|
|
elseif (isset($row['SCOM'])) { echo "<td class='bg-secondary'><small>".htmlspecialchars($row['SCOM'])."</small></td>"; }
|
|
else { echo "<td class='bg-warning text-black'>Missing</td>"; }
|
|
|
|
// Zabbix
|
|
$zabbixStatus = $row['zabbix'] ?? '';
|
|
if ($zabbixStatus === 'Y' || str_contains($zabbixStatus, '.')) { echo "<td class='bg-success text-white'>".htmlspecialchars(str_replace('Y', 'OK', $zabbixStatus))."</td>"; }
|
|
elseif (isset($row['zabbix'])) { echo "<td class='bg-secondary'><small>".htmlspecialchars($zabbixStatus)."</small></td>"; }
|
|
else { echo "<td class='bg-warning text-black'>Missing</td>"; }
|
|
|
|
// S1 (Comparison)
|
|
$s1Status = $row['S1'] ?? '';
|
|
$osRaw = $row['OS'] ?? '';
|
|
$targetMax = (stripos($osRaw, 'Windows') !== false) ? $maxS1Win : $maxS1Lin;
|
|
|
|
if (!empty($s1Status) && $s1Status === $targetMax && $targetMax !== "0") {
|
|
echo "<td class='bg-success text-white'>" . htmlspecialchars($s1Status) . " <i class='bi bi-check-all'></i></td>";
|
|
} elseif (str_contains($s1Status, '.')) {
|
|
echo "<td class='bg-warning text-black'>" . htmlspecialchars($s1Status) . "</td>";
|
|
} else {
|
|
echo renderStatusCellWithDate($s1Status, $row['S1lu'] ?? null, 7, ($s1Status === 'Y' ? 'OK' : $s1Status));
|
|
}
|
|
echo "</tr>";
|
|
}
|
|
//echo "<script>let kpiData = " . json_encode($counters) . ";</script>";
|
|
$stmt->close(); $conn->close();
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<button id="button" type="button" class="btn btn-primary btn-sm invisible"><i class="bi bi-arrow-clockwise"></i><b> Generate KPI</b></button>
|
|
|
|
<div class="row flex-nowrap text-center" style="zoom: 80%">
|
|
<div class="col"> <!-- CARTE Devices -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b><?php echo $w_allDevice; ?></b></div>
|
|
<a href="/crossover/GlobalCrossover.php">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-primary font-weight-bold" id="KPIDEVICE"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE OS -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b><?php echo $w_supportedOS; ?></b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=OS">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPIOS"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE AD -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>AD</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=AD">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPIAD"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE GLPI/FI -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>GLPI/FI</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=GLPI">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPIGLPI"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE SCCM -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>SCCM</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=SCCM">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPISCCM"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE EPO -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>NESSUS</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=NESSUS">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPIEPO"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE Backup (NBU + DPM) -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b><?php echo $w_backup; ?></b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=NBU">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPINBU"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE SCOM -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>SCOM</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=SCOM">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPISCOM"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE Zabbix -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>Zabbix</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=zabbix">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPIzabbix"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col"> <!-- CARTE SentinelOne -->
|
|
<div class="card border-secondary mb-3">
|
|
<div class="card-header text-dark"><b>SentinelOne</b></div>
|
|
<a href="/crossover/GlobalCrossover.php?filter=S1">
|
|
<div class="card-body">
|
|
<h2><span class="badge text-bg-secondary font-weight-bold" id="KPIS1"></span></h2>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="/js/switch.js"></script>
|
|
</body>
|
|
|
|
<script src="/crossover/Crossover-KPI.js"></script>
|
|
|
|
<script>
|
|
$(window).on('load', function () {
|
|
$('.preloader').addClass('preloader-deactivate');
|
|
});
|
|
|
|
$(function() {
|
|
// 1. Déclenchement du calcul
|
|
setTimeout(function () {
|
|
$('#button').trigger('click');
|
|
}, 500);
|
|
|
|
// 2. Gestion du redimensionnement
|
|
function adjustTableHeight() {
|
|
const $table = $('#t1');
|
|
if ($table.length && $table.offset()) {
|
|
const windowHeight = $(window).height();
|
|
const tableTop = $table.offset().top;
|
|
$table.bootstrapTable('refreshOptions', { height: Math.max(windowHeight - tableTop - 50, 400) });
|
|
}
|
|
}
|
|
|
|
$table = $('#t1');
|
|
$table.on('search.bs.table', function () { $('#button').trigger('click'); });
|
|
|
|
adjustTableHeight();
|
|
$(window).on('resize', adjustTableHeight);
|
|
});
|
|
</script>
|
|
</html>
|