Community discussions

MikroTik App
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

API PHP commands to disable an user in HOTSpot

Wed Jul 22, 2009 5:23 pm

Hi

I am new in PHP API command, please I need an example to disable an user in HotSpot that login by MAC
Please let`s think that the MAC is 00:00:00:00:00.
Also I need to remove the MAC 00:00:00:00:00 in /ip hotspot host .

Could some one please send an example

Thanks
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API PHP commands to disable an user in HOTSpot

Thu Jul 23, 2009 9:02 am

use same commands as in CLI
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Thu Jul 23, 2009 4:39 pm

Sorry could you show me an example:

I have in my PHP-API program

$API->write('/ip/hotspot/host/print');
But now I dont know how remove an user ( we loging by mac, so the name the user is for example 00:00:00:00:00)

Sorry for my question but I understand just a litter englis and thas why I ask for example

Best Regards
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API PHP commands to disable an user in HOTSpot

Thu Jul 23, 2009 6:13 pm

please tell, how you do that in CLI
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Fri Jul 24, 2009 2:01 am

Hi I will do the next in CLI

To disable:
ip hot use set [find name=00:02:55:BF:07:59] disable=yes
To enable
ip hot use set [find name=00:02:55:BF:07:59] disable=no
To remove
ip hot use remove [find name=00:02:55:BF:07:59]

I have seen some samples but I dont understan the las part (both cases enable/disable and remove ) when you refer to the .id , When I write my program in PHP, I dont have the .id ; so what exactly Do I have to put in my PHP program (Sorry my question I think that I dont understan for my english) If you could show me exactly what do I have to put in my PHP program I will really apreciate it.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API PHP commands to disable an user in HOTSpot

Fri Jul 24, 2009 9:29 am

about id: http://forum.mikrotik.com/viewtopic.php ... 36#p164836

so, you first execute
/ip/hotspot/user/print
=.proplist=.id
?name=00:02:55:BF:07:59
then
/ip/hotspot/user/set
=.id=your_id_here
?disabled=yes|no
and
/ip/hotspot/user/remove
=.id=your_id_here
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Fri Jul 24, 2009 6:47 pm

Sorry ( I dont know how to say in englis closed, no smart,... but I dont get it. )

I will put in my PHP API program all these and in that same form:


/ip/hotspot/user/print
=.proplist=.id
?name=00:02:55:BF:07:59
/ip/hotspot/user/set
=.id=your_id_here What does mean "your_id_here",,, I am doing a program to enable or disable any MAC,,, so now is
?disabled=yes

I am doing a program to enable or disable any MAC,,, so now is 00:02:55:BF:07:59 ,,,but then will be another so will be another MAC and another .id.. It is a program in PHP I want that work for any time just I put the any MAC

Iam really sorry to dont understand
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Fri Jul 24, 2009 7:11 pm

I am asking because I am doing a aplication in PHP to disable or enable the MAC .. so my program will ask me .. introduce the MAC TO DISABLE, I will put the MAC, my program take these , put into a variable and the send the comands to the router to disable that MAC.

I hope that now I explain correctly.. Sorry again
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API PHP commands to disable an user in HOTSpot

Fri Jul 24, 2009 7:36 pm

so what's problem?.. you send '/print' command with any MAC you want, receive its .id, then do with it what you want: disable, remove, even change MAC =)
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Fri Jul 24, 2009 8:40 pm

So. to get the .id I have to run the funtion read() and put into a variable what is sending the router , then send the command to disable/enable with that varibale,,
If I am Ok.. please could you show me with all lines commands that i have to use (I am using the funtion that are in wiki.mikrotik.api ) please using that funtion. could you write me how to do that..
I am using $v_mac as the variable that have the MAC


<?php

require('routeros_api.class.php');

$API = new routeros_api();

$API->debug = true;

if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {

$API->write('/ip/hotspot/user/print');
$API->write('=.proplist=.id');
$API->write('?name='.$v_mac); ...????????it is ok?

THEN????


$API->disconnect();

}

?>

Thanks
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API PHP commands to disable an user in HOTSpot

Sat Jul 25, 2009 3:16 pm

at first,

$API->write('/ip/hotspot/user/print', false);
$API->write('=.proplist=.id', false);
$API->write('?name='.$v_mac);

$API->write('?name='.$v_mac); ...????????it is ok?
yes, it is as it should be
THEN????
something like

$A = $API->read();
$A = $A[0];
$API->write('/ip/hotspot/user/set', false);
$API->write('=.id='.$A['.id'], false);
$API->write('=disabled=yes');
$API->read();
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Mon Jul 27, 2009 9:44 pm

Thks.. It is working

2 more things

1 ) One more question. I will use it to enable/disable, add/ remove user a lot of other things etc etc etc.., Do I have to be carefull with something,, or waht will I could not do or waht command are possible to execute or which ones not..

2) If I use a User Manager ..
2.1 Could I use these API command to enable/disable user that are in User manager
2.2 If I use User Manager DO I have to have the user in the User Manager and in each
router too ?
2.1 Does User Manager have a walled garden...like HotSpot
2.1 Have a profile (to use diferentes Band with) to apli to diferents user

Best Regards




Best Regards
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26381
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API PHP commands to disable an user in HOTSpot

Tue Jul 28, 2009 10:34 am

user manager doesn't replace hotspot, it just is a visual interface for managing users OF HOTSPOT. the same walled garden is still used.
 
juanCasseus
just joined
Topic Author
Posts: 15
Joined: Mon Jul 20, 2009 12:02 am

Re: API PHP commands to disable an user in HOTSpot

Tue Jul 28, 2009 11:05 pm

Please I did read about User Manager but In some place I read that I have to delete all configuration of the Hotspot in each router to be able to use the User Manager:

http://wiki.mikrotik.com/wiki/User_Mana ... ot_Example

* Note, first local HotSpot database is consulted, then User Manager database.

It means that if you have configuration in '/ ip hotspot user print', users will be able to authenticate in HotSpot using these data. Delete users configuration from '/ ip hotspot print' to stop using local HotSpot database for authentication. To move batch of local HotSpot users to the User Manager database use export/import . Use text editor program to create appropriate file to import local users to the User Manager database.

Sorry I dont Understand, If I have to keep the local configuration of each user ( to be able to use the "advertising and script " that have the profile user. So How can I use the profile user If I cant say to each user in USERMANAGER what is its profile.
Even more.. If I want to create new User DO I have to creat in local Hotspot or in USERMANAGER or both.

Again I am sorry. Pease help me
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26381
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API PHP commands to disable an user in HOTSpot

Thu Jul 30, 2009 1:46 pm

this is only to help you migrate. you DO NOT HAVE TO create any users locally, you can make all users only in user manager
 
onowojemma
Member Candidate
Member Candidate
Posts: 129
Joined: Sun Sep 11, 2005 5:27 pm
Location: Nigeria

Night Belt Hotspot

Sat Aug 22, 2009 10:10 pm

Hi Normis, and every one here.
Please i need some help on userman and hotspot is there a way i could make some users created on hotspot userman such that the name could only be active from 6pm till 7am the following day and then be disable from 7am till 6pm agin i.e they can only be use at night?

Who is online

Users browsing this forum: No registered users and 60 guests