Community discussions

MikroTik App
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sun Sep 20, 2015 5:33 am

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

# The Problematic Part comes here #
{
: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] ]
}
}
}
}

# The new terminal error message #
invalid value of "to", must be integer

NORMIS, PLEASE HELP ME TO DO THE SCRIPT COME BACK TO WORK FINE !!!!!!!!!!!!!!!!!!!!!!!!!!!
 
JJCinAZ
Member
Member
Posts: 475
Joined: Fri Oct 22, 2004 8:03 am
Location: Tucson, AZ

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Tue Sep 22, 2015 12:39 am

Everywhere you have:
:for nodays from=0 to=$months do={
Try using:
:for nodays from=0 to=[:tonum $months] do={
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Wed Sep 23, 2015 2:39 am

Everywhere you have:
:for nodays from=0 to=$months do={
Try using:
:for nodays from=0 to=[:tonum $months] do={
Thank you! Your code works! You are great!

# This her is my own Version #
# Important: always set the limit-uptime under ip-hotspot user # :D :lol: :)

{
:local date [ /system clock get date ]
:if ( [ /ip hotspot user get $user comment ] = "" ) do={
[ /ip hotspot user set $user comment="$date"]
}
}
:foreach h in=[/ip hotspot active find] do={
:global user [/ip hotspot active get $h user];
:global mac [/ip hotspot active get $h mac-address];
/ip hotspot user set $user mac=$mac
}
{
:foreach h in=[/ip hotspot active find] do={
:local user [/ip hotspot active get $h user];
:local mac [/ip hotspot active get $h mac-address];
:local logdate [/ip hotspot user get $user comment];
:local date [/system clock get date];
:local time [/system clock get time];
:local upt [/ip hotspot user get $user limit-uptime];
/system scheduler remove [/system scheduler find name="$user"];
/system scheduler add comment="$date . $time" interval=$upt name="$user" on-event="/ip\
\_hotspot active remove [/ip hotspot active find user=\"$user\"]\r\
\n/ip hotspot user disable [/ip hotspot user find name=\"$user\"]\r\
\n/ip hotspot cookie remove [/ip hotspot cookie find name=\"$user\"]\r\
\n/system scheduler remove [/system scheduler find name=\"$user\"]" \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-date=$logdate start-time=12:00:00
}
}
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 4:18 pm

There is a new error! This is very Curios!

{
:local offset 2
: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=[: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 profile=PRIVATE ] 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=[:tonum $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 ]
}
}
}
}

# By profile=PRIVATE NewTerminal error ,,invalid value of "to", must be integer" #


{
:local offset 2
: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=[: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 profile=10RS ] 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=[:tonum $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 ]
}
}
}
}

# By profile=10RS without error, NewTerminal O.K, why ???????????????? #
 
JJCinAZ
Member
Member
Posts: 475
Joined: Fri Oct 22, 2004 8:03 am
Location: Tucson, AZ

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 5:21 pm

You should try inserting some ":log info ()" commands to debug your code. For example
...

:foreach i in [ /ip hotspot user find where profile=PRIVATE ] 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 ]
:log info ($days)
:local monthtxt [ :pick $date 0 3 ]
:log info ($monthtxt)
:local year [ :pick $date 7 11 ]
:log info ($year)
:local months ( [ :find $montharray $monthtxt ] )
:log info ($months)
:for nodays from=0 to=[:tonum $months] do={
:set days ( $days + [ :pick $monthdays $nodays ] )
}

...
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 5:36 pm

the result is
script info th
script info HP
script info r

what I not understand is
when I change the profile from the user the script runs very well, when I change the profile in users other time back to my custumated the error comes back
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 6:00 pm

