I have created a very simple but a very useful PHP Based PPP Secrets Management System.
Currently following features are present in these scripts, more will be added if I get time.
1. Creating New User ( PPP->Secret + MySQL ).
2. Searching User ( this is only from MySQL ).
3. Show a list of all users ( PPP -> Secret ).
4. Delete User ( PPP->Secret + MySQL ).
5. Enable User ( PPP->Secret ).
6. Disable User ( PPP-> Secret ).
7. Change User Password ( PPP->Secret + MySQL), while changing old password is required.
8. Live Monitor Online Users ( PPP->Active Connections ).
9. Show User Stats ( Show Online Users Stats from Queue->Simple ).
10. Monitor Specific Users Stats.
It has a very simple look, which you can edit by creating your own custom CSS.
I have also written an article on how to setup a WebMin based Mikrotik Panel with some of the scripts that provide basic functionality to perform PPP User Management using SSH.
The article is at following URL http://wiki.mikrotik.com/wiki/Useful_Bash_Scripts
I have uploaded a video tutorial on http://www.tiktube.com. It is under the evaluation process, the video is a complete installation guide of the application.
There is a mistake in your guide. The DB name is not matched in the SQL fields.
e.g: “mtpanel” “mtpanle”
Please make a correction.
mysql#create database mtpanel;
mysql#grant all on mtpanel.* to 'mtpanel'@'localhost' identified by 'mtpanel';
mysql#flush privileges;
mysql#use mtpanle;
Also this line is not working.
mysql#\. /var/www/mtpanel/mtpanel.sql;
Workaround was following line.
mysql -u root -p123 --database mtpanel < mtpanel.sql
Yes that is just a spelling mistake, nothing else.
About the SQL import method that I have used. In my video tutorial, I have clearly mentioned that I am using a different method then specified in Wiki Article, because a MySQL library is required for that import method to work “libmysqlclient16” to be specific.
You can just perform “apt-get install libmysqlclient16” and then perform the import method specified in article, it will work.
I tried to create user via this php panel, but it didn’t created the user in MT. When I manually added 128k profile name’128’ in MT profiles, and tried to add the use, it succeed.
So If Package profile is not manually created in Mikrotik, this PHP panel will not add user.
Its better if it automatically create Package in MT, if its not already there.
Also I am getting following error in some I hit few functions like
Anyhow this panel is great and one can have good ideas. Good work and keep it up
Please update your WIKI article and mention these things in it so others may not face un-expected issues.
Something is really weird.
The same function when being executed from Mikrotik CLI is showing proper results, but the same thing when being executed from remote SSH is giving errors.
I am working on this and by tonight I will update and remove errors and will also add the “Adding Profile Feature”.
The function that is being called on “User Stats” menu is
function user_stats()
{
$ssh_command = ':global user
:global fname
:global lname
:global traffic
:global up
:global down
:foreach i in=[/queue simple find] do={
:set user [/queue simple get $i name]
:for m from=([:len $user]) to=0 do={:if ([:pick $user $m] = "-") do={:set fname ([:pick $user ($m+1) [:len $user]])}}
:for n from=([:len $fname]) to=0 do={:if ([:pick $fname $n] = ">") do={:set lname ([:pick $fname 0 $n])}}
:set traffic [/queue simple get $user bytes]
:for x from=([:len $traffic] - 1) to=0 do={:if ([:pick $traffic $x] = "/") do={:set up {[:pick $traffic 0 $x] / 1048576 }}}
:for y from=([:len $traffic]) to=0 do={:if ([:pick $traffic $y] = "/") do={:set down {[:pick $traffic ($y+1) [:len $traffic ]] / 1048576 }}}
:put "$lname\_\_\_\t\t ($down MB - $up MB)"}';
echo "<pre>";
echo "User ID Download - Upload";
echo "<br><br>";
ssh_run($ssh_command);
echo "</pre>";
}
Now when I create a script in mikrotik and run the above mikrotik code, it works and shows queues with upload and download.
But When the code is being executed through the PHP SSH library, it is showing error on 5.X series, but is working fine on 3.X.
A bit confusing as I have tried many times.
This is the first update which includes some bug fixes and a new feature to create PPP Profile.
I have update the code to work with v5.X but now its not working for v3.X. So I will not be updating this code to work for v3.X as that is very old.
Also I have added the Feature to create “Profile”.
The Zip file contains following file.
inc/functions.php
create_profile.php
index.php
create_user.php
profile.sql
Just place these files in respective folders. The SQL file needs to be imported in the database.
mysql -u 'SUPERUSER' -p --database 'DATABASE NAME' < profile.sql
Only the Stats feature is not working for v3.X, all other should work fine.
It would be great if someone can share their findings on this. update-1.zip (5.49 KB)
Adding profile options is working great. Now this panel is going in some Directions
How about adding some security to this php panel for authorized access only?
‘Live monitor specific user’ is not working. its giving the following error.
:global list "";:foreach i in [/ppp active find ] do={:if ([:find [/ppp active get $i name] "999"]=0) do={:set list ($list . "," . $i)}};:foreach i in={$list} do={/interface monitor-traffic $list}
interrupted