Kau bisa bersembunyi dari kesalahanmu, tapi tidak dari penyesalanmu. Kau bisa bermain dengan dramamu, tapi tidak dengan karmamu.

  • About

    Seorang Teknisi Jaringan yang pernah berkecimpung di Internet Service Provider (ISP) dan akhirnya memutuskan diri untuk menjadi freelancer yang berdomisili di Solo, Surakarta Hadiningrat.

  • Services

    Melayani jasa pasang Internet berbasis Wireless maupun Fiber Optic, Jasa Pasang Tower/Pipa, Pointing Wireless, Setting Router, CCTV, Hotspot, Proxy, Web Server, Network Managed dan Monitoring

  • Contact

    Berbagai saran, kritikan, keluhan dan masukan akan sangat berarti bagi saya. Anda dapat menghubungi/whatsapp saya di nomor:08564-212-8686 atau melalui BBM:2128686

    Tuesday, August 27, 2019


    on-up
    ====

    :local remote
    :set remote $"remote-address"
    :log warning ("wellcome ppp-$user ( $remote )")
    :if ( [ /ppp secret get "$user" comment ] = "" ) do={
    :local month
    :local year
    :local yeardiv
    :local yearmult
    :local leapyear
    :local lastday
    :local date [ /system clock get date ]
    :local time [ /system clock get time ]
    # ambil nama bulan dan tahun dari date
    :set month [:pick $date 0 3]
    :set year [:pick $date 7 11]
    # check tahun kabisat atau bukan
    :set yeardiv ($year / 4)
    :set yearmult ($yeardiv * 4)
    :if ([$yearmult] = $year) do={ :set leapyear true } else={ :set leapyear false }
    # set nilai lastday sesuai nama bulan dan tahun
    :if ([$month] = "jan") do={ :set lastday 31d }
    :if ([$month] = "feb") do={
    :if ($leapyear = true) do={ :set lastday 29d }
    :if ($leapyear = false) do={ :set lastday 28d }
    }
    :if ([$month] = "mar") do={ :set lastday 31d }
    :if ([$month] = "apr") do={ :set lastday 30d }
    :if ([$month] = "may") do={ :set lastday 31d }
    :if ([$month] = "jun") do={ :set lastday 30d }
    :if ([$month] = "jul") do={ :set lastday 31d }
    :if ([$month] = "aug") do={ :set lastday 31d }
    :if ([$month] = "sep") do={ :set lastday 30d }
    :if ([$month] = "oct") do={ :set lastday 31d }
    :if ([$month] = "nov") do={ :set lastday 30d }
    :if ([$month] = "dec") do={ :set lastday 31d }
    # cek nilai lastday
    #:log info ("$lastday")
    /ppp secret set $user comment="$date $time"
    /system scheduler remove [find name="ppp-$user"]
    /system scheduler add interval=$lastday name="ppp-$user" on-event="/ppp active remove [find user=\"$user\"]\r\n/ppp secret disable [find name=\"$user\"]\r\n/system scheduler remove [find name=\"ppp-$user\"]" start-date=$date start-time=$time
    } else={
    :local zoky [ /ppp secret get "$user" comment ]
    :local zoky1 " $zoky"
    :local zoky2
    :for i from=0 to=([:len $zoky1] - 1) do={
    :local char [:pick $zoky1 $i]
    :if ($char = " ") do={
    :set $char "\\ "
    }
    :set zoky2 ($zoky2 . $char)
    }
    :local var $zoky2
    :local myArray [:toarray [:pick $var ([:find $var " "]+1) [:len $var]]]
    :local month
    :local year
    :local yeardiv
    :local yearmult
    :local leapyear
    :local lastday
    :local comdate [:pick $myArray 0]
    :local comtime [:pick $myArray 1]
    # ambil nama bulan dan tahun dari comdate
    :set month [:pick $comdate 0 3]
    :set year [:pick $comdate 7 11]
    # check tahun kabisat atau bukan
    :set yeardiv ($year / 4)
    :set yearmult ($yeardiv * 4)
    :if ([$yearmult] = $year) do={ :set leapyear true } else={ :set leapyear false }
    # set nilai lastday sesuai nama bulan dan tahun
    :if ([$month] = "jan") do={ :set lastday 31d }
    :if ([$month] = "feb") do={
    :if ($leapyear = true) do={ :set lastday 29d }
    :if ($leapyear = false) do={ :set lastday 28d }
    }
    :if ([$month] = "mar") do={ :set lastday 31d }
    :if ([$month] = "apr") do={ :set lastday 30d }
    :if ([$month] = "may") do={ :set lastday 31d }
    :if ([$month] = "jun") do={ :set lastday 30d }
    :if ([$month] = "jul") do={ :set lastday 31d }
    :if ([$month] = "aug") do={ :set lastday 31d }
    :if ([$month] = "sep") do={ :set lastday 30d }
    :if ([$month] = "oct") do={ :set lastday 31d }
    :if ([$month] = "nov") do={ :set lastday 30d }
    :if ([$month] = "dec") do={ :set lastday 31d }
    # cek nilai lastday
    #:log info ("$lastday")
    /system scheduler remove [find name="ppp-$user"]
    /system scheduler add interval=$lastday name="ppp-$user" on-event="/ppp active remove [find user=\"$user\"]\r\n/ppp secret disable [find name=\"$user\"]\r\n/system scheduler remove [find name=\"ppp-$user\"]" start-date=$comdate start-time=$comtime
    } :local profile [/ppp secret get [find name="$user"] profile]
    :local rateLimit [/ppp profile get [find name="$profile"] rate-limit]
    :local parent [/ppp profile get [find name="$profile"] parent]
    :local queue [/ppp profile get [find name="$profile"] queue]
    /queue simple remove [find name="$user-$remote"]
    /queue simple add max-limit="$rateLimit" name="$user-$remote" parent="$parent" queue="$queue/$queue" target="$remote"
    /queue simple remove [find where name~"-$user"]


    on-down
    ======
    :local remote
    :set remote $"remote-address"
    :log warning ("goodbye $user ( $remote )")
    :local bytes [/queue simple get [find name="$user-$remote"] bytes]
    :local totalbytes
    :local arraybytes [:toarray [:pick $bytes ([:find $bytes "/"]+1) [:len $bytes]]]
    :local upbytes [:pick $arraybytes 0]
    :local downbytes [:pick $arraybytes 1]
    :set totalbytes ($upbytes+$downbytes)
    :local zoky [/ppp secret get "$user" comment]
    :local zoky1 " $zoky"
    :local zoky2
    :for i from=0 to=([:len $zoky1] - 1) do={
    :local char [:pick $zoky1 $i]
    :if ($char = " ") do={
    :set $char "\\ "
    }
    :set zoky2 ($zoky2 . $char)
    }
    :local commentppp $zoky2
    :local arraycomment [:toarray [:pick $commentppp ([:find $commentppp " "]+1) [:len $commentppp]]]
    :local comdate [:pick $arraycomment 0]
    :local comtime [:pick $arraycomment 1]
    :local combytes [:pick $arraycomment 2]
    :if ($combytes = "") do={
    /ppp secret set "$user" comment="$comdate $comtime $totalbytes"
    } else={
    :local alltotalbytes
    :set alltotalbytes ($combytes+$totalbytes)
    /ppp secret set "$user" comment="$comdate $comtime $alltotalbytes"
    }
    /queue simple remove [find name="$user-$remote"]
    note
    ===
    profile harap di set max-limit, parent dan queue-typenya
    bikin scheduler di run perjam atau terserah anda intervalnya
    untuk update counter usagenya
    :local userppp
    :local usersimple
    :foreach i in=[/ppp secret find] do {
    :set userppp ( userppp [/ppp secret get $i name])
    :local zoky [/ppp secret get "$userppp" comment]
    :local zoky1 " $zoky"
    :local zoky2
    :for i from=0 to=([:len $zoky1] - 1) do={
    :local char [:pick $zoky1 $i]
    :if ($char = " ") do={
    :set $char "\\ "
    }
    :set zoky2 ($zoky2 . $char)
    }
    :local commentppp $zoky2
    :local arraycomment [:toarray [:pick $commentppp ([:find $commentppp " "]+1) [:len $commentppp]]]
    :local comdate [:pick $arraycomment 0]
    :local comtime [:pick $arraycomment 1]
    :local combytes [:pick $arraycomment 2]
    :if ([/ppp secret get [/ppp secret find name="$userppp"] profile] != "") do {
    :foreach j in=[/queue simple find where name~"$userppp"] do {
    :set usersimple ( usersimple [/queue simple get $j name])
    :local bytes [/queue simple get [/queue simple find name="$usersimple"] bytes]
    :local totalbytes
    :local arraybytes [:toarray [:pick $bytes ([:find $bytes "/"]+1) [:len $bytes]]]
    :local upbytes [:pick $arraybytes 0]
    :local downbytes [:pick $arraybytes 1]
    :set totalbytes ($upbytes+$downbytes)
    :if ($combytes < 0) do {
    :local alltotalbytes
    :if (($comtime < 0)&&($combytes < 0)) do {
    :set alltotalbytes ($comdate+$totalbytes)
    /ppp secret set "$userppp" comment="$alltotalbytes"
    } else {
    :set alltotalbytes ($combytes+$totalbytes)
    /ppp secret set "$userppp" comment="$comdate $comtime $alltotalbytes"
    }
    #:log warning "$userppp $comdate $comtime $combytes $usersimple $totalbytes $alltotalbytes"
    } else {
    :if ($totalbytes = $totalbytes) do {
    #:log warning "no update usage ppp"
    } else {
    :local alltotalbytes
    :if (($comtime < 0)&&($combytes < 0)) do {
    :set alltotalbytes ($comdate+$totalbytes)
    /ppp secret set "$userppp" comment="$alltotalbytes"
    } else {
    :set alltotalbytes ($combytes+$totalbytes)
    /ppp secret set "$userppp" comment="$comdate $comtime $alltotalbytes"
    }
    #:log warning "$userppp $comdate $comtime $combytes $usersimple $totalbytes $alltotalbytes"
    }
    }
    }
    }
    }

    credits : zoky raharjo (fb) 

    0 comments:

    Post a Comment