
RouterOS PHP class
172
Add or set config for specified short command.
$parser->config("firewall-filter", "action=drop chain=forward");
$parser->config("firewall-filter", array("action"=>"drop", "chain"=>"forward"));
$parser->config("connection-tracking", "enabled=no");
•• function ignore($cmd, $line)
Ignore specified item from synchronization. Has precedence before "pass". Muliple ignore or pass rules can be
added.
$parser->ignore("firewall-filter", "chain=forward"); // doesn't synchronize rules from chain "forward"
•• function pass($cmd, $line)
Pass only specified item to synchronization. Muliple ignore or pass rules can be added.
$parser->pass("firewall-filter", "chain=forward"); // synchronize ONLY rules from chain "forward"
•• function section($alias, $cmd, $type, $keys = FALSE, $defaults = FALSE)
Add a section to synchronization.
alias - short alias of section
cmd - RouterOS command
type - type of section. See Types of section.
keys - list of keys to perform differencing synchronization.
defaults - list of default values.
$parser->section("firewall-filter", "/ip/firewall/filter", "addset_order", FALSE, "disabled=no");
// ordered list of items without <b>key</b> and default not disabled
$parser->section("wireless-wds", "/interface/wireless/wds", "addset", "name", "disabled=no");
// unordered list of items with interface name as key and default not disabled
$parser->section("interface-queue", "/queue/interface", "set", "name");
// only settable list of items with interface name as key
$parser->section("dns", "/ip/dns", "value");
// value section
•• function cmd($alias, $cmd)
Defines user php function with at least one arg: $parser.
function parser_test_function($parser, $srcaddress, $dstaddress) {
$parser->config("firewall-filter", "chain=forward action=drop src-address=$srcaddress dst-address=$dstaddress");
return TRUE;
}
$parser->cmd("test_function", parser_test_function);
•• function parseFile($file)
Parse text from file. If $file is array parse line of array as command.
$parser->parseFile("my_config_file.cfg");
Komentáře k této Příručce