Hi All,
I'm super new to this, therefore, I've had someone help me create a Hotspot profile script for 3-hour & single day vouchers in winbox, but have run into some issues of the script not executing as needed.
FYI - in Mexico hence the wording in script below
- Would like it to have the current user comment also show up in the Active comments
- Be able to see the session time left in Active tab
- Fix that the vouchers are not deactivating and deleting when time is up
- Is there a way to keep a record of information from expired vouchers which contains the User name, MAC, date & time activated, and voucher type (day or 3-hour) or the profile name used
{
:local tdias 0
:local thoras 3
: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 ($adate." - ".$temp3." Horas: ".$thoras);
:if ( [ /ip hotspot user get $user comment ] = "" ) do={ [ /ip hotspot user set $user comment=$temp4 ] }
Agrego un registro en el LOG del usuario (Create registry in LOG)
/log info "Usuario= $user $adate $atime Dias: $tdias ";
: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/system scheduler remove [find name="$user"] \r
\n/ip hotspot active remove [find user="$user"] \r
\n/\r
" start-date=$adate start-time=$atime]
}