0% found this document useful (0 votes)
134 views2 pages

Hostpot

1. The script sets the login date in the comment field of a hotspot user when they connect. 2. It is meant to run daily from the scheduler to check for expired users based on their profile's validity period and remove them if expired. 3. The script checks two user profiles, with offsets of 31 and 90 days before removing expired users and disconnecting them.

Uploaded by

David Bracho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views2 pages

Hostpot

1. The script sets the login date in the comment field of a hotspot user when they connect. 2. It is meant to run daily from the scheduler to check for expired users based on their profile's validity period and remove them if expired. 3. The script checks two user profiles, with offsets of 31 and 90 days before removing expired users and disconnecting them.

Uploaded by

David Bracho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

## The script sets the date in the user comment ##

## Place it in system Script and enter the path to the script in user-profile by-
login ##
## Written by: BrasDeutscher,PA,Brazil ##
## Testet under RouterOS v6.37rc32 ##
{
## !!-- Enter the Hotspot server name here --!! ##
:global sv "1"

## !!-- PLEASE CHANGE NOTHING MORE BELOW --!! ##


:global mac
:global ip
:global date [/system clock get date ]
:global action1
:global action2
:foreach i in=[/ip hotspot active find where server="$sv" ] do={
:set mac [/ip hotspot active get $i mac-address ];
:set ip [/ip hotspot active get $i address ];
:if ([/ip hotspot user get [find where ! default ! dynamic ! disabled \
mac-address=$mac ] comment ] = "" ) do={
:set action1 [/ip hotspot user set [find where mac-address=$mac ]
comment="$date" ];
:set action2 [/ip hotspot active remove [find where mac-address=$mac ]];
:log warning ("New Login Mac:$mac mit der IP:$ip");
}}}

## Expire Hotspot User ##


## One script for all profiles ##
## Written by: BrasDeutscher,PA,Brazil ##
## Testet under RouterOS v6.37rc32 ##
## Enter the script in the Schedule and let it run with daily Interval ##
{
:global today
:global prof
:global offset
{
: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
}
#########!!-- In this line, the script check's two user profiles --!!############
:foreach i in=[/ip hotspot user find where ! default ! disabled ( profile=1 ||
profile=2 ) ] 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 prof [/ip hotspot user get $i profile ]
### !!-- Offset mean's the validity period of the Hotspot user e.g. 31 days etc.
--!! ###
:if ("$prof" = 1 ) do={
:set offset 31
} else={
:if ("$prof" = 2 ) do={
:set offset 90
}}}
: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]
:log warning "EXPIRE PROFIL $prof : Offset:$offset : Hotspot Nutzer:$name Mac:$mac
1. Login am $Date"
[/ip hotspot user remove $i ]
[/ip hotspot active remove [ find where mac-address=$mac ]]
}}}}

You might also like