
RouterOS PHP class
160
RouterOS PHP class
•• Author: Kamil Trzcinski
•• E-mail: ayufan(at)osk-net(dot)pl
• WWW: [1]
•• License: GPL
•• added callbacks
•• added btest
•• initial release
The main purpose of another RouterOS PHP API class it to simplify configuration update processes. Example: We
have about 20 access points and for each of them we have connected about 20 wds links. Using automatic
configuration process we can store information about all wds links in one place. It can be MySQL database.
Using set of configuration files router's can be divided into function groups (ie. router, main-access-point,
client-access-point, switch) and be configured from central server automatically. ONLY changed configuration will
be updated, so in most cases no configuration will change.
Requires a very good knowledge of RouterOS configuration tree, PHP Runtime and API access to RouterOS.
Base class for handing RouterOS API interface. It implements methods of getting and setting values as well
restarting router.
All commands accepts two forms of arguments. Either using string or using array. Prefered way is to use array.
From version 0.2 interface supports many simulatenous commands using user callbacks. Every function with
$callback parameter support asynchronous operation. If valid $callback would be passed function returns instead of
results assigned ".tag" value to callback or FALSE on failure.
function myCallbackFunction($conn, $state, $results);
• conn - RouterOS object
• state - indicate callback boolean state. TRUE the response is either "!done" or "!re". FALSE the response is
"!trap"
• results - contains additional arguments for response. If NULL callback got "!done" status otherwise contains
associative array of results from API server.
To specify command (in RouterOS configuration tree) use:
•• slash delimeted string:
/ip/firewall/string
•• array of string:
array("ip", "firewall", "string")
To specify configuration line (for command) use:
•• space delimeted string:
chain=forward action=drop in-interface=ether1
•• associative array of string:
array("chain"=>"forward", "action"=>"drop", "in-interface"=>"ether1")
•• public $readOnly = FALSE;
Read-only flag. If set to TRUE: RouterOS class will not change nor remove any item.
Comentários a estes Manuais