بسم الله الرحمان الرحيم
نقدم لكم اليوم حل مشكله الصلاحيه+تصفير الكروت في الهوست بوتالحل يتناسب مع برنامج هوائي فقط.
ناتي الي الشرح
اولا نضع الامر في يوزر بروفايل on-login
/import alssman;
ثانيا نضع الامر التالي في يوزر بروفايل on-logout
{:local content [ /ip hotspot user get $user comment ];:local Uuptime [ /ip hotspot user get $user uptime];:local LimitUptime [ /ip hotspot user get $user limit-uptime ];:local limitBytesTotal [ /ip hotspot user get $user limit-bytes-total];:local bytesOut [ /ip hotspot user get $user bytes-out];:local IscommentAnd [ :find $content "&" ];:local IscommentStar [ :find $content "*" ];:if ( $IscommentAnd >= 0 && $IscommentStar >=0) do={:local pos1 [:find $content "*"];:local pos2 [:len $content];:local comment [:pick $content 0 ($pos1) ]; :local Timeleft;:local Sizletf;:if ([:len $LimitUptime] = 0) do={ :set Timeleft unlimited};:if ([:len $LimitUptime] != 0) do={ :set Timeleft ($LimitUptime - $Uuptime);};:if ([:len $limitBytesTotal] = 0) do={ :set Sizletf unlimited};:if ([:len $limitBytesTotal] != 0) do={:set Sizletf ($limitBytesTotal - $bytesOut);};[/ip hotspot user set $user comment=($comment . "*" . $Sizletf . "&" . $Timeleft)];};};
/system script
add name=Save_Session_TimeLeft_774278910 owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive source="{:forea\
ch i in [ /ip hotspot active find where !radius ] do={:local SessionTimeLe\
ft [ /ip hotspot active get \$i session-time-left];:local SizeTimeLeft [ /\
ip hotspot active get \$i limit-bytes-total];:local username [ /ip hotspot\
\_active get \$i user];:local content [ /ip hotspot user get \$username co\
mment ];:if ([:len \$SessionTimeLeft] = 0) do={ set SessionTimeLeft unli\
mited};:if ([:len \$SizeTimeLeft] = 0) do={ set SizeTimeLeft unlimited};:l\
ocal IscommentAnd [ :find \$content \"&\" ];:local IscommentStar [ :find \
\$content \"*\" ];:if ( \$IscommentAnd >= 0 && \$IscommentStar >=0) do={:l\
ocal pos1 [:find \$content \"*\"];:local pos2 [:len \$content];:local SubC\
omment [:pick \$content 0 (\$pos1) ];[/ip hotspot user set \$username com\
ment=(\$SubComment . \"*\" . \$SizeTimeLeft . \"&\" . \$SessionTimeLeft)];\
};};}; "
add name=Check_Session_TimeLeft_After_Shutdown_774278910 owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive source=" {:fore\
ach i in [ /ip hotspot user find where disabled=no] do={:local name [ /ip \
hotspot user get \$i name ];:local content [ /ip hotspot user get \$i comm\
ent ];:local uptime [ /ip hotspot user get \$i uptime ];:local limitUptime\
\_[ /ip hotspot user get \$i limit-uptime ];:local limitBytesTotal [ /ip h\
otspot user get \$i limit-bytes-total];:local bytesOut [ /ip hotspot user \
get \$i bytes-out];:local IscommentAnd [ :find \$content \"&\" ];:local Is\
commentStar [ :find \$content \"*\" ];:if ( \$IscommentAnd >= 0 && \$Iscom\
mentStar >=0) do={:local SubComment;:local Sizletf;:local Timeleft;:local \
pos1 [:find \$content \"*\"];:local pos3 [:len \$content];:local pos2 ([:f\
ind [:pick \$content (\$pos1+1) \$pos3] \"&\"]+\$pos1+1);:set SubComment [\
:pick \$content 0 (\$pos1)];:set Sizletf [:pick \$content (\$pos1+1) \$\
pos2];:set Timeleft [:pick \$content (\$pos2+1) (\$pos3)];:if ( ([:totim\
e \$Timeleft] > 00:00:00) && \$Timeleft != \"unlimited\" ) do={:if ( \$Tim\
eleft < (\$limitUptime - \$uptime)) do={[/ip hotspot user set \$name limi\
t-uptime= (\$Timeleft + \$uptime )];};};:if (\$Sizletf < \$limitBytesTotal\
\_&& \$Sizletf !=\"unlimited\" ) do={:if ( \$Sizletf < (\$limitBytesTotal \
- \$bytesOut)) do={[ /ip hotspot user set \$name limit-bytes-total= (\$Si\
zletf + \$bytesOut )];};};};};}; ";
/system scheduler
add name=Check_Session_TimeLeft_After_Shutdown on-event=\
Check_Session_TimeLeft_After_Shutdown_774278910 policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive start-time=\
startup
add interval=10m name=Save_Session_TimeLeft on-event=Save_Session_TimeLeft_774278910 \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-time=startup
add interval=3h name=alharth_alssman on-event="{\r\
\n:global today;\r\
\n{\r\
\n:local date [ /system clock get date ];\r\
\n:local montharray ( \"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"ju\
l\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\" );\r\
\n:local monthdays ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );\r\
\n:local days [ :pick \$date 4 6 ];\r\
\n:local monthtxt [ :pick \$date 0 3 ];\r\
\n:local year [ :pick \$date 7 11 ];\r\
\n:local months ([ :find \$montharray \$monthtxt]);\r\
\n:for nodays from=0 to=\$months do={\r\
\n:set days ( \$days + [ :pick \$monthdays \$nodays ] )};\r\
\n:set days (\$days + \$year * 365);\r\
\n:set today \$days;\r\
\n:foreach i in=[ /ip hotspot user find where disabled=no and comment~\"@\
\"] do={\r\
\n:local comm [/ip hotspot user get \$i comment];\r\
\n:local h2 [:find \$comm #];\r\
\n:local z [:pick \$comm 12 \$h2];\r\
\n:if ( [:tonum \$z] < \$today ) do={\r\
\n:local username [/ip hotspot user get \$i name];\r\
\n:log info \"user man \$username disabled by Alharth alssman_774278910\";\
\r\
\n/ip hotspot user disable \$i;\r\
\n/ip hotspot active remove [find where user=\$username];\r\
\n}\r\
\n}\r\
\n}\r\
\n}" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-time=startup;
add name=Save_Session_TimeLeft_774278910 owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive source="{:forea\
ch i in [ /ip hotspot active find where !radius ] do={:local SessionTimeLe\
ft [ /ip hotspot active get \$i session-time-left];:local SizeTimeLeft [ /\
ip hotspot active get \$i limit-bytes-total];:local username [ /ip hotspot\
\_active get \$i user];:local content [ /ip hotspot user get \$username co\
mment ];:if ([:len \$SessionTimeLeft] = 0) do={ set SessionTimeLeft unli\
mited};:if ([:len \$SizeTimeLeft] = 0) do={ set SizeTimeLeft unlimited};:l\
ocal IscommentAnd [ :find \$content \"&\" ];:local IscommentStar [ :find \
\$content \"*\" ];:if ( \$IscommentAnd >= 0 && \$IscommentStar >=0) do={:l\
ocal pos1 [:find \$content \"*\"];:local pos2 [:len \$content];:local SubC\
omment [:pick \$content 0 (\$pos1) ];[/ip hotspot user set \$username com\
ment=(\$SubComment . \"*\" . \$SizeTimeLeft . \"&\" . \$SessionTimeLeft)];\
};};}; "
add name=Check_Session_TimeLeft_After_Shutdown_774278910 owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive source=" {:fore\
ach i in [ /ip hotspot user find where disabled=no] do={:local name [ /ip \
hotspot user get \$i name ];:local content [ /ip hotspot user get \$i comm\
ent ];:local uptime [ /ip hotspot user get \$i uptime ];:local limitUptime\
\_[ /ip hotspot user get \$i limit-uptime ];:local limitBytesTotal [ /ip h\
otspot user get \$i limit-bytes-total];:local bytesOut [ /ip hotspot user \
get \$i bytes-out];:local IscommentAnd [ :find \$content \"&\" ];:local Is\
commentStar [ :find \$content \"*\" ];:if ( \$IscommentAnd >= 0 && \$Iscom\
mentStar >=0) do={:local SubComment;:local Sizletf;:local Timeleft;:local \
pos1 [:find \$content \"*\"];:local pos3 [:len \$content];:local pos2 ([:f\
ind [:pick \$content (\$pos1+1) \$pos3] \"&\"]+\$pos1+1);:set SubComment [\
:pick \$content 0 (\$pos1)];:set Sizletf [:pick \$content (\$pos1+1) \$\
pos2];:set Timeleft [:pick \$content (\$pos2+1) (\$pos3)];:if ( ([:totim\
e \$Timeleft] > 00:00:00) && \$Timeleft != \"unlimited\" ) do={:if ( \$Tim\
eleft < (\$limitUptime - \$uptime)) do={[/ip hotspot user set \$name limi\
t-uptime= (\$Timeleft + \$uptime )];};};:if (\$Sizletf < \$limitBytesTotal\
\_&& \$Sizletf !=\"unlimited\" ) do={:if ( \$Sizletf < (\$limitBytesTotal \
- \$bytesOut)) do={[ /ip hotspot user set \$name limit-bytes-total= (\$Si\
zletf + \$bytesOut )];};};};};}; ";
/system scheduler
add name=Check_Session_TimeLeft_After_Shutdown on-event=\
Check_Session_TimeLeft_After_Shutdown_774278910 policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive start-time=\
startup
add interval=10m name=Save_Session_TimeLeft on-event=Save_Session_TimeLeft_774278910 \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
start-time=startup
add interval=3h name=alharth_alssman on-event="{\r\
\n:global today;\r\
\n{\r\
\n:local date [ /system clock get date ];\r\
\n:local montharray ( \"jan\",\"feb\",\"mar\",\"apr\",\"may\",\"jun\",\"ju\
l\",\"aug\",\"sep\",\"oct\",\"nov\",\"dec\" );\r\
\n:local monthdays ( 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );\r\
\n:local days [ :pick \$date 4 6 ];\r\
\n:local monthtxt [ :pick \$date 0 3 ];\r\
\n:local year [ :pick \$date 7 11 ];\r\
\n:local months ([ :find \$montharray \$monthtxt]);\r\
\n:for nodays from=0 to=\$months do={\r\
\n:set days ( \$days + [ :pick \$monthdays \$nodays ] )};\r\
\n:set days (\$days + \$year * 365);\r\
\n:set today \$days;\r\
\n:foreach i in=[ /ip hotspot user find where disabled=no and comment~\"@\
\"] do={\r\
\n:local comm [/ip hotspot user get \$i comment];\r\
\n:local h2 [:find \$comm #];\r\
\n:local z [:pick \$comm 12 \$h2];\r\
\n:if ( [:tonum \$z] < \$today ) do={\r\
\n:local username [/ip hotspot user get \$i name];\r\
\n:log info \"user man \$username disabled by Alharth alssman_774278910\";\
\r\
\n/ip hotspot user disable \$i;\r\
\n/ip hotspot active remove [find where user=\$username];\r\
\n}\r\
\n}\r\
\n}\r\
\n}" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-time=startup;
تعليقات
إرسال تعليق