Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "crud/Conexion.php";
- require "crud/Crud.php";
- require 'api/api_mt_include2.php';
- $mensaje = null;
- class action{
- public $host;
- public function conectap()
- {
- //$this->mensaje = $host . "responde!!";
- $Username="ecnex";
- $Pass="soporte";
- $api_puerto=8728;
- $connect = mysqli_connect("localhost", "root", "elrbsest", "ejercicios");
- $mac_to_delete = null;
- $host = $this->host;
- // conecto al MK
- $API = new routeros_api();
- $API->debug = false;
- if ($API->connect($host , $Username , $Pass, $api_puerto))
- {
- print "conectado a $host\n";
- $API->write("/interface/wireless/registration-table/getall",true);
- $READ = $API->read(false);
- $ARRAY = $API->parse_response($READ);
- $API->write("/system/identity/getall",true);
- $READ_2= $API->read(false);
- $ARRAY_2 = $API->parse_response($READ_2);
- $API->write("/ip/address/getall",true);
- $READ_3= $API->read(false);
- $ARRAY_3 = $API->parse_response($READ_3);
- $API->write("/system/resource/getall",true);
- $READ_4= $API->read(false);
- $ARRAY_4 = $API->parse_response($READ_4);
- $API->write("/interface/wireless/getall",true);
- $READ_5 = $API->read(false);
- $WIRELESS = $API->parse_response($READ_5);
- $API->disconnect();
- $cantidad_usuarios = '';
- if(isset($ARRAY[0]{'mac-address'}))
- {
- for($j = 0;$j < count($ARRAY); $j++)
- {
- $cantidad_usuarios = $j;
- }
- }
- echo "Desconectado de $host\n";
- if ($cantidad_usuarios){
- $ARRAY[0]{'cantidad_usuarios'} = $cantidad_usuarios;
- }
- else
- {
- $ARRAY[0]{'cantidad_usuarios'} = 0;
- }
- $ARRAY[0]{'ap_name'} = $ARRAY_2[0]{'name'};
- $ARRAY[0]{'ip_ap'} = $host;
- $ARRAY[0]{'cpu_load'} = $ARRAY_4[0]{"cpu-load"};
- $ARRAY[0]{'ap_uptime'} = $ARRAY_4[0]{"uptime"};
- $ARRAY[0]{'ssid'} = $WIRELESS[0]{'ssid'};
- $ARRAY[0]{'frequency'} = $WIRELESS[0]{'frequency'};
- }
- else
- {
- //print "error al conectar a $host\n";
- $this->mensaje = '';
- }
- return $ARRAY;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement