|
发表于 2012-7-13 09:04:21
|
显示全部楼层
#6位日期版,给你参考一下#
#清除所有/ppp secret的remote-address ip
/ppp secret
:foreach j in=[find comment!=""] do={:if ([get $j remote-address]!="") do={unset $j remote-address;}}
#计算日期
:global ipn 11
:local Date [/system clock get date];:local Year ([:pick $Date 7 11]-1)
:local Month ([:find jan,feb,mar,apr,may,jun,jul,aug,sep,oct,nov,dec [:pick $Date 0 3]])
:local Day [:pick $Date 4 6];:if ([:pick $Date 4 5] = 0) do={:set Day [:pick $Date 5 6]};:set Day ($Day-1)
:local leapyear 0,31,59,90,120,151,181,212,243,273,304,334,0,31,60,91,121,152,182,213,244,274,305,335
:global Today ($Year*365+$Year/4)
:if (($Year-$Year/4*4) != 3) do={:set Today ($Today+[:pick $leapyear $Month]+$Day)} else={:set Today ($Today+[:pick $leapyear ($Month+12)]+$Day)}
:local usname;:local uspfl;:local Ccomment;:local Exp;:local CYear;:local CMonth;:local CDay;:local CToday
:global Week ($Today-$Today/7*7)
:log error ("今天: " .$Year+1 ."-". $Month+1 ."-". $Day+1 ." 星期". $Week);
/ppp secret
:foreach i in=[find comment!="" disabled=no] do={
:set Ccomment [get $i comment]
:set usname [get $i name]
:if ([:typeof [:tonum [:pick $Ccomment 0 6]]]="num" && [:typeof [:tonum [:pick $Ccomment 6 7]]]!="num") do={
:set Exp [:pick $Ccomment 0 6];:set CToday 0
:set uspfl [get $i profile];:set CYear ([:pick $Exp 0 2]-1);:set CYear ("20" . "$CYear");:set CToday ($CYear*365+$CYear /4)
:set CMonth [:pick $Exp 2 4];:if ([:pick $Exp 2 3] = 0) do={ :set CMonth [:pick $Exp 3 4]};:set CMonth ($CMonth-1)
:set CDay [:pick $Exp 4 6];:if ([:pick $Exp 4 5] = 0) do={ :set CDay [:pick $Exp 5 6]};:set CDay ($CDay-1)
:if (($CYear-$CYear/4*4) != 3) do={:set CToday ($CToday+[:pick $leapyear $CMonth]+$CDay)} else={:set CToday ($CToday+[:pick $leapyear ($CMonth+12)]+$CDay)}
:if ($CToday < $Today) do={ disable $i
:set Ccomment ( $Ccomment . " [脚本停用]" )
/ppp secret set $i comment=$Ccomment;
/ppp active remove [find name=$usname]
:log error ("已停帐号:" . $usname . ",到期时间是:" . $CYear+1 . "-" . $CMonth+1 . "-" . $CDay+1)} else={
:local lc;:local rc;
:set lc [:find $Ccomment "["]
:set rc [:find $Ccomment "]"]
:if ( ($lc<$rc)&&($rc-$lc=9)) do={:set Ccomment ( [:pick $Ccomment 0 $lc]);/ppp secret set $i comment=$Ccomment;}
:if (($CToday-5) < $Today) do={
:if ([:len $uspfl]=6) do={
:if ([:pick $uspfl 0 4]="1.8M") do={set $i remote-address=("112.9" . [:pick $uspfl 5 6] . ".16." . $ipn);:set ipn ($ipn+1)}
:if ([:pick $uspfl 0 4]="3.6M") do={set $i remote-address=("112.9" . [:pick $uspfl 5 6] . ".17." . $ipn);:set ipn ($ipn+1)}
:if ([:pick $uspfl 0 4]="5.3M") do={set $i remote-address=("112.9" . [:pick $uspfl 5 6] . ".18." . $ipn);:set ipn ($ipn+1)}}
:if ([:len $uspfl]=7) do={
:if ([:pick $uspfl 0 4]="1.8M") do={set $i remote-address=("112." . (90+[:pick $uspfl 5 7]) . ".16." . $ipn);:set ipn ($ipn+1)}
:if ([:pick $uspfl 0 4]="3.6M") do={set $i remote-address=("112." . (90+[:pick $uspfl 5 7]) . ".17." . $ipn);:set ipn ($ipn+1)}
:if ([:pick $uspfl 0 4]="5.3M") do={set $i remote-address=("112." . (90+[:pick $uspfl 5 7]) . ".18." . $ipn);:set ipn ($ipn+1)}}
/ppp active remove [find name=$usname];:log error ("用户:" . $usname . " 使用期剩余" . $CToday-$Today . "天,已通过网页提示")}
}} else={:log info ("用户:" . $usname . " 日期标记错误!")}} |
|