let say if i configure "Trial uptime time 1d 00:10:00" and "trial uptime reset 30d 00:10:00" what does that means i'm a little confused with this....
It means the user can use ten minutes of internet, then will be locked out. After one month, he can use 10 minutes again.
{
:local offset 7
:global today
{
: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=$months do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:set today $days
}
:foreach i in=[/ip hotspot user find where profile=PRIVATE disabled=no] do={
:if ([ :find [ /ip hotspot user get $i comment ] ] = 0 ) 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=$months do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:if ( ($days + $offset) < $today ) do={
:local name [/ip hotspot user get $i name]
:log info "HOTSPOT EXPIRE SCRIPT: Setting Profile=ERROR to Hotspot user $name first logged in $date"
/ip hotspot user set profile=ERROR [/ip hotspot user find comment="$date"]
}
}
}
}
# Now it works #
# EXPIRE USER #
{
:global offset
:global today
:global getprof
{
: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 (comment~"jan" || comment~"feb" || comment~"mar" || comment~"apr" \
|| comment~"may" || comment~"jun" || comment~"jul" || comment~"aug" || comment~"sep" || comment~"oct" \
|| comment~"nov" || comment~"dec" ) ] 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 getprof [/ip hotspot user get $i profile ]
:if ("$getprof" = "10") do={
:set offset 2
} else={
:if ("$getprof" = "30") do={
:set offset 7
} else={
:if ("$getprof" = "60") do={
:set offset 14
} else={
:if ("$getprof" = "100") do={
:set offset 21
} else={
:if ("$getprof" = "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: Removing Hotspot user $name Profile -> $getprof Offset is $offset Days first logged in $date"
[/ip hotspot user remove $i ]
}}}}