Community discussions

MikroTik App
 
tact1982
just joined
Topic Author
Posts: 21
Joined: Thu Feb 18, 2010 11:13 pm

How do I read user manager End Time by php API

Tue Jul 17, 2012 9:17 am

How do I read user manager End Time by php API
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How do I read user manager End Time by php API

Tue Jul 17, 2012 8:44 pm

I assume you mean the session's "till-time"? I mean, I can't find anything closer to that...

Using my client (see my signature), you can do it like so:
<?php
namespace PEAR2\Net\RouterOS;
require_once 'PEAR2/Net/RouterOS/Autoload.php';

$client = new Client('192.168.0.1', 'admin', 'password');

header('Content-Type: text/plain');//This is just to get nice text formatting...

foreach ($client->sendSync(new Request('/tool user-manager session print'))->getAllOfType(Response::TYPE_DATA) as $response) {
    echo 'User: ', $response->getArgument('user'), "\nEnd time: ", $response->getArgument('till-time'), "\n\n";
} 
(assuming you want this for all users)
Last edited by boen_robot on Fri Jul 20, 2012 5:12 pm, edited 1 time in total.
 
tact1982
just joined
Topic Author
Posts: 21
Joined: Thu Feb 18, 2010 11:13 pm

Re: How do I read user manager End Time by php API

Thu Jul 19, 2012 3:24 am

I did not find this file
PEAR2/Net/RouterOS/Autoload.php

in your script
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: How do I read user manager End Time by php API

Thu Jul 19, 2012 1:30 pm

From my signature, you can download an archive (there's a TGZ and ZIP versions; both are equivalent, so it doesn't matter which of the two you get). All files, including Autoload.php, are in the "src" folder of the archive. Extract all files from that folder somewhere, and adjust the path in the script above so that it points to Autoload.php.


(I'm going to release a new version soon, that will contain everything within a single .phar file that will be require_once'd directly... hopefully, that will make things easier)
 
tact1982
just joined
Topic Author
Posts: 21
Joined: Thu Feb 18, 2010 11:13 pm

Re: How do I read user manager End Time by php API

Fri Jul 20, 2012 12:08 am

ok thank you i try now

Who is online

Users browsing this forum: No registered users and 15 guests