Community discussions

 
kraker
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 88
Joined: Thu Aug 02, 2012 9:34 am

Access Period based user script for hotspot users...

Sat Sep 13, 2014 2:01 pm

Hi all;

At the wiki, I found below script based on first login date.It's solve the hotspot user access for a period of time and it's working like time based radius.

http://blog.getcaffeinated.net/2012/05/ ... er-7-days/

Question: How can I use this script with a different user profile?

Example: offset 7 (for user profile x)
offset 5 (for user profile y) ........


first login script,

{
:local date [ /system clock get date ]
:if ( [ /ip hotspot user get $user comment ] = "" ) do={
[ /ip hotspot user set $user comment=$date ]
}
}

.....

daily script,

{
: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 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: Disabling Hotspot user $name first logged in $date"
[ /ip hotspot user disable $i ]
[ /ip hotspot active remove [find where user=$user] ]
}
}
}
}


thanks...
 
cicserver
Member
Member
Posts: 300
Joined: Sun Jul 24, 2011 12:04 pm

Re: Access Period based user script for hotspot users...

Fri Sep 19, 2014 1:14 pm

I am interested to know it too :)
 
gogo3alatool
just joined
Posts: 3
Joined: Mon Feb 02, 2015 10:15 pm

Re: Access Period based user script for hotspot users...

Mon Feb 02, 2015 10:25 pm

excuse me for my bad language ..
there is one wrong code in first part and i think i correct it

the old one:


{
: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
}



the corrected one:


{
: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-1) do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:set today $days
}




please feed me back
thanx
 
gogo3alatool
just joined
Posts: 3
Joined: Mon Feb 02, 2015 10:15 pm

Re: Access Period based user script for hotspot users...

Mon Feb 02, 2015 10:28 pm

{
: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 -1) do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}
:set days ($days + $year * 365)
:set today $days
}

Who is online

Users browsing this forum: Google [Bot] and 8 guests