{
:local offset 1
: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=[: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 profile=1000 ] 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 ]
:log info ($days)
:local monthtxt [ :pick $date 0 3 ]
:log info ($monthtxt)
:local year [ :pick $date 7 11 ]
:log info ($year)
:local months ( [ :find $montharray $monthtxt ] )
:log info ($months)
:for nodays from=0 to=[:tonum $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]
:local mac [/ip hotspot user get $i mac-address]
:local mail [/ip hotspot user get $i email]
:local time [/system clock get time]
:local cdate [/system clock get date]
:log info "HOTSPOT EXPIRE SCRIPT: Sending email to Hotspot user $name first logged in $date"
[ /tool e-mail send to="$mail" from="5g.net" subject=("Aviso 5G Net" . " -- " . "Usoario=$name" . " -- " . "Seu Mac=$mac") body=\
"AVISO SUA RECARGA VAI VENCER !!!
Sua Recarga vai vencer nos proximos 24 Horas, use todos os Gigabytes ou Megabytes restantes imediatamente !!!
Sua Recarga atual foi ativado no Dia-$date !!!
Nome do Usoario=$name, O Mac do seu Dispositivo=$mac
Esta Mensagem foi enviado em-$cdate, Horas-$time
Muito Obrigado dos seus Amigos da 5G Net de Novo Progresso, PA, CEP 68193-000, Brasil" ]
}
}
}
}

# invalid value of "to", must be integer #
# script info th
script info HP
script info r
script info #


# now I change the profile=270RS in hotspot user #


{
:local offset 1
: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=[: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 profile=270RS ] 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 ]
:log info ($days)
:local monthtxt [ :pick $date 0 3 ]
:log info ($monthtxt)
:local year [ :pick $date 7 11 ]
:log info ($year)
:local months ( [ :find $montharray $monthtxt ] )
:log info ($months)
:for nodays from=0 to=[:tonum $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]
:local mac [/ip hotspot user get $i mac-address]
:local mail [/ip hotspot user get $i email]
:local time [/system clock get time]
:local cdate [/system clock get date]
:log info "HOTSPOT EXPIRE SCRIPT: Sending email to Hotspot user $name first logged in $date"
[ /tool e-mail send to="$mail" from="5g.net" subject=("Aviso 5G Net" . " -- " . "Usoario=$name" . " -- " . "Seu Mac=$mac") body=\
"AVISO SUA RECARGA VAI VENCER !!!
Sua Recarga vai vencer nos proximos 24 Horas, use todos os Gigabytes ou Megabytes restantes imediatamente !!!
Sua Recarga atual foi ativado no Dia-$date !!!
Nome do Usoario=$name, O Mac do seu Dispositivo=$mac
Esta Mensagem foi enviado em-$cdate, Horas-$time
Muito Obrigado dos seus Amigos da 5G Net de Novo Progresso, PA, CEP 68193-000, Brasil" ]
}
}
}
}

# email send O.K, New Terminal no error,
script info 10
script info oct
script info 2015
script info 9

My email client thunderbird receifed

AVISO SUA RECARGA VAI VENCER !!!
Sua Recarga vai vencer nos proximos 24 Horas, use todos os Gigabytes ou Megabytes restantes imediatamente !!!
Sua Recarga atual foi ativado no Dia-oct/10/2015 !!!
Nome do Usoario=Sa, O Mac do seu Dispositivo=94:51:03:D3:B6:B8
Esta Mensagem foi enviado em-oct/19/2015, Horas-12:55:04
Muito Obrigado dos seus Amigos da 5G Net de Novo Progresso, PA, CEP 68193-000, Brasil #
 
JJCinAZ
Member
Member
Posts: 475
Joined: Fri Oct 22, 2004 8:03 am
Location: Tucson, AZ

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 6:16 pm

Right, so $days is wrong and that comes from the variable $date which comes from a hotspot user comment:
:local date [ /ip hotspot user get $i comment ]
So clearly, one of your hotspot users doesn't have a comment in the expected format.
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 9:34 pm

oct/10/2015
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 9:40 pm

I don't understand why this script works fine for all user profiles, error comes only by one especific profile, I doesn't change any thing from the rule, error occur when I change the profile in user profile???????????
 
JJCinAZ
Member
Member
Posts: 475
Joined: Fri Oct 22, 2004 8:03 am
Location: Tucson, AZ

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Mon Oct 19, 2015 9:41 pm

Try logging the date variable each time through the loop.
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Fri Oct 23, 2015 2:56 pm

I don't understand what you mean?????????????? :?
 
JJCinAZ
Member
Member
Posts: 475
Joined: Fri Oct 22, 2004 8:03 am
Location: Tucson, AZ

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sat Oct 24, 2015 1:16 am

