Community discussions

MikroTik App
 
snakepitwalt
just joined
Topic Author
Posts: 17
Joined: Wed May 27, 2015 5:11 pm

how to remove a active connections with API PHP?

Tue Nov 24, 2015 11:29 pm

hi, i need remove active connections from PPPOE of a single user from with PHP API

paste a capture screen.

Image

routeros_api.class.php use. my syntax is similar to the following but no found

by terminal I run this command: interface pppoe-server remove <pppoe-14703>
<?php

include('routeros_api.class.php');
$Username="laklfasd";
$Pass="sadasjkdaskljd";
$api_puerto=8728;
$usuario = 'asdjlkasdl';
$ipRouteros = 'asdñaksdl';

//$comando = 'interface pppoe-server remove <pppoe-14703>';




$API = new routeros_api();
$API->debug = true;
if ($API->connect($ipRouteros , $Username , $Pass, $api_puerto)) {
$API->comm("interface pppoe-server remove <pppoe-14703>");

}
?>

THANKS!!!
 
mwarren77
just joined
Posts: 18
Joined: Tue Oct 20, 2009 10:28 pm

Re: how to remove a active connections with API PHP?

Wed Nov 25, 2015 8:56 pm

try something like

$API->write('/interface/pppoe-server/print', false);
$API->write('=.proplist=.id,name');
$ARRAY = $API->read();
foreach($ARRAY as $keys=>$val){
if($ARRAY[$keys]['name'] == '<pppoe-14703>'){
$API->write('/interface/pppoe-server/remove',false);
$API->write('=.id='.$ARRAY[$keys]['.id']);
}
}

or

$API->write('/interface/pppoe-server/print', false);
$API->write('=.proplist=.id', false);
$API->write('?name=<pppoe-14703>');
$ARRAY = $API->read();
$API->write('/interface/pppoe-server/remove',false);
$API->write('=.id='.$ARRAY[0]['.id']);
I would print the output of $ARRAY via print_r($ARRAY) to make sure that is right on the id.

That is one way . you may need to fiddle with the exact pppoe fields but think that will work.
 
snakepitwalt
just joined
Topic Author
Posts: 17
Joined: Wed May 27, 2015 5:11 pm

Re: how to remove a active connections with API PHP?

Wed Nov 25, 2015 10:27 pm

try something like

$API->write('/interface/pppoe-server/print', false);
$API->write('=.proplist=.id,name');
$ARRAY = $API->read();
foreach($ARRAY as $keys=>$val){
if($ARRAY[$keys]['name'] == '<pppoe-14703>'){
$API->write('/interface/pppoe-server/remove',false);
$API->write('=.id='.$ARRAY[$keys]['.id']);
}
}

or

$API->write('/interface/pppoe-server/print', false);
$API->write('=.proplist=.id', false);
$API->write('?name=<pppoe-14703>');
$ARRAY = $API->read();
$API->write('/interface/pppoe-server/remove',false);
$API->write('=.id='.$ARRAY[0]['.id']);
I would print the output of $ARRAY via print_r($ARRAY) to make sure that is right on the id.

That is one way . you may need to fiddle with the exact pppoe fields but think that will work.

not found :( :(

returns
'Connection attempt #1 to 10.28.1.2:8728... <<< [6] /login >>> [5/5] bytes read. >>> [5, 39]!done >>> [37/37] bytes read. >>> [37, 1]=ret=2cf454b8e830f77b78d7a9d5b33a73 <<< [6] /login <<< [14] =name=prueba <<< [44] =response=00473cbb0bc842e37c2aae464e44b07d >>> [5/5] bytes read. >>> [5, 1]!done Connected... <<< [42] /interface/pppoe-server/remove=.id=*F2CEFC'

but no delete to PPPO-SERVER

the user is 14703 do not know if you can delete via user.
 
User avatar
seriousblack
newbie
Posts: 36
Joined: Tue Apr 03, 2018 4:02 am
Contact:

Re: how to remove a active connections with API PHP?

Sat Jan 02, 2021 5:07 pm

 
 $client = zero_says
 
 $wofBIT=$API->comm("/ppp/active/getall",
                    array(
                           ".proplist"=> ".id",
                                 "?name" => $client,
                              ));
                              
            $API->comm("/ppp/active/remove",
                  array(
                           ".id" => $wofBIT[0][".id"],
                           )
                  );
:idea:

Who is online

Users browsing this forum: eworm, jvzg545cr and 19 guests