Code: Select all
require('routeros_api.class.php');
function recorro($matriz)
{
foreach($matriz as $key=>$value)
{
if (is_array($value))
{
//echo $value["name"].'<br>';
//si es un array busco dentro
if ($value["name"] == $mac)
{
//si coincide con el valor deseado, lo devuelvo para usarlo
return $value['.id'];
break;
}
recorro($value);
}else{
//si es un elemento continuo
continue;
}
}
}
if ($API->connect('IP', 'USER', 'PASSWORD'))
{
echo '<br><br>';
echo 'Conecatado Ok';
echo '<br><br>';
$API->write('/ip/hotspot/user/print',true);
$READ = $API->read(true);
$id = recorro($READ);
$API->write('/ip/hotspot/user/disable',false);
$API->write('=.id=' . $id);
echo 'Buscado: '.$id;
echo '<br><br>';
//print_r($READ);
echo '<br><br>';
$API->write('/ip/hotspot/active/print',true);
$READ2 = $API->read(true);
foreach ($READ2 as $value2) {
//echo $value2['mac-address'].'<br>';
if ($value2['mac-address'] == $mac)
{
$API->write('/ip/hotspot/active/remove',false);
$API->write('=.id=' . $value2['.id']);
$KILL = $API->read();
echo 'Encontrado ';
echo $value2['.id'];
}
}
//print_r($READ2);
$API->disconnect();
}
if i send the $mac value from other web, or form, ($_GET) the api seems dont get this value,
if i use $value["name"] == "MAC ADDRESS", the api works fine.
any idea why the api dont read the value of the var?
thanks