Capture screen return from OLT CIANET device with PHP

4

I am trying to capture data from a 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 an example of how to send and capture OLT, thank you in advance.

    
asked by anonymous 26.05.2014 / 14:42

1 answer

1
<?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>&#10004;</font>";';
  } else {
   $html .= 'document.getElementById("fish'.$slot.''.$c4.'").innerHTML =
      "<font color=red>&#10008;</font>";';
  }
 }
 $html .= '</script>'.PHP_EOL;
 echo $html;
 // echo '<pre>'.$html."</pre>";
?>
    
30.05.2014 / 15:28