Hi everyone, i would like to ask if i could use CLI script to be run on PHP?
i was reading about php script and came across with @boen.robot pdf
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
$client = new RouterOS\Client('192.168.0.1', 'admin', 'password');
header('Content-Type: text/plain');
$util = new RouterOS\Util($client);
$util->exec('
/ip dhcp-client lease
make-static [find address=$address]
comment [find address=$address] $name
/log info "User $name now has the static IP $address"
',
array(
'name' => $_GET['user'],
'address' => $_GET['ip']
)
);
i was thinking
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
$client = new RouterOS\Client('192.168.0.1', 'admin', 'password');
header('Content-Type: text/plain');
$util = new RouterOS\Util($client);
$util->exec('
/ system script add name="delete_user" source={
:foreach i in [/ip hotspot user find secret=tommy] do={
:if ([/ip hotspot user get $i limit-uptime]<=[/ip hotspot user get $i \
uptime]) do={
/ip hotspot user remove $i
}
}
}
',
array(
'name' => $_GET['user'],
'address' => $_GET['ip']
)
);
can i be able to run CLI script using PHP? i apologize for being a noob, just learning php. thank you