sync pool to Mikrotik

This commit is contained in:
Ibnu Maksum 2023-09-15 13:34:56 +07:00
parent 95a8eaeadb
commit e494570807
No known key found for this signature in database
GPG key ID: 7FC82848810579E5
2 changed files with 22 additions and 4 deletions

View file

@ -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'].'<br>';
}
r2(U . 'pool/list', 's', $log);
break;
case 'add-post':
$name = _post('name');
$ip_address = _post('ip_address');

View file

@ -3,7 +3,14 @@
<div class="row">
<div class="col-sm-12">
<div class="panel panel-hovered mb20 panel-primary">
<div class="panel-heading">{$_L['Pool']}</div>
<div class="panel-heading">
<div class="btn-group pull-right">
<a class="btn btn-primary btn-xs" title="save" href="{$_url}pool/sync"
onclick="return confirm('This will sync/send IP Pool to Mikrotik?')"><span
class="glyphicon glyphicon-refresh" aria-hidden="true"></span> sync</a>
</div>
{$_L['Pool']}
</div>
<div class="panel-body">
<div class="md-whiteframe-z1 mb20 text-center" style="padding: 15px">
<div class="col-md-8">
@ -45,9 +52,9 @@
<td>{$ds['range_ip']}</td>
<td>{$ds['routers']}</td>
<td align="center">
<a href="{$_url}pool/edit/{$ds['id']}"
class="btn btn-info btn-xs">{$_L['Edit']}</a>
<a href="{$_url}pool/delete/{$ds['id']}" id="{$ds['id']}" onclick="return confirm('{$_L['Delete']}?')"
<a href="{$_url}pool/edit/{$ds['id']}" class="btn btn-info btn-xs">{$_L['Edit']}</a>
<a href="{$_url}pool/delete/{$ds['id']}" id="{$ds['id']}"
onclick="return confirm('{$_L['Delete']}?')"
class="btn btn-danger btn-xs">{$_L['Delete']}</a>
</td>
</tr>