PHP Класс RouterosAPI, routeros-api

RouterOS PHP API class v1.6 Author: Denis Basta Contributors: Nick Barnes Ben Menking (ben [at] infotechsc [dot] com) Jeremy Jefferson (http://jeremyj.com) Cristian Deluxe (djcristiandeluxe [at] gmail [dot] com) Mikhail Moskalev (mmv.rus [at] gmail [dot] com) http://www.mikrotik.com http://wiki.mikrotik.com/wiki/API_PHP_class ****************************
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$attempts Connection attempt timeout and data read timeout
$connected Show debug information
$debug
$delay Connection attempt count
$error_no Variable for storing socket resource
$error_str Variable for storing connection error number, if any
$port Connection state
$socket Delay between connection attempts in seconds
$ssl Port to connect to (default 8729 for ssl)
$timeout Connect using SSL (must enable api-ssl in IP/Services)

Открытые методы

Метод Описание
__destruct ( ) : void Standard destructor
arrayChangeKeyName ( array &$array ) : array Change "-" and "/" from array key to "_"
comm ( string $com, array $arr = [] ) : array Write (send) data to Router OS
connect ( string $ip, string $login, string $password ) : boolean Login to RouterOS
debug ( string $text ) : void Print text for debug purposes
disconnect ( ) : void Disconnect from RouterOS
encodeLength ( string $length ) : void
isIterable ( $var ) * Check, can be var used in foreach
parseResponse ( array $response ) : array Parse response from Router OS
parseResponse4Smarty ( array $response ) : array Parse response from Router OS
read ( boolean $parse = true ) : array Read data from Router OS
write ( string $command, mixed $param2 = true ) : boolean Write (send) data to Router OS

Описание методов

__destruct() публичный Метод

Standard destructor
public __destruct ( ) : void
Результат void

arrayChangeKeyName() публичный Метод

Change "-" and "/" from array key to "_"
public arrayChangeKeyName ( array &$array ) : array
$array array Input array
Результат array Array with changed key names

comm() публичный Метод

Write (send) data to Router OS
public comm ( string $com, array $arr = [] ) : array
$com string A string with the command to send
$arr array An array with arguments or queries
Результат array Array with parsed

connect() публичный Метод

Login to RouterOS
public connect ( string $ip, string $login, string $password ) : boolean
$ip string Hostname (IP or domain) of the RouterOS server
$login string The RouterOS username
$password string The RouterOS password
Результат boolean If we are connected or not

debug() публичный Метод

Print text for debug purposes
public debug ( string $text ) : void
$text string Text to print
Результат void

disconnect() публичный Метод

Disconnect from RouterOS
public disconnect ( ) : void
Результат void

encodeLength() публичный Метод

public encodeLength ( string $length ) : void
$length string
Результат void

isIterable() публичный Метод

* Check, can be var used in foreach
public isIterable ( $var )

parseResponse() публичный Метод

Parse response from Router OS
public parseResponse ( array $response ) : array
$response array Response data
Результат array Array with parsed data

parseResponse4Smarty() публичный Метод

Parse response from Router OS
public parseResponse4Smarty ( array $response ) : array
$response array Response data
Результат array Array with parsed data

read() публичный Метод

Read data from Router OS
public read ( boolean $parse = true ) : array
$parse boolean Parse the data? default: true
Результат array Array with parsed or unparsed data

write() публичный Метод

Write (send) data to Router OS
public write ( string $command, mixed $param2 = true ) : boolean
$command string A string with the command to send
$param2 mixed If we set an integer, the command will send this data as a "tag" If we set it to boolean true, the funcion will send the comand and finish If we set it to boolean false, the funcion will send the comand and wait for next command Default: true
Результат boolean Return false if no command especified

Описание свойств

$attempts публичное свойство

Connection attempt timeout and data read timeout
public $attempts

$connected публичное свойство

Show debug information
public $connected

$debug публичное свойство

public $debug

$delay публичное свойство

Connection attempt count
public $delay

$error_no публичное свойство

Variable for storing socket resource
public $error_no

$error_str публичное свойство

Variable for storing connection error number, if any
public $error_str

$port публичное свойство

Connection state
public $port

$socket публичное свойство

Delay between connection attempts in seconds
public $socket

$ssl публичное свойство

Port to connect to (default 8729 for ssl)
public $ssl

$timeout публичное свойство

Connect using SSL (must enable api-ssl in IP/Services)
public $timeout