From Morten, 1 Year ago, written in Plain Text.
Embed
  1. <?php
  2.  
  3. $leases = [];
  4. $filename = "dhcpleases.txt";
  5. $file_handle = fopen($filename, "rb");
  6. while(!feof($file_handle))
  7. {
  8.   $leases[] = fgetcsv($file_handle, 0, ';');
  9. }
  10.  
  11. ?>
  12.  
  13. <html>
  14.     <head>
  15.         <title>DHCP leases</title>
  16.         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  17.         <style>
  18.             .content
  19.             {
  20.                 padding: 40px 80px 0;
  21.             }
  22.             .monospace
  23.             {
  24.                 font-family: monospace;
  25.                 font-size: 15px;
  26.             }
  27.         </style>
  28.     </head>
  29.     <body>
  30.         <div class="content">
  31.             <h1>DHCP leases</h1>
  32.             <table class="table table-striped table-hover table-bordered">
  33.                 <caption>
  34.                     <?=$filename?> was last modified: <strong style="font-weight: 500"><?=date("F d Y H:i:s.", filemtime($filename))?></strong>
  35.                 </caption>
  36.                 <thead>
  37.                     <tr>
  38.                         <th>Expire time</th>
  39.                         <th>MAC address</th>
  40.                         <th>IP address</th>
  41.                         <th>Hostname</th>
  42.                     </tr>
  43.                 </thead>
  44.                 <tbody>
  45.                     <?php foreach($leases as $lease): ?>
  46.                     <tr>
  47.                         <td><?=$lease[0]?></td>
  48.                         <td class="monospace"><?=$lease[1]?></td>
  49.                         <td class="monospace"><?=$lease[2]?></td>
  50.                         <td><a href="<?=strpos($lease[3], 'http') !== 0 ? "http://{$lease[3]}" : $lease[3]?>"><?=$lease[3]?></a></td>
  51.                     </tr>
  52.                     <?php endforeach ?>
  53.                 </tbody>
  54.             </table>
  55.         </div>
  56.   </body>
  57. </html>
  58.