diff --git a/.gitattributes b/.gitattributes
index 2972084..ad94413 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -6,10 +6,11 @@
.gitignore export-ignore
.scrutinizer.yml export-ignore
.travis.yml export-ignore
-README.md export-ignore
README export-ignore
+README.md export-ignore
CREDITS export-ignore
RELEASE-* export-ignore
+extrasetup.php export-ignore
package.xml export-ignore
packagexmlsetup.php export-ignore
-extrasetup.php export-ignore
+scanoptions.php export-ignore
diff --git a/docs/wiki b/docs/wiki
index fc21ecb..5025c7d 160000
--- a/docs/wiki
+++ b/docs/wiki
@@ -1 +1 @@
-Subproject commit fc21ecb79f6c97f9e97569569bb023284dfd6251
+Subproject commit 5025c7d17faa6025cb3358d2a7794f948f7e4a3d
diff --git a/examples/Util/parseValue.php b/examples/Script/parseValue.php
similarity index 100%
rename from examples/Util/parseValue.php
rename to examples/Script/parseValue.php
diff --git a/examples/Script/prepare.php b/examples/Script/prepare.php
new file mode 100644
index 0000000..f4e296c
--- /dev/null
+++ b/examples/Script/prepare.php
@@ -0,0 +1,19 @@
+setMenu('/system scheduler')->add(
+ array(
+ 'name' => 'logger',
+ 'interval' => '1m',
+ 'on-event' => RouterOS\Script::prepare(
+ '/log info $phpver',
+ array(
+ 'phpver' => phpversion()
+ )
+ )
+ )
+);
diff --git a/examples/Util/edit.php b/examples/Util/edit.php
new file mode 100644
index 0000000..283dd06
--- /dev/null
+++ b/examples/Util/edit.php
@@ -0,0 +1,10 @@
+setMenu('/ip arp');
+$util->edit(0, 'address', '192.168.88.103');
diff --git a/examples/Util/set-multiple.php b/examples/Util/set-multiple.php
index 1453d23..52ef940 100644
--- a/examples/Util/set-multiple.php
+++ b/examples/Util/set-multiple.php
@@ -9,6 +9,7 @@
$util->setMenu('/ip arp');
$util->set(
$util->find(
+ 0,
function ($response) {
//Matches any item with a comment that starts with two digits
return preg_match('/^\d\d/', $response->getArgument('comment'));
diff --git a/extrasetup.php b/extrasetup.php
index cae9013..1c8f7bd 100644
--- a/extrasetup.php
+++ b/extrasetup.php
@@ -18,6 +18,7 @@
'pear2.php.net' => array(
'PEAR2_Autoload',
'PEAR2_Cache_SHM',
+ 'PEAR2_Net_Transmitter',
'PEAR2_Console_CommandLine',
'PEAR2_Console_Color'
)
@@ -33,7 +34,6 @@
foreach ($channelPackages as $package) {
foreach ($registry->toPackage($package, $channel)->installcontents
as $file => $info) {
- var_dump($package, $file);
if (strpos($file, 'php/') === 0 || strpos($file, 'src/') === 0) {
$filename = substr($file, 4);
$extrafiles['src/' . $filename]
diff --git a/package.xml b/package.xml
index 0e63f2e..d6b3451 100644
--- a/package.xml
+++ b/package.xml
@@ -11,8 +11,8 @@
boen.robot@gmail.comyes
- 2016-11-07
-
+ 2017-05-22
+
1.0.0b61.0.0
@@ -37,6 +37,8 @@
- newRequest()
* Script::escapeString() no longer escapes bytes above 0x7F. This means that parameter string values are now influenced by charset settings, and thus no additional conversion is necessary. A new second argument can be set to TRUE to escape all bytes, including the previously untouched ASCII alphanumeric characters and underscores.
* Stream parameters in Script::append() (and inherently, Script::prepare() and Util::exec()) now have ALL bytes escaped.
+* Script::escapeValue() converts NULL to "nil" instead of "nothing".
+* The $params array in Script::append() can declare variables with a value of type "nothing" by using numeric keys, and the variable names as values.
* Script::parseValue() now supports letter notation for time (1h2m3s), not just double colon notation (01:02:03), modeled after RouterOS. Related to that is also that leading zeroes, and zero minutes and seconds are now optional (e.g. "1:" is a valid way of saying 1 hour). Sub-second information is rounded up to the nearest second on current PHP versions (future versions are expected to support sub-second information in DateInterval by allowing seconds to be a double; The code currently attempts to give DateInterval a double, falling back to rounding to a second).
* Script::parseValue() now recognizes dates in the "M/d/Y H:i:s" format (used across RouterOS), and turns that into a DateTime object for that time (or midnight in UTC if the time part is omitted).
* Util::getAll() now throws a NotSupportedException if the arguments "follow", "follow-only" or "count-only" are used. The first two, because PHP would hang (since Client::sendSync() is used under the hood), and the last one because it's unredable in the returned output (use Util::count() instead).
@@ -58,6 +60,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -79,9 +96,14 @@
+
+
+
+
+
@@ -94,7 +116,6 @@
-
@@ -381,7 +402,7 @@
PEAR2_Console_CommandLinepear2.php.net
- 0.2.1
+ 0.2.2PEAR2_Console_Color
@@ -400,14 +421,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -420,7 +457,6 @@
-
diff --git a/packagexmlsetup.php b/packagexmlsetup.php
index 14ec21c..1320298 100644
--- a/packagexmlsetup.php
+++ b/packagexmlsetup.php
@@ -104,6 +104,8 @@
$oldCwd = getcwd();
chdir(__DIR__);
+ $package->setRawRelease('php', '');
+ $release = $package->getReleaseToInstall('php');
foreach (new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(
'.',
@@ -112,8 +114,12 @@
),
RecursiveIteratorIterator::LEAVES_ONLY
) as $path) {
- $filename = substr($path->getPathname(), 2);
- $cFilename = str_replace('src/', 'php/', $filename);
+ if ('.git' === $path->getFilename()) {
+ continue;
+ }
+
+ $filename = substr($path->getPathname(), 2);
+ $cFilename = str_replace('src/', 'php/', $filename);
if (isset($package->files[$filename])) {
$parsedFilename = pathinfo($filename);
@@ -135,7 +141,7 @@
$as = substr($as, 0, -4);
}
}
- $package->getReleaseToInstall('php')->installAs($filename, $as);
+ $release->installAs($filename, $as);
$contents = file_get_contents($filename);
foreach ($config['replace'] as $from => $attribs) {
diff --git a/scanoptions.php b/scanoptions.php
new file mode 100644
index 0000000..77998e6
--- /dev/null
+++ b/scanoptions.php
@@ -0,0 +1,36 @@
+
+ * @copyright 2011 Vasil Rangelov
+ * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
+ * @version GIT: $Id$
+ * @link http://pear2.php.net/PEAR2_Net_RouterOS
+ */
+
+$scanoptions = array(
+ 'ignore' => array()
+);
+$oldCwd = getcwd();
+chdir(__DIR__);
+foreach (new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator(
+ '.',
+ RecursiveDirectoryIterator::UNIX_PATHS
+ | RecursiveDirectoryIterator::SKIP_DOTS
+ ),
+ RecursiveIteratorIterator::LEAVES_ONLY
+) as $path) {
+ if ('.git' === $path->getFilename()) {
+ $scanoptions['ignore'][$path->getRealPath()]
+ = $path->isDir() ? 'dir' : 'file';
+ }
+}
+chdir($oldCwd);
+return $scanoptions;
diff --git a/scripts/roscon.php b/scripts/roscon.php
index ff71cc4..52fde39 100644
--- a/scripts/roscon.php
+++ b/scripts/roscon.php
@@ -73,55 +73,83 @@
$cwd = getcwd();
chdir(__DIR__);
- //The composer autoloader from this package.
- //Also matched if the bin-dir is changed to a folder that is directly
- //descended from the composer project root.
- $autoloader = stream_resolve_include_path('../vendor/autoload.php');
- if (false !== $autoloader) {
- include_once $autoloader;
- } else {
- //The composer autoloader, when this package is a dependency.
- $autoloader = stream_resolve_include_path(
- (false === ($vendorDir = getenv('COMPOSER_VENDOR_DIR'))
- ? '../../..'
- : $vendorDir) . '/autoload.php'
- );
+ $composerAutoloaderPaths = array();
+ $vendorDir = getenv('COMPOSER_VENDOR_DIR');
+ if (false !== $vendorDir) {
+ $composerAutoloaderPaths[] = $vendorDir . '/autoload.php';
unset($vendorDir);
+ }
+ $composerAutoloaderPaths[] = '../vendor/autoload.php';
+ $composerAutoloaderPaths[] = '../../../autoload.php';
+ foreach ($composerAutoloaderPaths as $autoloaderPath) {
+ $autoloader = stream_resolve_include_path($autoloaderPath);
+ if (false !== $autoloader) {
+ include_once $autoloader;
+ if (class_exists('PEAR2\Net\RouterOS\Communicator', true)) {
+ break;
+ }
+ $autoloader = false;
+ }
+ }
+ unset($autoloaderPath, $composerAutoloaderPaths);
+ if (false === $autoloader) {
+ //PEAR2_Autoload, most probably installed globally.
+ $autoloader = stream_resolve_include_path('PEAR2/Autoload.php');
if (false !== $autoloader) {
include_once $autoloader;
+ Autoload::initialize(
+ realpath('../src')
+ );
+ Autoload::initialize(
+ realpath('../../Net_Transmitter.git/src')
+ );
+ Autoload::initialize(
+ realpath('../../Console_Color.git/src')
+ );
+ Autoload::initialize(
+ realpath('../../Console_CommandLine.git/src')
+ );
} else {
- //PEAR2_Autoload, most probably installed globally.
- $autoloader = stream_resolve_include_path('PEAR2/Autoload.php');
- if (false !== $autoloader) {
- include_once $autoloader;
- Autoload::initialize(
- realpath('../src')
- );
- Autoload::initialize(
- realpath('../../Net_Transmitter.git/src')
- );
- Autoload::initialize(
- realpath('../../Console_Color.git/src')
- );
- Autoload::initialize(
- realpath('../../Console_CommandLine.git/src')
- );
- } else {
- fwrite(
- STDERR,
- <<getMessage() . "\n"
+ "Error when parsing command line: {$e->getMessage()}\n"
);
$cmdParser->displayUsage(13);
}
@@ -255,6 +303,7 @@
<<getCode() === RouterOS\SocketException::CODE_CONNECTION_FAIL
) {
+ $phpBin = defined('PHP_BINARY')
+ ? PHP_BINARY
+ : (PHP_BINDIR . DIRECTORY_SEPARATOR .
+ (PHP_SAPI === 'cli' ? 'php' : 'php-cgi') .
+ (stristr(PHP_OS, 'win') === false ? '' : '.exe'));
fwrite(
STDERR,
<<setAttribute($prefix, $value);
- continue;
- }
- if ('.' === $ind && 'tag' === $prefix) {
- $this->setTag(stream_get_contents($word, -1, -1));
- continue;
+ rewind($word);
+ $ind = fread($word, 1);
+ if ('=' === $ind || '.' === $ind) {
+ $prefix = stream_get_line($word, null, '=');
+ }
+ if ('=' === $ind) {
+ $value = fopen('php://temp', 'r+b');
+ $bytesCopied = ftell($word);
+ while (!feof($word)) {
+ $bytesCopied += stream_copy_to_stream(
+ $word,
+ $value,
+ 0xFFFFF,
+ $bytesCopied
+ );
}
- rewind($word);
- $this->unrecognizedWords[] = $word;
+ rewind($value);
+ $this->setAttribute($prefix, $value);
+ continue;
+ }
+ if ('.' === $ind && 'tag' === $prefix) {
+ $this->setTag(stream_get_contents($word, -1, -1));
+ continue;
+ }
+ rewind($word);
+ $this->unrecognizedWords[] = $word;
}
} else {
for ($word = $com->getNextWord(); '' !== $word;
diff --git a/src/PEAR2/Net/RouterOS/Util.php b/src/PEAR2/Net/RouterOS/Util.php
index 3d81157..b1e1712 100644
--- a/src/PEAR2/Net/RouterOS/Util.php
+++ b/src/PEAR2/Net/RouterOS/Util.php
@@ -522,7 +522,7 @@ public function find()
* there are no items (e.g. "/system identity"), you can specify NULL.
* You can also specify a {@link Query}, in which case the first match
* will be considered the target item.
- * @param string|null $valueName The name of the value to get.
+ * @param string|resource|null $valueName The name of the value to get.
* If omitted, or set to NULL, gets all properties of the target item.
*
* @return string|resource|null|array The value of the specified
@@ -730,7 +730,10 @@ public function comment($numbers, $comment)
* index as the array key, and the name of the flag as the array value.
*
* @return ResponseCollection Returns the response collection, allowing you
- * to inspect errors, if any.
+ * to inspect the output. Current RouterOS versions don't return
+ * anything useful, but if future ones do, you can read it right away.
+ *
+ * @throws RouterErrorException When the router returns one or more errors.
*/
public function set($numbers, array $newValues)
{
@@ -768,7 +771,10 @@ public function set($numbers, array $newValues)
* If set to NULL, the property is unset.
*
* @return ResponseCollection Returns the response collection, allowing you
- * to inspect errors, if any.
+ * to inspect the output. Current RouterOS versions don't return
+ * anything useful, but if future ones do, you can read it right away.
+ *
+ * @throws RouterErrorException When the router returns one or more errors.
*/
public function edit($numbers, $valueName, $newValue)
{
@@ -789,7 +795,10 @@ public function edit($numbers, $valueName, $newValue)
* @param string $valueName The name of the value you want to unset.
*
* @return ResponseCollection Returns the response collection, allowing you
- * to inspect errors, if any.
+ * to inspect the output. Current RouterOS versions don't return
+ * anything useful, but if future ones do, you can read it right away.
+ *
+ * @throws RouterErrorException When the router returns one or more errors.
*/
public function unsetValue($numbers, $valueName)
{
@@ -887,7 +896,10 @@ public function add(array $values)
* will be moved to the bottom of the menu.
*
* @return ResponseCollection Returns the response collection, allowing you
- * to inspect errors, if any.
+ * to inspect the output. Current RouterOS versions don't return
+ * anything useful, but if future ones do, you can read it right away.
+ *
+ * @throws RouterErrorException When the router returns one or more errors.
*/
public function move($numbers, $destination = null)
{