Hello everyone!
Do I need to dowload a aquivo and run an import that file all this via php api eg
/ tool fetch url = "192.168.1.1/script.rsc"
/ import file-name = script.rsc
I'll be very grateful if someone can help me
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b3.phar';
$client = new Client('192.168.0.1', 'admin', 'password');
$client(new Request('/tool fetch url="192.168.1.1/script.rsc"'));
$client(new Request('/import file-name=script.rsc'));
<?php require_once("$DOCUMENT_ROOT/lib/PEAR2_Net_RouterOS-1.0.0b3.phar");
use PEAR2\Net\RouterOS;?>
<?php
use PEAR2\Net\RouterOS;
require_once("$DOCUMENT_ROOT/lib/PEAR2_Net_RouterOS-1.0.0b3.phar");
?>
<? Phpuse PEAR2 \ Net \ RouterOS;
require_once ("$ DOCUMENT_ROOT/lib/PEAR2_Net_RouterOS-1.0.0b3.phar");?>
<?php phpinfo(); ?>
<?php
use PEAR2\Net\RouterOS;
require_once '/home/username/public_html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar';
echo 'OK so far.';
?>
<?php
use PEAR2\Net\RouterOS;
require_once '/home/bakanas/sistema/web/html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar';
echo 'Test OK';
?>
<?php
$phar = '/home/bakanas/sistema/web/html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar';
if (is_file($phar)) {
if (is_readable($phar)) {
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
echo 'WTF? All requirements are OK...';
} else {
echo 'Path to PHAR file is correct and readable, but PHP version is earlier than 5.3.0. Maybe your earlier phpinfo() run was from a different SAPI.';
}
} else {
echo 'Path to PHAR file is correct, but unreadable by PHP.';
}
} else {
echo 'Wrong path to PHAR file.';
}
<?php
use PEAR2\Net\RouterOS;
require_once '/home/username/public_html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar';
echo 'OK so far.';
?>
<?php
require_once '/home/username/public_html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar';
echo 'Inclusion OK.';
try {
$client = new \PEAR2\Net\RouterOS\Client('192.168.0.1', 'admin', 'password');
echo 'Connection OK';
} catch (Exception $e) {
echo 'Connection FAIL.';
}
Fatal error: Uncaught exception 'PharException' with message 'manifest cannot be larger than 100 MB in phar "/home/bakanas/sistema/web/html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar"' in /home/bakanas/sistema/web/html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar:3 Stack trace: #0 /home/bakanas/sistema/web/html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar(3): Phar::mapPhar() #1 /home/bakanas/sistema/web/html/teste_pear.php(8): require_once('/home/bakanas/s...') #2 {main} thrown in /home/bakanas/sistema/web/html/lib/PEAR2_Net_RouterOS-1.0.0b3.phar on line 3
//fetch configuration file from server
$API->write('/tool/fetch', false);
$API->write('=address=address', false);
$API->write('=src-path='.$_SESSION['load_ConfigFile'].'', false);
$API->write('=user=marijn', false);
$API->write('=mode=https', false);
$API->write('=password=password', false);
$API->write('=dst-path=config.rsc', false);
$API->write('=port=443', false);
$API->write('=keep-result=yes');
// import and execute configuration file
$API->write('/import', false);
$API->write('=file-name=config.rsc');
sleep(2);
I am having the exact same issue, any ideas?man can you helpme?
in this case:
$client = new Client('xx.xx.xx.xx', 'admin', '1234');
$client(new Request('/tool fetch url="xx.xx.xx.xx/nt2/x.rsc"'));
$client(new Request('/import file-name=x.rsc'));
I have:
Fatal error: Uncaught Exception: Class Client could not be loaded from Client.php, file does not exist (registered paths="/var/www/html/nt2") [PEAR2_Autoload-@PACKAGE_VERSION@] in /var/www/html/nt2/PEAR2/Autoload.php:305 Stack trace: #0 [internal function]: PEAR2\Autoload::load('Client') #1 /var/www/html/nt2/teste2.php(10): spl_autoload_call('Client') #2 {main} thrown in /var/www/html/nt2/PEAR2/Autoload.php on line 305
There ara solution for this please?
tks a lot.