From e49457080733b00e97fe42b529d882899aa64e59 Mon Sep 17 00:00:00 2001 From: Ibnu Maksum Date: Fri, 15 Sep 2023 13:34:56 +0700 Subject: [PATCH] sync pool to Mikrotik --- system/controllers/pool.php | 11 +++++++++++ ui/ui/pool.tpl | 15 +++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/system/controllers/pool.php b/system/controllers/pool.php index 925f2ef5..c633dc75 100644 --- a/system/controllers/pool.php +++ b/system/controllers/pool.php @@ -70,6 +70,17 @@ switch ($action) { } break; + case 'sync': + $pools = ORM::for_table('tbl_pool')->find_many(); + $log = ''; + foreach($pools as $pool){ + $mikrotik = Mikrotik::info($pool['routers']); + $client = Mikrotik::getClient($mikrotik['ip_address'], $mikrotik['username'], $mikrotik['password']); + Mikrotik::addPool($client, $pool['pool_name'], $pool['range_ip']); + $log .= 'DONE: '.$pool['pool_name'].': '.$pool['range_ip'].'
'; + } + r2(U . 'pool/list', 's', $log); + break; case 'add-post': $name = _post('name'); $ip_address = _post('ip_address'); diff --git a/ui/ui/pool.tpl b/ui/ui/pool.tpl index d49a78f1..a5e40ecd 100644 --- a/ui/ui/pool.tpl +++ b/ui/ui/pool.tpl @@ -3,7 +3,14 @@
-
{$_L['Pool']}
+
+
+ sync +
+ {$_L['Pool']} +
@@ -45,9 +52,9 @@ {$ds['range_ip']} {$ds['routers']} - {$_L['Edit']} - {$_L['Edit']} + {$_L['Delete']}