Capture screen return of OLT CIANET equipment with PHP
I am trying to capture data from an OLT CIANET via Telnet or SSH and I have not been successful, I want to know in which slot / pon the ONU is connected, the command to display the ONUs I use is:
show port epon ".$slot."/1-4 onu mac ".$mac." epon-mac-address-table
I tried using an SSH class and another Telnet, I did not succeed in any of them, if someone has a telnet or ssh class, or example of how to send and capture those from OLT, I thank you.
4
Author: bfavaretto, 2014-05-26
1 answers
<?php
// error_reporting(0);
$slot = $_GET['slot'];
$mac = str_replace(":","",$_GET['mo']);
$ip = 'ip_do_equipamento_na_sua_rede';
$user = 'seu_usuario';
$pass = 'sua_senha_de_acesso';
$porta = 'porta_do_socket';
$cmd = "show port epon ".$slot."/1-4 onu mac '.$mac.' epon-mac-address-table";
include('../Net/SSH2.php');
$sftp = new Net_SSH2($ip,$porta);
$sftp->login($usuario, $pass);
$sftp->write("enable\n");
$sftp->write($cmd."\n");
$saida = $sftp->read('port '.$slot.'/1');
$sftp->write("exit\n");
$saida = $sftp->read('exit');
$sftp->disconnect();
$bomba = explode(''.$slot.'/',$saida); //
$lin = count($bomba);
$html = '<script type="text/javascript">'.PHP_EOL;
for($i=0; $i<$lin; $i++) {
$pedaco = $bomba[$i];
$c4 = explode("\n", $pedaco);
$contador = count($c4);
$c4 = 1 + $i;
if($contador > 3) {
$html .= 'document.getElementById("fish'.$slot.''.$c4.'").innerHTML =
"<font color=green>✔</font>";';
} else {
$html .= 'document.getElementById("fish'.$slot.''.$c4.'").innerHTML =
"<font color=red>✘</font>";';
}
}
$html .= '</script>'.PHP_EOL;
echo $html;
// echo '<pre>'.$html."</pre>";
?>
1
Author: Fabio Branco da Silva, 2014-05-30 17:09:12