Community discussions

MikroTik App
 
kapes
Trainer
Trainer
Topic Author
Posts: 2
Joined: Sat Aug 31, 2013 5:41 pm

hotspot script, for make user profile ( hour, day, month) be active on every first login

Sun Aug 02, 2015 9:05 pm

Put the scripts on hotspot user profile script at on Login:
And add user with correct profile.
**********************************************************************************************************
Hour Profile Scripts
{
:local a false;
:foreach i in [/ip hotspot user find name=$user limit-uptime=01:00:00] do= {
:set a true;
}
:if ( $a = false ) do={
/ip hotspot user set $user limit-uptime=01:00:00;
/ip hotspot user reset-counters $user;
/ip hotspot user set $user comment="";
:foreach j in [/ip hotspot active find where user=$user] do= {
/ip hotspot active remove numbers=$j;
}
}
}}
*********************************************************************************************************
Day Profile Scripts
{
:local dayticket 1;
:local date [/system clock get date];
:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" );
:local monthdays;
:local days [ :pick $date 4 6 ];
:local monthtxt [ :pick $date 0 3 ];
:local year [ :pick $date 7 11 ];
:if (($year % 400) = 0 or ($year % 4) = 0 and ($year % 100) != 0) do={
:set monthdays ( 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ) ;
} else= {
:set monthdays ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ) ;
}
:local months ([ :find $montharray $monthtxt] )
:for nodays from=0 to=$months do={
:set days ( $days + [ :pick $monthdays ($nodays-1) ] )
}
:local comment [/ip hotspot user get $user comment ];
:local check false;
:if ( $comment != "" ) do={
:set check true;
}
:if ($check = false) do={
/ip hotspot user set $user comment=$date;
ip hotspot user set $user limit-uptime=00:00:00;
:foreach j in [/ip hotspot active find where user=$user] do= {
/ip hotspot active remove numbers=$j;
}}
if ($check = true) do={
:local sdate;
:set sdate $comment;
:local sdays [ :pick $sdate 4 6 ]
:local smonthtxt [ :pick $sdate 0 3 ]
:local syear [ :pick $sdate 7 11 ]
:local smonths ([ :find $montharray $smonthtxt] )
:for nodays from=0 to=$smonths do={
:set sdays ( $sdays + [ :pick $monthdays ($nodays-1) ] )
}
:if ($smonthtxt = "dec" and $monthtxt = "jan") do={
:set days ($days + 365);
}
:set dayticket ($dayticket - 1);
:local total;
:set total ($days - $sdays);
:if ($total > $dayticket) do={
/ip hotspot user set $user disabled=yes;
:foreach k in [/ip hotspot active find where user=$user] do= {
/ip hotspot active remove numbers=$k;
}}
}
}
********************************************************************************************************
Month Profile Scripts
{
:local monthticket 1;
:local date [/system clock get date];
:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" )
:local monthdays ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 )
:local days [ :pick $date 4 6 ]
:local monthtxt [ :pick $date 0 3 ]
:local year [ :pick $date 7 11 ]
:local months ([ :find $montharray $monthtxt] )
:local comment [/ip hotspot user get $user comment ];
:local check false;
:if ( $comment != "" ) do={
:set check true;
}
:if ($check = false) do={
/ip hotspot user set $user comment=$date;
ip hotspot user set $user limit-uptime=00:00:00;
:foreach j in [/ip hotspot active find where user=$user] do= {
/ip hotspot active remove numbers=$j;
}}
if ($check = true) do={
:local sdate;
:set sdate $comment;

:local sdays [ :pick $sdate 4 6 ]
:local smonthtxt [ :pick $sdate 0 3 ]
:local syear [ :pick $sdate 7 11 ]
:local smonths ([ :find $montharray $smonthtxt] )
:set months ($months + 1);
:set smonths ($smonths + 1);
:if ($months < $smonths) do={
:set months ($months + 11);
}
:local total;
:set total ($months - $smonths);
:if ($total > $monthticket or $total = $monthticket) do={
/ip hotspot user set $user disabled=yes;
:foreach k in [/ip hotspot active find where user=$user] do= {
/ip hotspot active remove numbers=$k;
}}
}
}
******************************************************************************************************
You do not have the required permissions to view the files attached to this post.
 
kojakjordan
just joined
Posts: 1
Joined: Wed May 18, 2022 8:51 pm

Re: hotspot script, for make user profile ( hour, day, month) be active on every first login

Wed May 18, 2022 9:04 pm

hi sir :
the script is working with one problem that he on log in remove all users in active but i need to remove the only user reached his limit
I Hobe you can help me
thanks

Who is online

Users browsing this forum: flapviv, MTNick and 21 guests