Thank you boen_robot
MikroTik RouterOS 5.26 username= admin password=
First of all I did not use personal firewall now as show in personal_fw.jpg.
The reason why I use this API client because :
1.It works with debug mode whereas I did not see in PEAR2_Net_RouterOS.
2.There are a lot of documents which I easily find the useful command than PEAR2_Net_RouterOS.
In the first time , I've ever use PEAR2_Net_RouterOS.
I try with your guide (ping test from API PHP package guideline) as shown below.
It display input IP for ping , but it does not work as show in ping_test.jpg
Again I try with Mac finder.php as shown I below. However the result appear on the screen is
"We're sorry, but we can't determine your MAC address right now as shown in Mac_finder.jpg
Please advise;
Thank you
Banatus S
<?php
use PEAR2\Net\RouterOS;
// You may want to include a namespace declaration here
//include_once 'PEAR2_Net_RouterOS-1.0.0b4.phar';
require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar';
if (isset($_GET['act'])) {//This is merely to ensure the form was submitted.
debug=true;
//Adjust RouterOS IP, username and password accordingly.
$client = new RouterOS\Client('192.168.88.98', 'admin',' ');
//This is just one approach that allows you to create a multi purpose form,
//with ping being just one action.
if ($_GET['act'] === 'Ping' && isset($_GET['address'])) {
//Ping can run for unlimited time, but for PHP,
//we need to actually stop it at some point.
$pingRequest = new RouterOS\Request('/ping count=3');
$results = $client->sendSync($pingRequest->setArgument('address', $_GET['address']));
}
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>Ping someone</title>
</head>
<body>
<div>
<form action="" method="get">
<ul>
<li>
<label for="address">Address:</label>
<input type="text" id="address" name="address" value="<?php
if (isset($_GET['address'])) {
echo htmlspecialchars($_GET['address']);
}
?>" />
</li>
<li>
<input type="submit" id="act" name="act" value="Ping" />
</li>
</ul>
</form>
</div>
<?php
if (isset($_GET['act'])) {//There's no need to execute this if the form was not submitted yet.
echo '<div>Results:<ul>';
foreach ($results as $result) {
//Add whatever you want displayed in this section.
echo '<li>Time:', $result->getArgument('time'), '</li>';
}
echo '</ul></div>';
}
?>
</body>
</html>
<?php
**************************************************
use PEAR2\Net\RouterOS;
require_once 'PEAR2_Net_RouterOS-1.0.0b4.phar';
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>Your MAC address</title>
</head>
<body>
<h1>
<?php
try {
//Adjust RouterOS IP, username and password accordingly.
$client = new RouterOS\Client('192.168.88.98', 'admin', '');
$printRequest = new RouterOS\Request('/ip arp print .proplist=mac-address');
$printRequest->setQuery(
RouterOS\Query::where('address', $_SERVER['REMOTE_ADDR'])
);
$mac = $client->sendSync($printRequest)->getArgument('mac-address');
if (null !== $mac) {
echo 'Your MAC address is: ', $mac;
} else {
echo 'Your IP (', $_SERVER['REMOTE_ADDR'],
") is not part of our network, and because of that, we can't determine your MAC address.";
}
} catch(Exception $e) {
echo "We're sorry, but we can't determine your MAC address right now.";
}
?>
</h1>
</body>
</html>
</pre>
You do not have the required permissions to view the files attached to this post.