
RouterOS PHP class
169
$lines = array();
foreach($dests as $dest=>$desc) {
$lines[] = array("host"=>$desc["dest"], "speed"=>$desc["speed"], "proto"=>$desc["protocol"],
"status"=>$status[$dest], "current"=>$current[$dest], "average"=>$average[$dest], "%"=>$percent[$dest]);
}
ncurses_addstr(printTable($header, $lines));
ncurses_refresh();
}
?>
Parser class to load configuration from file and perform differencing configuration update.
Parser output should be shown in text/plain content-type!
Order of sections defines order of configuration updates.
• For each section: getall items from RouterOS
•• ignore all dynamic entries, remove all invalid entries
•• try to classify RouterOS item to either ignore or to pass list
• try to match RouterOS item with local item using defined keys, if no match found remove, if match found update
only what changed
•• reorder RouterOS item list
•• add not found items to RouterOS
One line is one command. Command can be either: comment, flow function, include function, user function definer
or configurer function. Each line is firstly trimmed from whitespaces.
Comment can only by started from new line and after # char. Before # can be zero or more whitespaces. Comment
can't be added after command!
# Sample comment
To use variable add % before and after variable name: To get value of my-variable:
%my-variable%
To define variable in script use var keyword
var [variable-name] [variable-value]
var my-variable test-variable
var my-variable test-variable-using-previous-value-of-my-variable-%my-variable%
In script files there are a few flow functions: if, elseif, else, endif. Flow functions can be nested. One flow block
if-else-endif has to be located in ONE file. So simply You can't start flow block in one file and end it in another.
if [left-value] [operator] [right-value]
# [commands execute when first comparision is true] ...
elseif [left-value] [operator] [right-value]
# [commands execute when second comparision is true] ...
else
# [commands execute when neither first nor second comparision is true] ...
endif
Komentarze do niniejszej Instrukcji