In localhost is all right, without fail. When i put it in server on line, i have a random failure conection. I don´t understend what happening.
My code to remove:
function apagarequipamento($id)
{
$dadosplaca = $this->Equipamento->findById($id);
// DEFINIÇÕES DO SISTEMA
define('USER_PADRAO', 'manut'); // User
define('ADMIN_SISTEMA', 'zuca'); // Admin system
define('SENHA_SISTEMA', '123456'); // test password
$ip = $dadosplaca['Equipamento']['ip']; // IP of MIKROTIK
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ACTION IN MIKROTIK
require('routeros_api.class.php'); // API PHP
$API = new routeros_api();
$API->debug = true;
if ($API->connect($ip, ADMIN_SISTEMA, SENHA_SISTEMA)) // ****** Problem, i think, is here. But why on line and localhost not?
{
$API->write('/user/remove', false);
$API->write('=.id='.USER_PADRAO);
$ARRAY = $API->read();
$this->Equipamento->delete($id); // Save data. If mikrotik fail, this fail to.
$API->disconnect();
$mensagem = 'REMOVED WITH SUCESS!
<br/> PLACA: '.$ip;
$this->Session->setFlash($mensagem);
$this->redirect(array('action' => 'index'));
}
else
{
$mensagem = 'FAILURE ('.$ip.'). // [i][u]I receive this message when debug is false[/u][/i]
<br/> >> USER NOT REMOVE <<
<br/> >> DAT NOT REMOVE <<';
$this->Session->setFlash($mensagem);
$this->redirect(array('action' => 'index'));
}
// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: AÇÃO NO MIKROTIK
}
}