how to online user kick script

freeradius + dialup_admin

<?php require('./routeros_aip.class.php'); $API = new routeros_api(); $API->debug = true; if ($API->connect(1.1.1.1, 'test', '1234')) { // Change this as necessery $API->write('/interface/pptp-server/remove [find user=ppp1]'); //$API->write('/ppp active remove [find name="ppp1"]'); $API->disconnect(); } ?>

Connection attempt #1 to 1.1.1.1:8728… <<< [6] /login >>> [5/5] bytes read. >>> [5, 39]!done >>> [37/37] bytes read. >>> [37, 1]=ret=d5fd71d5d0a33246051b787657209da7 <<< [6] /login <<< [10] =name=test <<< [44] =response=0045adad336ab5fc9192dadfa2c079198d >>> [5/5] bytes read. >>> [5, 1]!done Connected… <<< [37] /ppp active remove [find name=“ppp1”] Disconnected…

Please help me…

‘find’ command, is not available in api. use queries and proplist instead.
for more information, take a look at wiki:

http://wiki.mikrotik.com/wiki/Manual:API
http://wiki.mikrotik.com/wiki/API_command_notes

It’s also worth noting that API commands need to be supplied one by one. They can’t be nested like scripting commands.

Using the client from my signature, you can do it like:

<?php
namespace PEAR2\Net\RouterOS;
require_once 'PEAR2/Net/RouterOS/Autoload.php';

$client = new Client('1.1.1.1', 'test', '1234');

$printRequest = new Request('/interface pptp-server print .proplist=.id');
$printRequest->setQuery(Query::where('user', 'ppp1'));

$id = $client->sendSync($printRequest)->getArgument('.id');

$removeRequest = new Request('/interface pptp-server remove');
$removeRequest->setArgument('numbers', $id);
$client->sendSync($removeRequest);
 

(assuming there is only one entry matching the query; If there are more, only the first will be removed with this code “as is”, but if needed, it can easily be switched to match all)

Thank you for your answer.