Datasheet
API PHP package
53
<input type="password" id="password2" name="password2" value="" />
</li>
<li>
<input type="submit" id="act" name="act" value="Change password" />
</li>
</ul>
</form>
<?php } ?>
</div>
</body>
</html>
"Forgotten password" form for hotspot users
The following script needs to be accessible from a server in a walled garden, i.e. users must not need to be logged in
to access it. You should link to it from the login page.
To prevent arbitrary people from resetting passwords, the script here requires users to provide two pieces of personal
information: Email, and phone. The latter is expected to be the "comment" for a user. If both pieces are correct, the
password is set to a new password the user defines.
This scheme is used for the sake of simplicity. Depending on the rest of your setup (e.g. if you have a public trial
account, or an SMS gateway...), you may have better ways to deal with confirming the user's identity.
<?php
use PEAR2\Net\RouterOS;
require_once 'PEAR2/Autoload.php';
$errors = array();
//Check if the form was submitted. Don't bother with the checks if not.
if (isset($_POST['act'])) {
try {
//Adjust RouterOS IP, username and password accordingly.
$client = new RouterOS\Client('192.168.0.1', 'admin', 'password');
} catch(Exception $e) {
$errors[] = $e->getMessage();
}
if (empty($_POST['email'])) {
$errors[] = 'Email is required.';
}
if (empty($_POST['phone'])) {
$errors[] = 'Phone is required.';
}
if (empty($errors)) {
//Check if this is an imposter or not
$printRequest = new RouterOS\Request('/ip hotspot user print .proplist=.id');










