Quantcast
Channel: MikroTik
Viewing all articles
Browse latest Browse all 21147

Useful user articles • permissions of the days for Hotspot users

$
0
0
This script is the permissions of the days for Hotspot users of the days and it worked well on the 6 system, and after updating to version 7.15 it did not work. What is the reason and how do I solve it?

Code:
{ :global todayHours; { :local d [ /system clock get date ]; :local t [ /system clock get time ]; :set d ($d." ".$t); :local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" ); :local monthdays ( 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ); :local days [ :pick $d 4 6 ]; :local monthtxt [ :pick $d 0 3 ]; :local year [ :pick $d 9 11 ]; :local monthsIndex ([ :find $montharray $monthtxt]); :local h [ :pick $d 12 14 ]; :local m [ :pick $d 15 17 ]; :local s [ :pick $d 18 20 ]; :for nodays from=0 to=$monthsIndex do={ :set days ( $days + [ :pick $monthdays $nodays ] ); }; :set days ($days + $year * 365); :local totalHours ($h + ($days * 24)); :set todayHours $totalHours; }; :foreach i in=[ /ip hotspot user find where disabled=no ] do={ :if ([ :find [ /ip hotspot user get $i comment ] ] = 0 && [ :find [ /ip hotspot user get $i email ] ] = 0) do={ :local d [ /ip hotspot user get $i comment ]; :local oldemail [ /ip hotspot user get $i email ]; :local atmark [ :find $oldemail "@" ]; :local dotmark [ :find $oldemail "." ]; :if ( $atmark >= 0 && $dotmark >= 0 ) do={ :local validity [ :pick $oldemail 0 $atmark]; :local rest [ :pick $oldemail ($atmark + 1) [ :len $oldemail] ]; :local validityInHours false; :local hmark [ :find $validity "h" ]; :if ( $hmark >= 0) do={ :set validityInHours true; :set validity [ :pick $validity 0 $hmark]; }; :if ( [:tonum $validity] != "" ) do={ :if ( [:tonum $validity] != "0" ) do={ :if ([:len $d] != 20) do={ :set d ( $d." 00:00:00" ); }; :local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" ); :local monthdays ( 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ); :local days [ :pick $d 4 6 ]; :local monthtxt [ :pick $d 0 3 ]; :local year [ :pick $d 9 11 ]; :local monthsIndex ([ :find $montharray $monthtxt]); :local h [ :pick $d 12 14 ]; :local m [ :pick $d 15 17 ]; :local s [ :pick $d 18 20 ]; :for nodays from=0 to=$monthsIndex do={ :set days ( $days + [ :pick $monthdays $nodays ] ); }; :set days ($days + $year * 365); :local totalHours ($h + ($days * 24)); :local totalValidity $validity; :if ($validityInHours = false) do={ :set totalValidity ($validity * 24); }; :if ( ($totalHours + $totalValidity) <= $todayHours ) do={ :local n [/ip hotspot user get $i name]; :log info "HOTSPOT VALITITY EXPIRE: Disabling Hotspot user $n first logged in $d"; [ /ip hotspot user disable $i ]; }; }; }; }; }; }; };

Statistics: Posted by samiesmail — Sat Mar 16, 2024 1:37 am



Viewing all articles
Browse latest Browse all 21147

Trending Articles