66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>DHCPAdmin</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
</head>
|
|
<body>
|
|
<?php
|
|
$serviceStatusOKString = 'active';
|
|
|
|
$commandOutput = shell_exec("sudo /usr/bin/systemctl is-active isc-dhcp-server.service");
|
|
$serviceStatus = false;
|
|
|
|
if($commandOutput == $serviceStatusOKString) $serviceStatus = true;
|
|
?>
|
|
|
|
<?php if ($serviceStatus): ?>
|
|
<div class="alert alert-success" role="alert">
|
|
<h4 class="alert-heading">Service is running</h4>
|
|
<?php else: ?>
|
|
<div class="alert alert-danger" role="alert">
|
|
<h4 class="alert-heading">Service is stopped</h4>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<table class="table">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">#</th>
|
|
<th scope="col">MAC</th>
|
|
<th scope="col">IP</th>
|
|
<th scope="col">HOSTNAME</th>
|
|
<th scope="col">BEGIN</th>
|
|
<th scope="col">END</th>
|
|
<th scope="col">MANUFACTURER</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
$sourceData = shell_exec("sudo /usr/sbin/dhcp-lease-list --parsable");
|
|
$splittedData = explode(PHP_EOL, $sourceData);
|
|
|
|
for($i = 0; $i < count($splittedData); $i++)
|
|
{
|
|
$splittedDataRow = explode(' ', $splittedData[$i]);
|
|
if(!isset($splittedDataRow[2])) continue;
|
|
|
|
echo "<tr>\n";
|
|
echo "\t<th scope='row'>".$i."</th>\n";
|
|
echo "\t<td>".$splittedDataRow[1]."</td>\n";
|
|
echo "\t<td>".$splittedDataRow[3]."</td>\n";
|
|
echo "\t<td>".$splittedDataRow[5]."</td>\n";
|
|
echo "\t<td>".$splittedDataRow[7].' '.$splittedDataRow[8]."</td>\n";
|
|
echo "\t<td>".$splittedDataRow[10].' '.$splittedDataRow[11]."</td>\n";
|
|
echo "\t<td>".$splittedDataRow[13]."</td>\n";
|
|
echo "</tr>\n";
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
|
</body>
|
|
</html>
|