Datasheet

API PHP package
51
</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>
"Change password" form for hotspot users
The script assumes you have already made a hotspot and do NOT make this file accessible in a walled garden, i.e.
users must be logged in to access it. For convenience's sake, you may want to link to it from the status page.
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
$errors = array();
try {
//Adjust RouterOS IP, username and password accordingly.
$client = new RouterOS\Client('192.168.0.1', 'admin', 'password');
$printRequest = new RouterOS\Request(
'/ip hotspot active print',
RouterOS\Query::where('address', $_SERVER['REMOTE_ADDR'])
);
$hotspotUsername = $client->sendSync($printRequest)->getArgument('user');
} catch(Exception $e) {
$errors[] = $e->getMessage();
}
if (isset($_POST['password']) && isset($_POST['password2'])) {
if ($_POST['password'] !== $_POST['password2']) {
$errors[] = 'Passwords do not match.';
} elseif (empty($errors)) {