PEAR2_Net_RouterOS
1.0.0b6
A MikroTik RouterOS client
|
Static Public Member Functions | |
static | parseValue ($value, DateTimeZone $timezone=null) |
Parses a value from a RouterOS scripting context. More... | |
static | parseValueToString ($value) |
Parses a RouterOS value into a PHP string. More... | |
static | parseValueToSimple ($value) |
Parses a RouterOS value into a PHP simple type. More... | |
static | parseValueToDateTime ( $value, DateTimeZone $timezone=null) |
Parses a RouterOS value into a PHP DateTime object. More... | |
static | parseValueToDateInterval ($value) |
Parses a RouterOS value into a PHP DateInterval. More... | |
static | parseValueToArray ( $value, DateTimeZone $timezone=null) |
Parses a RouterOS value into a PHP array. More... | |
static | prepare ( $source, array $params=array()) |
Prepares a script. More... | |
static | append ( $stream, $source, array $params=array()) |
Appends a script. More... | |
static | escapeValue ($value) |
Escapes a value for a RouterOS scripting context. More... | |
static | escapeString ($value, $full=false) |
Escapes a string for a RouterOS scripting context. More... | |
Definition at line 62 of file Script.php.
|
static |
Appends a script.
Appends a script to an existing stream.
resource | $stream | An existing stream to write the resulting script to. |
string | resource | $source | The source of the script, as a string or stream. If a stream is provided, reading starts from the current position to the end of the stream, and the pointer stays at the end after reading is done. |
array<string|int,mixed> | $params An array of parameters to make available in the script as local variables. Variable names are array keys, and variable values are array values. Array values are automatically processed with static::escapeValue(). Streams are also supported, and are processed in chunks, each with static::escapeString() with all bytes being escaped. Processing starts from the current position to the end of the stream, and the stream's pointer is left untouched after the reading is done. Variables with a value of type "nothing" can be declared with a numeric array key and the variable name as the array value (that is casted to a string). |
Definition at line 476 of file Script.php.
|
static |
Escapes a string for a RouterOS scripting context.
Escapes a string for a RouterOS scripting context. The value can then be surrounded with quotes at a RouterOS script (or concatenated onto a larger string first), and you can be sure there won't be any code injections coming from it.
By default, for the sake of brevity of the output, ASCII alphanumeric characters and underscores are left untouched. And for the sake of character conversion, bytes above 0x7F are also left untouched.
string | $value | Value to be escaped. |
bool | $full | Whether to escape all bytes in the string, including ASCII alphanumeric characters, underscores and bytes above 0x7F. |
Definition at line 605 of file Script.php.
|
static |
Escapes a value for a RouterOS scripting context.
Turns any native PHP value into an equivalent whole value that can be inserted as part of a RouterOS script.
DateInterval objects will be casted to RouterOS' "time" type.
DateTime objects will be casted to a string following the "M/d/Y H:i:s" format. If the time is exactly midnight (including microseconds), and the timezone is UTC, the string will include only the "M/d/Y" date.
Unrecognized types (i.e. resources and other objects) are casted to strings, and those strings are then escaped.
mixed | $value | The value to be escaped. |
Definition at line 531 of file Script.php.
|
static |
Parses a value from a RouterOS scripting context.
Turns a value from RouterOS into an equivalent PHP value, based on determining the type in the same way RouterOS would determine it for a literal.
This method is intended to be the very opposite of static::escapeValue(). That is, results from that method, if given to this method, should produce equivalent results.
string | $value | The value to be parsed. Must be a literal of a value, e.g. what static::escapeValue() will give you. |
DateTimeZone | null | $timezone | The timezone which any resulting DateTime object (either the main value, or values within an array) will use. Defaults to UTC. |
Definition at line 95 of file Script.php.
|
static |
Parses a RouterOS value into a PHP array.
Parses a RouterOS value into a PHP array.
string | $value | The value to be parsed. Must be a literal of a value, e.g. what static::escapeValue() will give you. |
DateTimeZone | null | $timezone | The timezone which any resulting DateTime object within the array will use. Defaults to UTC. |
ParserException | When the value is not of a recognized type. |
Definition at line 347 of file Script.php.
|
static |
Parses a RouterOS value into a PHP DateInterval.
Parses a RouterOS value into a PHP DateInterval.
string | $value | The value to be parsed. Must be a literal of a value, e.g. what static::escapeValue() will give you. |
ParserException | When the value is not of a recognized type. |
Definition at line 248 of file Script.php.
|
static |
Parses a RouterOS value into a PHP DateTime object.
Parses a RouterOS value into a PHP DateTime object.
string | $value | The value to be parsed. Must be a literal of a value, e.g. what static::escapeValue() will give you. |
DateTimeZone | null | $timezone | The timezone which the resulting DateTime object will use. Defaults to UTC. |
ParserException | When the value is not of a recognized type. |
Definition at line 192 of file Script.php.
|
static |
Parses a RouterOS value into a PHP simple type.
Parses a RouterOS value into a PHP simple type. "Simple" types being scalar types, plus NULL.
string | $value | The value to be parsed. Must be a literal of a value, e.g. what static::escapeValue() will give you. |
Definition at line 155 of file Script.php.
|
static |
Parses a RouterOS value into a PHP string.
string | $value | The value to be parsed. Must be a literal of a value, e.g. what static::escapeValue() will give you. |
Definition at line 127 of file Script.php.
|
static |
Prepares a script.
Prepares a script for eventual execution by prepending parameters as variables to it.
This is particularly useful when you're creating scripts that you don't want to execute right now (as with Util::exec(), but instead you want to store it for later execution, perhaps by supplying it to "/system scheduler".
string | resource | $source | The source of the script, as a string or stream. If a stream is provided, reading starts from the current position to the end of the stream, and the pointer stays at the end after reading is done. |
array<string|int,mixed> | $params An array of parameters to make available in the script as local variables. Variable names are array keys, and variable values are array values. Array values are automatically processed with static::escapeValue(). Streams are also supported, and are processed in chunks, each with static::escapeString() with all bytes being escaped. Processing starts from the current position to the end of the stream, and the stream's pointer is left untouched after the reading is done. Variables with a value of type "nothing" can be declared with a numeric array key and the variable name as the array value (that is casted to a string). |
Definition at line 438 of file Script.php.