Files
Web-Infra-Reports-IT/Network/dhcp_detail.php
e025532 1f1b7dcd22 Update VM and DHCP management pages, optimize code
- 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.
2026-04-14 13:59:24 +02:00

155 lines
6.4 KiB
PHP

<?php
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
$server = $_GET['s'] ?? '';
$ts = date("Y-m-d");
$data = Invoke_Entry01("SELECT dump FROM dump_dhcp where ts ='$ts' and server = '$server'");
$xmlRaw = $data[0]['dump'] ?? '';
if (!$xmlRaw) {
die("Aucune donnée trouvée pour le serveur $server à la date $ts");
}
$xmlString = mb_convert_encoding($xmlRaw, 'UTF-8', 'ISO-8859-1');
if (!str_contains($xmlString, '<?xml')) {
$xmlString = '<?xml version="1.0" encoding="UTF-8"?>' . $xmlString;
}
try {
$xml = new SimpleXMLElement($xmlString);
} catch (Exception $e) {
echo "Erreur de parsing XML : " . $e->getMessage();
exit;
}
$definitions = [];
foreach ($xml->xpath("//OptionDefinition") as $optDef) {
$definitions[(string)$optDef->OptionId] = (string)$optDef->Name;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<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">
<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">
<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">
<?php include $_SERVER['DOCUMENT_ROOT'] . "/navbar.html"; ?>
</div>
<div class="col py-3">
<h1><span class="badge bg-secondary text-white w-100"><?php echo htmlspecialchars($server); ?></span></h1>
<div class="card mb-3 bg-light text-dark">
<div class="card-header bg-info text-white">
<a class="fw-bold text-black" data-bs-toggle="collapse" href="#OptVal"><?php echo $w_globalOptionValues ; ?></a>
</div>
<div id="OptVal" class="collapse show">
<div class="card-body bg-white text-black">
<?php
$globalOptions = $xml->xpath("//IPv4/OptionValues/OptionValue");
foreach ($globalOptions as $opt):
$idx = (string)$opt->OptionId;
$vals = [];
foreach ($opt->Value as $v) $vals[] = (string)$v;
?>
<div class="row row-option">
<div class="col-md-3"><strong><?php echo $idx; ?></strong> - <?php echo $definitions[$idx] ?? 'Unknown'; ?></div>
<div class="col-md-6"><?php echo implode(" ; ", $vals); ?></div>
<div class="col-md-3 text-muted small"><?php echo (string)$opt->VendorClass; ?></div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php
foreach ($xml->xpath("//Scope") as $scope):
$scopeIdRaw = (string)$scope->ScopeId;
$cleanId = "scope_" . str_replace('.', '', $scopeIdRaw);
$scopeName = (string)$scope->Name;
?>
<div class="card mb-2">
<div class="card-header bg-success text-white">
<a class="text-white fw-bold" data-bs-toggle="collapse" href="#<?php echo $cleanId; ?>">
<?php echo "$scopeIdRaw ($scopeName)"; ?>
</a>
</div>
<div id="<?php echo $cleanId; ?>" class="collapse">
<div class="card-body bg-white text-black">
<div class="row mb-3 text-center bg-secondary text-light py-2">
<div class="col-md-4"><strong><?php echo $w_start; ?>:</strong> <?php echo (string)$scope->StartRange; ?></div>
<div class="col-md-4"><strong><?php echo $w_end; ?>:</strong> <?php echo (string)$scope->EndRange; ?></div>
<div class="col-md-4"><strong><?php echo $w_mask; ?>:</strong> <?php echo (string)$scope->SubnetMask; ?></div>
</div>
<h6 class="fw-bold border-bottom"><?php echo $w_scopeOptions; ?></h6>
<?php foreach ($scope->OptionValues->OptionValue as $sOpt):
$sIdx = (string)$sOpt->OptionId;
$sVals = [];
foreach ($sOpt->Value as $sv) $sVals[] = (string)$sv;
?>
<div class="row small row-option">
<div class="col-md-3"><strong><?php echo $sIdx; ?></strong> <?php echo $definitions[$sIdx] ?? ''; ?></div>
<div class="col-md-6"><?php echo implode(" ; ", $sVals); ?></div>
<div class="col-md-3 text-muted"><?php echo (string)$sOpt->VendorClass; ?></div>
</div>
<?php endforeach; ?>
<h6 class="fw-bold border-bottom mt-3"><?php echo $w_reservations; ?></h6>
<div class="table-responsive">
<table class="table table-sm table-hover">
<thead>
<tr class="table-secondary">
<th><?php echo $w_name; ?></th><th>IP</th><th>MAC</th><th>Description</th>
</tr>
</thead>
<tbody>
<?php
$reservations = $scope->Reservations->Reservation ?? null;
if ($reservations):
foreach ($reservations as $res): ?>
<tr>
<td><?php echo (string)$res->Name; ?></td>
<td><?php echo (string)$res->IPAddress; ?></td>
<td><code><?php echo (string)$res->ClientId; ?></code></td>
<td class="text-muted"><?php echo (string)$res->Description; ?></td>
</tr>
<?php endforeach;
else: ?>
<tr><td colspan="4" class="text-center text-muted"><em>Aucune réservation sur ce scope</em></td></tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</body>
<script src="/js/switch.js"></script>
</html>