Right after your line:
:local date [ /ip hotspot user get $i comment ]
Add a log:
:local date [ /ip hotspot user get $i comment ]
:log info "DATE IS:$date"
You'll see something you don't expect to be in the comment.
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sat Oct 24, 2015 12:40 pm

:foreach i in [ /ip hotspot user find where profile=1000 ] do={
:if ([ :find [ /ip hotspot user get $i comment ] ] = 0 ) do={
:local date [ /ip hotspot user get $i comment ]
:?
 
User avatar
diodo
just joined
Posts: 8
Joined: Fri May 06, 2016 3:58 am
Contact:

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Wed May 11, 2016 10:24 pm

:foreach i in [ /ip hotspot user find where profile=1000 ] do={
:if ([ :find [ /ip hotspot user get $i comment ] ] = 0 ) do={
:local date [ /ip hotspot user get $i comment ]
:?
Dear PeterDoBrasil

Did you reach solution for your problem? I´m trying to do a script similar to yours.
 
PeterDoBrasil
Member Candidate
Member Candidate
Topic Author
Posts: 134
Joined: Sun Aug 23, 2015 6:55 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sun May 22, 2016 12:14 am

:foreach i in [ /ip hotspot user find where profile=1000 ] do={
:if ([ :find [ /ip hotspot user get $i comment ] ] = 0 ) do={
:local date [ /ip hotspot user get $i comment ]
:?
Dear PeterDoBrasil

Did you reach solution for your problem? I´m trying to do a script similar to yours.
High Voltage has damaged my Router, I have no other device to work with Scripting now !!! :?
 
User avatar
diodo
just joined
Posts: 8
Joined: Fri May 06, 2016 3:58 am
Contact:

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sun May 22, 2016 2:16 am

Dear @PeterDoBrasil

Your script is being very useful to me. Thanks for share it on mikrotik WIKI.

I´m developing a group of scripts that should create a static user with the data of dinamic "trial hotspot user" and every LOGOUT, update the "uptime variable" of him (I´m using limit-uptime field).

Every days I run your script (with little adaptations) to know if the user spend more then 7hs in the last 7 days.

MY PROBLEM:

In "http://wiki.mikrotik.com/wiki/Manual:IP/Hotspot/User" says: "Starting with v6.34rc11 some additional variables are available:" we can find the new variable: "$uptime-secs" but using v6.35.2 or v6.34.1 the variable is not there.

Maybe your or the master @JJCinAZ can try help me.

Sorry for my bad english. My main language is portuguese. If possible call me on skype: osorio@diodo.com.br

Thank all.
 
User avatar
Sinan
Trainer
Trainer
Posts: 129
Joined: Tue Sep 01, 2015 7:00 am

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sun May 22, 2016 3:17 pm

This script has many errors !!
 
eldoncito2019
Member
Member
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sat Jun 04, 2022 4:53 pm

Friends, I found this script and I hope it will help someone:
:local mdays  {31;28;31;30;31;30;31;31;30;31;30;31}
:local months {"jan"=1;"feb"=2;"mar"=3;"apr"=4;"may"=5;"jun"=6;"jul"=7;"aug"=8;"sep"=9;"oct"=10;"nov"=11;"dec"=12}
:local monthr  {"jan";"feb";"mar";"apr";"may";"jun";"jul";"aug";"sep";"oct";"nov";"dec"}

:local dd  [:tonum [:pick $date 4 6]]
:local yy [:tonum [:pick $date 7 11]]
:local month [:pick $date 0 3]

:local mm (:$months->$month)
:set dd ($dd+$days)

:local dm [:pick $mdays ($mm-1)]
:if ($mm=2 && (($yy&3=0 && ($yy/100*100 != $yy)) || $yy/400*400=$yy) ) do={ :set dm 29 }

:while ($dd>$dm) do={
    :set dd ($dd-$dm)
    :set mm ($mm+1)
    :if ($mm>12) do={
        :set mm 1
        :set yy ($yy+1)
    }
    :set dm [:pick $mdays ($mm-1)]
    :if ($mm=2 &&  (($yy&3=0 && ($yy/100*100 != $yy)) || $yy/400*400=$yy) ) do={ :set dm 29 }
}
:local res "$[:pick $monthr ($mm-1)]/"
if ($dd<10) do={ :set res ($res."0") }
:set $res "$res$dd/$yy"
:return $res

:local date ([system clock get date]." ".[system clock get time])
:if ([ip hotspot user get $user value-name=comment]="") do={
    ip hotspot user set $user comment=$date
}
:local validDays 30

:local getNextTime [:parse [/system script get nextDateByCaibneTik source]]
foreach usr in=[ip hotspot user find] do={
    if (([len [ip hotspot user get $usr comment]]=20) && ([:find [ip hotspot user get $usr comment] " " -1]=11)) do={
        :local getComment [ip hotspot user get $usr comment]; :local date [:pick $getComment 0 11]; :local time [:pick $getComment 12 20]
        if ([$getNextTime date=$date days=$validDays]=[system clock get date]) do={
            :local nowTime [system clock get time]
            :local nowMS (([pick $nowTime 0 2]*60*60*1000)+([pick $nowTime 3 5]*60*1000)+([pick $nowTime 6 8]*1000))
            :local ms (([pick $time 0 2]*60*60*1000)+([pick $time 3 5]*60*1000)+([pick $time 6 8]*1000))
            if ([$nowMS]>=$ms) do={
                :local username [ip hotspot user get $usr name]
                ip hotspot active remove [find user=$username]
                ip hotspot user remove $usr
            } 
        }
    }
}


EL DONCITO.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sat Jun 04, 2022 5:11 pm

A code thrown there haphazardly, without instructions, and incomplete, does not help anyone.
It's just garbage,
For example, where is the "nextDateByCaibneTik" script?
 
eldoncito2019
Member
Member
Posts: 332
Joined: Fri Jun 14, 2019 1:07 pm

Re: Expire users a after number of days Stops Work after Upgrade to v.6.33rc11

Sat Jun 04, 2022 5:17 pm

Sorry is this:
{
:local tdias 0
:local atime [ /system clock get time ]
:local adate [ /system clock get date ]
:local temp1 [:pick $adate 0 3] 
:local temp2 [:pick $adate 4 6]
:local temp3 [:pick $atime 0 5]
:local temp4 ($temp2."/".$temp1." - ".$temp3."  Dias: ".$tdias);
:local thoras 4
:if ([ /ip hotspot user get $user comment ]="") do={ [ /ip hotspot user set $user comment=$temp4 ] }

:local mesarray ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
:local diaarray ("31","28","31","30","31","30","31","31","30","31","30","31")
:local day [:pick $adate 4 6]
:local monthtxt [:pick $adate 0 3]
:local year [:pick $adate 7 11]
:local months ([:find $mesarray $monthtxt])
:local dia ([:pick $diaarray $months])
:local fhora [:pick $atime 0 2]
:local fminutos [:pick $atime 3 5]
:local fsegundos [:pick $atime 6 9]
:local mayorhora (($fhora+$thoras)-24) 

 :if (($fhora+$thoras)>23) do={
     :set atime ("0".$mayorhora.":".$fminutos.":".fsegundos);
	 :set $tdias ($tdias+1);
	} else={
     :set atime (($fhora+$thoras).":".$fminutos.":".fsegundos) ;
 }
 

 :if (($day+$tdias)>$dia) do={
    :if ($months=11) do={
        
     :set months 0;
        
     :set year ($year+1);
        
     :set day (($day+$tdias)-$dia);
        
     :local mes ([:pick $mesarray $months]);
        
     :set adate ($mes."/".$day."/".$year);
        
     } else={
           
       :set months ($months+1);
           
       :set day (($day+$tdias)-$dia);
           
       :local mes ([:pick $mesarray $months]);
           
       :set adate ($mes."/".$day."/".$year);
        
       }
    
        } else={
        
          :set day ($day+$tdias);
        
          :local mes ([:pick $mesarray $months]);
        
          :set adate ($mes."/".$day."/".$year);
    
     }

[/system scheduler add name=$user on-event="/ip hotspot user remove \"$user\" \r\
  \n/ip hotspot cookie remove [find user=\"$user\"] \r\
  \n/ip dhcp-server lease remove [find dynamic] \r\
  \n/system scheduler remove [find name=\"$user\"] \r\
  \n\r\
  " start-date=$adate start-time=$atime]
 
}  


EL DONCITO.

Who is online

Users browsing this forum: No registered users and 14 guests