Click to get the latest Buzzing content. Take A Sneak Peak At The Movies Coming Out This Week (8/12) #BanPaparazzi – Hollywood.com will not post paparazzi photos.
Note: This is just one of three PHP API clients. Check out also the API clients by Kamil Trzcinski and Denis Basta
- 2.4'Change password' form for hotspot users
The examples on this page use the PEAR2_Net_RouterOS package. You can install it with Pyrus, PEAR, Composer or just download the '.phar' file and include it from your PHP file.
Note:Despite the name, PEAR(2) itself is NOT required.
Note: The client requires PHP 5.3.0 or later.
Note: The client should, in theory, work without any problems for large replies and commands, as well as any and all RouterBOARD devices, but has not been extensively tested with such. Please report any such experiences (positive or negative ones) at the forums.
Tutorials for this client are available in its GitHub Wiki, including reference docs, which, if you have a smart PHP IDE like NetBeans, PhpStorm or similar, you can also view alongside its auto-complete suggestions.
Credits and legal stuff
Author: Vasil Rangelov, a.k.a. boen_robot (boen [dot] robot [at] gmail [dot] com)
License: LGPL 2.1
(Summary: Use the library as you like, no requirements or restrictions; If you modify the library and publish an application using that library, also publish the modified library itself with the original credits preserved and under the same license)
All examples assume that you used Pyrus or PEAR for installation and have installed PEAR2_Autoload. Also, the router is assumed to be accessible with a local IP to the device PHP runs from. The client itself could work without these restrictions - they are specified here for clarity and consistency.
Mikrotik License Key Generator Download Mac
Note: You should be able to replace 'PEAR2/Autoload.php' with the path to the '.phar' file, and have everything 'just work'.
Print router logs (as plain text)
The following example shows the router's log as plain text (one log entry per line). You should make sure this is not publicly visible, as it may give potential attackers useful info (especially the parts about a username having logged in by a particular protocol).
Print router logs (as HTML table)
Mikrotik License Key Generator Download Free
Same as the previous example, but as an HTML table instead, with the different topics being highlighted in different dotted 'boxes'.
Ping from router
This example is particularly useful when you want to ping someone from inside the network while browsing the page from outside the network.
'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, and make sure the web server's lease is static.
Warning: As clarified earlier on this page, the web server needs to be within the local network of the hotspot. In this case, this is required to distinguish hotspot users, which would otherwise be accessing the page with the same IP.
Warning: The web server too must be logged into the hotspot, in order to be able to access the router. You can create an IP binding for the web server that is of type 'bypassed', in order to avoid having it log in. See hotspot's manual page for details on how to create a binding.
Bonus: 'Change password' regardless of web server location
The above approach for determining the currently logged in user requires for the web server to be inside the local hotspot network. In addition to being inconvenient (in that you may not want to keep your web server in your network), the approach can also be somewhat error prone, in that users could access the web server without being logged in, at which point they'd see the same error message as if the router was unavailable, except that it is, it's just that it can't determine their username.. Oh, and the IP binding requirement is a little annoying too.
The approach below detects the hotspot user's cookie, taking the username from it. If the server (or this PHP file at least) is not in a walled garden and outside the hotspot network, users won't be able to access it without being logged in, ensuring a successful match.
The setup at the router here is the most important bit:
- Make sure the hotspot is available from a domain, even if it's one only the router itself knows, e.g. 'router.local'.
- Add a DNS entry for the web server that is in a subdomain of the hotspot's domain, e.g. 'panel.router.local'.
- Make sure the web server can actually respond to this domain. With IIS for example, a separate setting is required. With Apache, if you're using ANY virtual hosts, you'll need to explicitly add this one too.
- Place the PHP file so that the 'path' component of the URL starts with '/login'. This could be a dedicated folder at the web server root called 'login', or even just prefixing the name of the file, e.g. 'loginChangePassword.php'. This last part is required, because the cookies that hotspot sets have 'path=/login' in them, meaning the browser will only give the cookie if the path starts with '/login'.
To actually do the matching against a cookie, replace
You'll notice the ID is available in a cookie called 'loginID'. The cookie's value is in decimal, and RouterOS internally stores the ID in hex, with '*' to indicate type 'id', which is why we do the conversion (and we use base_convert instead of dechex, because the ID can be up to 64 bits, not just 32 - dechex's limit).
'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.
Random Wi-Fi password generator
The following script is meant to be ran at a scheduled interval, generating a new Wi-Fi password each time it's ran.
The Wi-Fi password is set at the 'default' security profile, which is predefined on RouterBOARD devices with Wi-Fi adapters. Adjust accordingly if not using that profile.
Note that the provided alphabet below intentionally omits potentially ambiguous characters, such as '0' and 'o'.
Tired of asking your customers to tell you their MAC address (and go over the same 'click here and..' instructions over and over again)? Well, using the following script, you can now.. switch the insructions to 'go to this web page.. by clicking here and..':
- MUM BG 2014 presentation (Video in Bulgarian; Slides in English and Bulgarian)