You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
854 B
44 lines
854 B
<?php
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
use \RouterOS\Client;
|
|
|
|
// Initiate client with config object
|
|
$client = new Client([
|
|
'timeout' => 1,
|
|
'host' => '127.0.0.1',
|
|
'user' => 'admin',
|
|
'pass' => 'admin'
|
|
]);
|
|
|
|
// Send query to RouterOS and parse response
|
|
$response = $client->query('/ip/firewall/address-list/print')->read();
|
|
|
|
// You could treat response as an array except using array_* function
|
|
|
|
// Export every row using foreach
|
|
foreach ($response as $row) {
|
|
echo current($row) . PHP_EOL;
|
|
}
|
|
|
|
$item = current($response);
|
|
var_dump($item);
|
|
echo PHP_EOL;
|
|
|
|
$item = end($response);
|
|
var_dump($item);
|
|
echo PHP_EOL;
|
|
|
|
$item = current($response);
|
|
var_dump($item);
|
|
echo PHP_EOL;
|
|
|
|
$item = reset($response);
|
|
var_dump($item);
|
|
echo PHP_EOL;
|
|
|
|
$item = current($response);
|
|
var_dump($item);
|
|
echo PHP_EOL;
|