mirror of
https://github.com/mivodev/mivo.git
synced 2026-01-26 13:31:56 +07:00
Initial Release v1.0.0: Full feature set with Docker automation, Nginx/Alpine stack
This commit is contained in:
38
app/Controllers/DhcpController.php
Normal file
38
app/Controllers/DhcpController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Core\Controller;
|
||||
use App\Models\Config;
|
||||
use App\Libraries\RouterOSAPI;
|
||||
use App\Helpers\HotspotHelper;
|
||||
|
||||
class DhcpController extends Controller
|
||||
{
|
||||
public function index($session)
|
||||
{
|
||||
$configModel = new Config();
|
||||
$config = $configModel->getSession($session);
|
||||
if (!$config) {
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
$leases = [];
|
||||
$API = new RouterOSAPI();
|
||||
$API->attempts = 1;
|
||||
$API->timeout = 3;
|
||||
|
||||
if ($API->connect($config['ip_address'], $config['username'], $config['password'])) {
|
||||
// Fetch DHCP Leases
|
||||
$leases = $API->comm("/ip/dhcp-server/lease/print");
|
||||
$API->disconnect();
|
||||
}
|
||||
|
||||
// Add index for viewing
|
||||
return $this->view('network/dhcp', [
|
||||
'session' => $session,
|
||||
'leases' => $leases ?? []
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user