-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuto Remove Mikrotik Userman Expired User
More file actions
34 lines (31 loc) · 1.37 KB
/
Copy pathAuto Remove Mikrotik Userman Expired User
File metadata and controls
34 lines (31 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
:local dateint do={
:local days [ :pick $d 8 12 ];
:local month [ :pick $d 5 7 ];
:local year [ :pick $d 0 4 ];
:return [:tonum ("$year$month$days")];
}
:local timeint do={
:local hours [ :pick $t 0 2 ];
:local minutes [ :pick $t 3 5 ];
:return ($hours * 60 + $minutes);
}
:local date [ /system clock get date ];
:local time [ /system clock get time ];
:local today [$dateint d=$date] ;
:local curtime [$timeint t=$time];
:foreach i in [ /user-manager/user-profile/find state=used ] do={
:local userprofile [user-manager/user-profile/get value-name=user number=$i];
:local expiredtime [user-manager/user-profile/get value-name=end-time number=$i];
:local olahdatamentah $expiredtime;
:local tanggalexpired [ :pick $olahdatamentah 0 10];
:local waktuexpired [ :pick $olahdatamentah 11 19];
:local tanggalexpiredconverted [$dateint d=$tanggalexpired];
:local waktuexpiredconverted [$timeint t=$waktuexpired];
:if (($tanggalexpiredconverted < $today and $waktuexpiredconverted < $curtime) or ($tanggalexpiredconverted < $today and $waktuexpiredconverted > $curtime) or ($tanggalexpiredconverted = $today and $waktuexpiredconverted < $curtime)) do={
/user-manager/user/remove [find name=$userprofile];
/user-manager/user-profile/remove numbers=$i;
} else={
:put "salah. Masih Aktif.";
:put [/user-manager/user/print detail where name=$userprofile]
}
}