Hotspot on Login Script
{
:global name
:global mac
:global date
:global prof
:global action
:foreach i in=[/ip hotspot user find where dynamic=no ] do={
:if ([/ip hotspot user get $i comment ] = “” ) do={
:set name [/ip hotspot user get $i name ];
:set prof [/ip hotspot user get $i profile ];
:if ([/ip hotspot active find where user=“$name” ] != “” ) do={
:set date [/system clock get date ];
:set mac [/ip hotspot active get [ find where user=“$name” ] mac-address ];
:set action [/ip hotspot user set $i mac-address=$mac comment=“$date” ];
:log warning (“New Login User->$name Mac->$mac Profile->$prof”);
}}}}
\
Other Version
Expire Payed User
{
:global offset
:global today
:global prof
{
: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] )
:for nodays from=0 to=[:tonum $months] do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:set today $days
}
:foreach i in [ /ip hotspot user find where dynamic=no (profile=10 || profile=30 || profile=60
|| profile=100 || profile=110 ) ] do={
:if ([/ip hotspot user get $i comment ] != “” ) do={
:local date [ /ip hotspot user get $i comment ]
: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 ] )
:for nodays from=0 to=[:tonum $months] do={
:set days ( $days + [ :pick $monthdays $nodays ] )
:set prof [/ip hotspot user get $i profile ]
:if (“$prof” = “10”) do={
:set offset 2
} else={
:if (“$prof” = “30”) do={
:set offset 6
} else={
:if (“$prof” = “60”) do={
:set offset 12
} else={
:if (“$prof” = “100”) do={
:set offset 20
} else={
:if (“$prof” = “110”) do={
:set offset 31
}}}}}}
:set days ($days + $year * 365)
:if ( ($days + $offset) < $today ) do={
:local name [/ip hotspot user get $i name]
:log error (“HOTSPOT EXPIRE SCRIPT: Disabling Hotspot User $name with Profile $prof and Offset $offset first logged in $date”)
[ /ip hotspot user disable $i ]
[ /ip hotspot active remove [find where user=$user] ]
}}}}