Advertisement
Guest User

Untitled

a guest
May 30th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <?php
  2. require "crud/Conexion.php";
  3. require "crud/Crud.php";
  4. require 'api/api_mt_include2.php';
  5. $mensaje = null;
  6.  
  7.  
  8. class action{
  9. public $host;
  10. public function conectap()
  11. {
  12.  
  13. //$this->mensaje = $host . "responde!!";
  14. $Username="ecnex";
  15. $Pass="soporte";
  16. $api_puerto=8728;
  17. $connect = mysqli_connect("localhost", "root", "elrbsest", "ejercicios");
  18. $mac_to_delete = null;
  19. $host = $this->host;
  20. // conecto al MK
  21. $API = new routeros_api();
  22. $API->debug = false;
  23. if ($API->connect($host , $Username , $Pass, $api_puerto))
  24. {
  25. print "conectado a $host\n";
  26. $API->write("/interface/wireless/registration-table/getall",true);
  27. $READ = $API->read(false);
  28. $ARRAY = $API->parse_response($READ);
  29. $API->write("/system/identity/getall",true);
  30. $READ_2= $API->read(false);
  31. $ARRAY_2 = $API->parse_response($READ_2);
  32. $API->write("/ip/address/getall",true);
  33. $READ_3= $API->read(false);
  34. $ARRAY_3 = $API->parse_response($READ_3);
  35. $API->write("/system/resource/getall",true);
  36. $READ_4= $API->read(false);
  37. $ARRAY_4 = $API->parse_response($READ_4);
  38. $API->write("/interface/wireless/getall",true);
  39. $READ_5 = $API->read(false);
  40. $WIRELESS = $API->parse_response($READ_5);
  41. $API->disconnect();
  42. $cantidad_usuarios = '';
  43.  
  44. if(isset($ARRAY[0]{'mac-address'}))
  45. {
  46. for($j = 0;$j < count($ARRAY); $j++)
  47. {
  48.  
  49. $cantidad_usuarios = $j;
  50. }
  51. }
  52. echo "Desconectado de $host\n";
  53. if ($cantidad_usuarios){
  54. $ARRAY[0]{'cantidad_usuarios'} = $cantidad_usuarios;
  55. }
  56. else
  57. {
  58. $ARRAY[0]{'cantidad_usuarios'} = 0;
  59. }
  60. $ARRAY[0]{'ap_name'} = $ARRAY_2[0]{'name'};
  61. $ARRAY[0]{'ip_ap'} = $host;
  62. $ARRAY[0]{'cpu_load'} = $ARRAY_4[0]{"cpu-load"};
  63. $ARRAY[0]{'ap_uptime'} = $ARRAY_4[0]{"uptime"};
  64. $ARRAY[0]{'ssid'} = $WIRELESS[0]{'ssid'};
  65. $ARRAY[0]{'frequency'} = $WIRELESS[0]{'frequency'};
  66. }
  67. else
  68. {
  69. //print "error al conectar a $host\n";
  70. $this->mensaje = '';
  71. }
  72. return $ARRAY;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement