. */ session_start(); // hide all error error_reporting(0); if (!isset($_SESSION["mikhmon"])) { header("Location:../admin.php?id=login"); } else { $getallqueue = $API->comm("/queue/simple/print", array( "?dynamic" => "false", )); $getpool = $API->comm("/ip/pool/print"); if (isset($_POST['name'])) { $name = (preg_replace('/\s+/', '-',$_POST['name'])); $sharedusers = ($_POST['sharedusers']); $ratelimit = ($_POST['ratelimit']); $expmode = ($_POST['expmode']); $validity = ($_POST['validity']); $graceperiod = ($_POST['graceperiod']); $getprice = ($_POST['price']); $getsprice = ($_POST['sprice']); $addrpool = ($_POST['ppool']); if ($getprice == "") { $price = "0"; } else { $price = $getprice; } if ($getsprice == "") { $sprice = "0"; } else { $sprice = $getsprice; } $getlock = ($_POST['lockunlock']); if ($getlock == "Enable") { $lock = '; [:local mac $"mac-address"; /ip hotspot user set mac-address=$mac [find where name=$user]]'; } else { $lock = ""; } $randstarttime = "0".rand(1,5).":".rand(10,59).":".rand(10,59); $randinterval = "00:02:".rand(10,59); $parent = ($_POST['parent']); $record = '; :local mac $"mac-address"; :local time [/system clock get time ]; /system script add name="$date-|-$time-|-$user-|-'.$price.'-|-$address-|-$mac-|-' . $validity . '-|-'.$name.'-|-$comment" owner="$month$year" source=$date comment=mikhmon'; $onlogin = ':put (",'.$expmode.',' . $price . ',' . $validity . ','.$sprice.',,' . $getlock . ',"); {:local date [ /system clock get date ];:local year [ :pick $date 7 11 ];:local month [ :pick $date 0 3 ];:local comment [ /ip hotspot user get [/ip hotspot user find where name="$user"] comment]; :local ucode [:pic $comment 0 2]; :if ($ucode = "vc" or $ucode = "up" or $comment = "") do={ /sys sch add name="$user" disable=no start-date=$date interval="' . $validity . '"; :delay 2s; :local exp [ /sys sch get [ /sys sch find where name="$user" ] next-run]; :local getxp [len $exp]; :if ($getxp = 15) do={ :local d [:pic $exp 0 6]; :local t [:pic $exp 7 16]; :local s ("/"); :local exp ("$d$s$year $t"); /ip hotspot user set comment=$exp [find where name="$user"];}; :if ($getxp = 8) do={ /ip hotspot user set comment="$date $exp" [find where name="$user"];}; :if ($getxp > 15) do={ /ip hotspot user set comment=$exp [find where name="$user"];}; /sys sch remove [find where name="$user"]'; if ($expmode == "rem") { $onlogin = $onlogin . $lock . "}}"; $mode = "remove"; } elseif ($expmode == "ntf") { $onlogin = $onlogin . $lock . "}}"; $mode = "set limit-uptime=1s"; } elseif ($expmode == "remc") { $onlogin = $onlogin . $record . $lock . "}}"; $mode = "remove"; } elseif ($expmode == "ntfc") { $onlogin = $onlogin . $record . $lock . "}}"; $mode = "set limit-uptime=1s"; } elseif ($expmode == "0" && $price != "") { $onlogin = ':put (",,' . $price . ',,,noexp,' . $getlock . ',")' . $lock; } else { $onlogin = ""; } $bgservice = ':local dateint do={:local montharray ( "jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec" );:local days [ :pick $d 4 6 ];:local month [ :pick $d 0 3 ];:local year [ :pick $d 7 11 ];:local monthint ([ :find $montharray $month]);:local month ($monthint + 1);:if ( [len $month] = 1) do={:local zero ("0");:return [:tonum ("$year$zero$month$days")];} else={: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 [ /ip hotspot user find where profile="'.$name.'" ] do={ :local comment [ /ip hotspot user get $i comment]; :local name [ /ip hotspot user get $i name]; :local gettime [:pic $comment 12 20]; :if ([:pic $comment 3] = "/" and [:pic $comment 6] = "/") do={:local expd [$dateint d=$comment] ; :local expt [$timeint t=$gettime] ; :if (($expd < $today and $expt < $curtime) or ($expd < $today and $expt > $curtime) or ($expd = $today and $expt < $curtime)) do={ [ /ip hotspot user '.$mode.' $i ]; [ /ip hotspot active remove [find where user=$name] ];}}}'; $API->comm("/ip/hotspot/user/profile/add", array( /*"add-mac-cookie" => "yes",*/ "name" => "$name", "address-pool" => "$addrpool", "rate-limit" => "$ratelimit", "shared-users" => "$sharedusers", "status-autorefresh" => "1m", //"transparent-proxy" => "yes", "on-login" => "$onlogin", "parent-queue" => "$parent", )); if($expmode != "0"){ if (empty($monid)){ $API->comm("/system/scheduler/add", array( "name" => "$name", "start-time" => "$randstarttime", "interval" => "$randinterval", "on-event" => "$bgservice", "disabled" => "no", "comment" => "Monitor Profile $name", )); }else{ $API->comm("/system/scheduler/set", array( ".id" => "$monid", "name" => "$name", "start-time" => "$randstarttime", "interval" => "$randinterval", "on-event" => "$bgservice", "disabled" => "no", "comment" => "Monitor Profile $name", )); }}else{ $API->comm("/system/scheduler/remove", array( ".id" => "$monid")); } $getprofile = $API->comm("/ip/hotspot/user/profile/print", array( "?name" => "$name", )); $pid = $getprofile[0]['.id']; echo ""; } } ?>

Address Pool
Shared Users
Rate limit [up/down]
Parent Queue