Hello everyone ,
can you help me get user manager End time & Till time values using php API
Thanks in advance
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
$util = new RouterOS\Util($client = new RouterOS\Client('router', 'username', 'password'));
$items = $util->setMenu('/tool user-manager session')->getAll(array('.proplist' => 'user,till-time'));
foreach ($items as $item) {
echo 'Username ' . $item('user') . ' will have internet until ' . $item('till-time') . ";\n";
}
[admin@MikroTik] > /tool user-manager
[admin@MikroTik] /tool user-manager>
customer history payment router user
database log profile session export
[admin@MikroTik] /tool user-manager> user
add create-and-activate-profile edit export print reset-counters
comment disable enable find remove set
[admin@MikroTik] /tool user-manager> user get value-name=
active first-name reg-key
active-sessions incomplete registration-date
actual-profile ip-address shared-users
caller-id last-name upload-used
caller-id-bind-on-first-use last-seen uptime-used
comment location username
customer name wireless-enc-algo
disabled password wireless-enc-key
download-used phone wireless-psk
email random-password
[admin@MikroTik] /tool user-manager> profile
limitation add edit find remove
profile-limitation comment export print set
[admin@MikroTik] /tool user-manager> profile get value-name=
comment name-for-users owner starts-at
name override-shared-users price validity
[admin@MikroTik] /tool user-manager> profile profile-limitation
add comment edit export find print remove set
[admin@MikroTik] /tool user-manager> profile profile-limitation get value-name=
comment from-time limitation profile till-time weekdays
[admin@MikroTik] /tool user-manager>
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
$util = new RouterOS\Util($client = new RouterOS\Client('router', 'username', 'password'));
$userManDateTimeFormat = 'm/d/Y H:i:s';
$users = $util->setMenu('/tool user-manager user')->getAll(array('.proplist' => 'name,actual-profile'));
foreach ($users as $user) {
echo 'Username ' . $user('name') . ' will have internet until ';
$profileLimits = $util->setMenu('/tool user-manager profile profile-limitation')->getAll(array('.proplist' => 'till-time'), RouterOS\Query::where('profile', $user('actual-profile')));
$endTime = DateTime::createFromFormat($userManDateTimeFormat, $profileLimits->current()->getProperty('till-time'));
while ($profileLimits->next()) {
$nextEndTime = DateTime::createFromFormat($userManDateTimeFormat, $profileLimits->current()->getProperty('till-time'));
if ($nextEndTime > $endTime) {
$endTime = $nextEndTime;
}
}
echo $endTime->format($userManDateTimeFormat);
}
[admin@MikroTik] /tool user-manager> user get value-name=
active first-name reg-key
active-sessions incomplete registration-date
actual-profile ip-address shared-users
caller-id last-name upload-used
caller-id-bind-on-first-use last-seen
uptime-used comment location
username customer name
wireless-enc-algo disabled password
wireless-enc-key download-used phone
wireless-psk email random-password
/tool user-manager
customer print
user print
session print
profile print
profile profile-limitation print
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b5.phar';
$util = new RouterOS\Util($client = new RouterOS\Client('router', 'username', 'password'));
$userManDateTimeFormat = 'm/d/Y H:i:s';
$users = $util->setMenu('/tool user-manager user')->getAll(array('.proplist' => 'name,active-sessions'));
foreach ($users as $user) {
echo 'Username ' . $user('name');
$activeSessions = $util->setMenu('/tool user-manager session')->getAll(array('from' => $user('active-sessions')));
if (count($activeSessions) === 0) {
echo ' does not have internet currently.';
} else {
$endTime = DateTime::createFromFormat($userManDateTimeFormat, $activeSessions->current()->getProperty('till-time'));
while ($activeSessions->next()) {
$nextEndTime = DateTime::createFromFormat($userManDateTimeFormat, $activeSessions->current()->getProperty('till-time'));
if ($nextEndTime > $endTime) {
$endTime = $nextEndTime;
}
}
echo ' will have internet until ' . $endTime->format($userManDateTimeFormat);
}
}