[SOLVED] PHP API to disconnect a user

this is my idea
I have my hotspot if my users have their username and password then they can access to my wifi ok :open_mouth:
my hostpot is in HTML and use md5 in order to logged in…
when somebody hires me my internet service I register them with php on my database with this I register how many days they want the service,

when somebody logged in if I can send the username and password to my page in my server then
I can know how many days somebody payed for the service and when their hires finish,
that’s way I need to know when my users logged in hotspot…
(all of this I already did it with php and works perfectly my problem is how can integrate php to mikrotik and send my username and password)
for that I try to catch this information after they logged in just in the page redirect.html from mikrotik and send them to my external page in php in order to do everything that I want in my database

or how can I do it?, just the last way that you told me, didn’t you?
but if I try to integrate php to my hotspot how can I work? if mikrotik doesn’t integrate php that’s way I think that I have to send my variables with ajax or something like that… I wanna kill myself :open_mouth:

YES!!! That’s the way!

You can’t. You can’t install PHP, or anything else for that matter, on RouterOS.

“/tool fetch” is exactly that “something like ajax” thing AND it doesn’t leave any traces on the user’s machine, which is what makes it so perfect - it’s not the user telling your server “Hey, I just logged in!”; It’s the router telling you server “Hey, one of my users called X just logged in!”.

You need to maintain an always on DB server anyway, with or without MikroTik supporting PHP internally, so I don’t see why this makes such a huge deal.

Ok, thanks for everything and your advices
I need to prove and after that I show you if I could do it, I am new with mikrotik maybe and sometimes I can understand so well thanks anyway

hi can you help me with this
I need to access to my mk from web, this is my problem I am working with api class with php
when I try to connect whit mk and I am in the same range the comunication is possible and work fine
whit this

if ($API->connect(“192.xx.xx.xx”, “user”, “pass”))

but now I have my server online and with the same line I can’t to access to mikrotik how can I do it?

Simply replace “192.xx.xx.xx” with your router’s public IP.

… and make sure that external API connections are allowed in Firewall Filter

Im not sure to understand you, you want to say that I have to add a rule inside Mk’s firellaw, don’t you?

Not necessarily. You must NOT have a rule that denies connections to the API, either explicitly or implicitly.

If you don’t have ANY filter, mangle or dst-nat rules, you have nothing to worry about.


Stop getting ahead of yourself, and just try connecting with the public IP already. We’ll deal with any errors, if there are any to begin with.

can i have the code using vb.net
after some research i have found this but nothing works :frowning:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mk = New mkAPI(tb_ip.Text)
If Not mk.Login(tb_user.Text, tb_pass.Text) Then
mk.Close()
tb_result.Text = “Error”
Me.Enabled = True
Exit Sub
End If
mk.Login(tb_user.Text, tb_pass.Text)
mk.Send(“/ppp/active/remove/”, False)
mk.Send(“=.id=*8007DC0C”)

End Sub

on the rb side i can see on the log page
user **** logged in from 192.168.**** via api
but no session end
any help please

where did you get ‘*8007DC0C’? it should change each time user reconnects

“*8007DC0C” this is the session id that i want it to be disconnected
i have take this id from my rb ppp/active/getall

you don’t wait for any response of the command (also, is ‘/ppp/active/remove/’ a correct command? shouldn’t it be ‘/ppp/active/remove’?), why?

i have tried this

mk.Login(tb_user.Text, tb_pass.Text)
mk.Send(“/ppp/active/remove”, False)
mk.Send(“=.id=*8007DC0C”)
it did not work :frowning:

do you have an operational example for vb.net how to disconnect a pppoe user from the rb using api?
i am searching also for changing queue limits using api nothing found :frowning:
thank you

what’s the response?

nope

!trap=message=no such command
!done

so, ‘/ppp/active/remove’ seems like not valid command for some reason - recheck it…

You can disconnect user, from /ppp/interfaces/“username”