Peace & Protection 4.00 — File Browser

PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / INFO.MRC

INFO.MRC — 21.49 KB — Download this file

; #= P&P -rs
; ########################################
; Peace & Protection
; Bulk info- channel info, clone info, server ping, stats, etc.
; ########################################

;
; Speedy clone scan
;

; /clones [-action] [#chan] [nick|mask]
alias _cln if ($nick($1,0)) { :loop | aline @.clonedat $gettok($address($nick($1,$ifmatch),5),2-,64) | if ($calc($ifmatch - 1)) goto loop }
alias clones {
  _time1
  if ($ial == $false) _error IAL is not on!You cannot scan for clones if the IAL is off.
  _ssplit cc 20 $1-
  if ($chan(%.chan.cc).ial != $true) _error The IAL is not full yet.Wait about ten seconds and then try again.
  if ($window(@Clones)) clear @Clones
  else _window 2. -hln -t13,24 @Clones -1 -1 -1 -1 @Clones
  var %num,%mask,%chan = %.chan.cc,%targ = %.targ.cc
  if ($_ismask(%targ)) {
    _recent userscan 6 %targ
    %mask = %targ
    goto fill
  }
  elseif (%targ) {
    %mask = $address($_ncc(%targ,%chan),2)
    goto fill
  }
  window -hlns @.clonedat
  _cln %chan
  :loop2
  if ($line(@.clonedat,1)) {
    if ($ifmatch == $line(@.clonedat,2)) {
      %mask = *!*@ $+ $ifmatch
      :fill
      %num = 1
      :loop3
      if ($ialchan(%mask,%chan,%num)) {
        aline -a @Clones $replace($ifmatch,!,	,@,	)
        inc %num
        goto loop3
      }
      if (%targ) goto done
      dline @.clonedat 1- $+ $calc(%num - 1)
      aline @Clones  
    }
    else dline @.clonedat 1
    goto loop2
  }
  :done
  window -c @.clonedat

  if ($_ismask(%targ)) {
    if ($sline(@Clones,0)) titlebar @Clones ( $+ %chan $+ ) $ifmatch users matching %targ
    else {
      window -c @Clones | _dowcleanup @Clones
      disprs %chan $:cl(%chan) No users matching $:s(%targ) found on channel.
    }
  }
  elseif (%targ) {
    if ($sline(@Clones,0) > 1) titlebar @Clones ( $+ %chan $+ ) $ifmatch clones from %targ
    else {
      window -c @Clones | _dowcleanup @Clones
      disprs %chan $:cl(%chan) User $:t(%targ) does not have any clones.
    }
  }
  else {
    if ($sline(@Clones,0)) titlebar @Clones ( $+ %chan $+ ) $ifmatch clones found
    else {
      window -c @Clones | _dowcleanup @Clones
      disprs %chan $:cl(%chan) No clones found on channel.
    }
  }
  if ($window(@Clones)) {
    window -aw @Clones
    iline -a @Clones 1 Select one or more users and right-click for options.
    sline -r @Clones 1
    iline @Clones 2  
    iline @Clones 3 Nick	Userid	Hostname
    iline @Clones 4 $_ultab(4,6,9)
  }
  _time2
}

alias -l _clonepop set -u %.clonepop $iif(($sline($active,1).ln > 4) && ($numtok($sline($active,1),9) > 1),1,0)
menu @Clones {
  $_clonepop:{ }
  $iif(%.clonepop,Ping):ping $_clonesel
  $iif(%.clonepop,Whois):whois $_clonesel
  -
  $iif(%.clonepop,Warn...):_clonedo warn $_entry(0,$_s2p($_clonewarn),Warning to send?)
  -
  $iif(%.clonepop,Kick...):_clonedo kick $_rentry(kick,0,$_s2p($_clonewhy),Reason for kick?)
  $iif(%.clonepop,Cloneban...):_clonedo cb $_rentry(kick,0,$_s2p($_clonewhy),Reason for cloneban?)
  -
  Select all
  .$iif(%.clonepop,$replace($gettok($sline($active,1),2-3,9),	,@	)):_selectallw $active 5 * $+ $gettok($sline($active,1),2-3,9)
  .$iif(%.clonepop,	) $+ $iif(%.clonepop,$gettok($sline($active,1),3,9)):_selectallw $active 5 * $+ $gettok($sline($active,1),3,9)
  .-
  .	All users:_selectallw $active 5 *	*
  -
}
alias -l _clonewarn if (clone isin $gettok($window($active).title,3,32)) { if ($_dlgi(clonewarn)) return $_readprep($ifmatch) | return I have detected &num& clones from you (&host&) Please remove them at once. } | return
alias -l _clonewhy if (clone isin $gettok($window($active).title,3,32)) { if ($_dlgi(clonekick)) return $_readprep($ifmatch) | return &num& clones detected from &host& (&count&) } | return $_msg(kick)
alias -l _clonech return $right($left($gettok($window($active).title,1,32),-1),-1)
alias -l _clonedo {
  set -u %.punishwait 1
  var %host,%total,%count,%mask1,%mask2,%last,%num = 1,%chan = $_clonech
  :loop
  if ($numtok($sline($active,%num),9) == 1) goto skip
  if ($gettok($sline($active,%num),3,9) != %last) {
    %count = 1
    %last = $ifmatch
    %mask1 = *	 $+ $ifmatch
    %mask2 = *	 $+ $gettok($sline($active,%num),2-3,9)
    %total = $fline($active,%mask1,0)
    if (%total != $fline($active,%mask2,0)) %host = $replace($gettok($sline($active,%num),2-3,9),	,@)
    else %host = %last
    if ($1 == cb) cb %chan %host -1 $replace($2-,&num&,%total,&host&,%host)
  }
  else inc %count
  if ($1 == kick) kick %chan $gettok($sline($active,%num),1,9) $replace($2-,&num&,%total,&host&,%host,&count&,%count)
  if ($1 == warn) notice $gettok($sline($active,%num),1,9) $replace($2-,&num&,%total,&host&,%host,&nick&,$gettok($sline($active,%num),1,9),&chan&,%chan)
  :skip | if (%num < $sline($active,0)) { inc %num | goto loop }
  if (clone isin $gettok($window($active).title,3,32)) _dlgw $iif($1 == warn,clonewarn,clonekick) $_writeprep($2-)
}
alias -l _clonesel {
  var %all,%num = 1
  :loop
  if ($numtok($sline($active,%num),9) > 1) %all = $addtok(%all,$gettok($sline($active,%num),1,9),44)
  if (%num < $sline($active,0)) { inc %num | goto loop }
  return %all
} 

;
; Chan info
;
alias chaninfo _simsplit ci 22 $1- | %-chaninfo = %-chaninfo %.chan.ci | disprs %.chan.ci $:cl(%.chan.ci) Retrieving channel info... | .raw mode %.chan.ci | .raw topic %.chan.ci | .raw names %.chan.ci
alias count {
  _simsplit ci 30 $1-
  if (%.chan.ci !ischan) _error You are not on %.chan.ci $+ You can only /count channels you are currently on.
  disprs-div %.chan.ci
  <disp.users> %.chan.ci $nick(%.chan.ci,0) $nick(%.chan.ci,0,o) $nick(%.chan.ci,0,v,o) $nick(%.chan.ci,0,r)
}

; /scan [#chan] [[=]adhilmrsw]
alias scan {
  if (=* iswm $1) %.msg.ci = $1 | else _simsplit ci 23 $1-
  if (=* iswm %.msg.ci) { _cfgw scan.flag $right(%.msg.ci,-1) | disp Default scan flags set to $:s($right(%.msg.ci,-1)) | return }
  if (%.msg.ci == $null) {
    set %.chan.ci %.chan.ci
    _simsplit ci 23 $$dialog(scan,scan,-4)
  }
  disprs %.chan.ci $:cl(%.chan.ci) Scanning channel...
  _Q.who /_fin.scan $+ $gettok(%.msg.ci,1,32) %.chan.ci
}
alias _fin.scan {
  if ((%-dwho.num < 1) || (%-dwho.num == $null)) {
    disprs $2 $:cl($2) Scan results - No users found
    return
  }
  var %ppl,%best,%num,%where,%win,%flags = $1
  if ($remove(%flags,r,d)) {
    if (r isin %flags) { _info /scan | %win = @Info } | else %win = $2
    disprs-div %win
    disprs %win $:cl($2) Scan results for $:t(%-dwho.num) $iif(%-dwho.num == 1,user-,users-)
    if (a isin %flags) {
      %-dwho.here = %-dwho.num - %-dwho.gone
      disprs %win $:cl($2) Away- $:t(%-dwho.gone) $iif(%-dwho.gone == 1,user,users) $:s($_p(%-dwho.gone,%-dwho.num))
      disprs %win $:cl($2) Here- $:t(%-dwho.here) $iif(%-dwho.here == 1,user,users) $:s($_p(%-dwho.here,%-dwho.num))
    }
    if (w isin %flags) {
      if (%-dwho.gone == 0) {
        if (a !isin %flags) disprs %win $:cl($2) Away- None
      }
      else {
        disprs %win $:cl($2) Away- $:l(%-dwho.away)
        var %count = 1
        :loopaa
        if (%-dwho.away [ $+ [ %count ] ] ) {
          disprs %win $:cl($2) Away- $:l(%-dwho.away [ $+ [ %count ] ] )
          inc %count | goto loopaa
        }
      }
    }
    if (i isin %flags) {
      %-dwho.circop = $numtok(%-dwho.ircop,32)
      if (%-dwho.circop < 1) disprs %win $:cl($2) IRCop- None
      else {
        disprs %win $:cl($2) IRCop- $:t(%-dwho.circop) $iif(%-dwho.circop == 1,user,users) $:s($_p(%-dwho.circop,%-dwho.num))
        disprs %win $:cl($2) IRCop- $:l(%-dwho.ircop)
        var %count = 1
        :loopii
        if (%-dwho.ircop [ $+ [ %count ] ] ) {
          disprs %win $:cl($2) IRCop- $:l(%-dwho.ircop [ $+ [ %count ] ] )
          inc %count | goto loopii
        }
      }
    }
    if (h isin %flags) disprs %win $:cl($2) Hops- $:t($round($calc(%-dwho.hops / %-dwho.num),1)) avg hops among $:t($numtok(%-dwho.serv,32)) unique servers
    if ((s isin %flags) || (l isin %flags)) {
      var %count,%best = -1
      :loop0
      %num = $numtok(%-dwho.serv [ $+ [ %count ] ] ,32)
      :loop1
      var %test = $gettok(%-dwho.serv [ $+ [ %count ] ] ,%num,32)
      if ($_countseries(-dwho. [ $+ [ %test ] ] ) > %best) { %best = $ifmatch | %where = %test }
      if (%num > 1) { dec %num | goto loop1 }
      inc %count
      if (%-dwho.serv [ $+ [ %count ] ] != $null) goto loop0
      if ($_countseries(-dwho. [ $+ [ $server ] ] ) >= %best) { %best = $ifmatch | %where = $server }
      dec %best
      if ((m isin %flags) && ($me ison $2) && (%where == $server)) goto your
      _recseen serv %where
      if (s isin %flags) disprs %win $:cl($2) Favorite server- $:s(%where) with $:t(%best) $iif(%best == 1,user,users) $:s($_p(%best,%-dwho.num))
      if (l isin %flags) {
        %ppl = %-dwho. [ $+ [ %where ] ]
        %ppl = $gettok(%ppl,2-,32)
        if (s isin %flags) disprs %win $:cl($2) Favorite server- $:l(%ppl)
        else disprs %win $:cl($2) Favorite server- ( $+ $:s(%where) $+ ) $:l(%ppl)
        var %count = 1
        :loopff
        if (%-dwho. [ $+ [ %where ] $+ [ %count ] ] ) {
          disprs %win $:cl($2) Favorite server- $:l(%-dwho. [ $+ [ %where ] $+ [ %count ] ] )
          inc %count | goto loopff
        }
      }
    }
    if ((m isin %flags) && ($me ison $2)) {
      :your
      %ppl = %-dwho. [ $+ [ $server ] ]
      %ppl = $gettok(%ppl,2-,32)
      %best = $_countseries(-dwho. [ $+ [ $server ] ] ) - 1
      %num = %best - 1
      if (%where == $server) %where = Favorite server (your server)-
      else %where = Your server-
      disprs %win $:cl($2) %where $:s($server) with $:t(%best) $iif(%best == 1,user,users) $:s($_p(%best,%-dwho.num)) (not counting you- $:t(%num) $iif(%num == 1,user,users) $:s($_p(%num,%-dwho.num)) $+ )
      disprs %win $:cl($2) %where $:l(%ppl)
      var %count = 1
      :loopyy
      if (%-dwho. [ $+ [ $server ] $+ [ %count ] ] ) {
        disprs %win $:cl($2) %where $:l(%-dwho. [ $+ [ $server ] $+ [ %count ] ] )
        inc %count | goto loopyy
      }
    }
    disprs-div %win
  }
  if (d isin %flags) {
    if ($window(@ServerDetails)) clear @ServerDetails
    else _window 2.6 -l -t25,30,35,40 @ServerDetails -1 -1 -1 -1 @ServerDetails
    %num = $_countseries(-dwho.serv)
    titlebar @ServerDetails - $2 ( $+ %-dwho.num $iif(%-dwho.num == 1,user,users) / %num $iif(%num == 1,server,servers) $+ )
    var %count
    :loop2a
    var %var = -dwho.serv $+ %count,%num = $numtok(% [ $+ [ %var ] ] ,32)
    :loop2b
    %where = $gettok(% [ $+ [ %var ] ] ,%num,32)
    %ppl = %-dwho. [ $+ [ %where ] ]
    var %hops = $gettok(%ppl,1,32)
    if (%-dwho. [ $+ [ %where ] $+ [ 1 ] ] ) %ppl = (too many to show)
    else %ppl = $_s2cs($gettok(%ppl,2-,32))
    aline @ServerDetails %where $+ 	 $gettok(%ppl,1,32) 	???	 $calc($_countseries(-dwho. [ $+ [ %where ] ] ) - 1) 	 $+ %ppl
    if (%num > 1) { dec %num | goto loop2b }
    inc %count
    if (%-dwho.serv [ $+ [ %count ] ] != $null) goto loop2a
    iline @ServerDetails 1 Double-click to connect to a server, right-click for options
    iline @ServerDetails 2 ('hops' is a count of servers between you and a given server)
    iline @ServerDetails 3  
    iline @ServerDetails 4 Server	Hops	Ping	Num	People
    iline @ServerDetails 5 $_ultab(6,4,4,4,6)
    if ((%_detailsort != 1) && (%_detailsort != 4)) _servdsort 2
    else _servdsort %_detailsort
    window -b @ServerDetails
  }
  unset %-dwho.*
}

menu @ServerDetails {
  dclick:if ($1 > 5) server $gettok($line(@ServerDetails,$1),1,9) ?
  $iif($sline(@ServerDetails,1).ln > 5,Connect...):server $gettok($sline(@ServerDetails,1),1,9) ?
  -
  $iif($sline(@ServerDetails,1).ln > 5,Ping server):_sdping 1
  Ping all:_sdping 6
  -
  Sort
  .$_dynpop($iif(%_detailsort == 1,1,0)) by name:_servdsort 1
  .$_dynpop($iif(%_detailsort == 2,1,0)) by hops:_servdsort 2
  .$_dynpop($iif(%_detailsort == 3,1,0)) by ping:_servdsort 3
  .$_dynpop($iif(%_detailsort == 4,1,0)) by user count:_servdsort 4
  -
  Refresh:scan $gettok($window(@ServerDetails).title,2,32) d
}
alias _servdsort {
  %_detailsort = $1
  _dosort @ServerDetails 6 $1 $iif($1 & 1,9,32) $iif($1 < 2,0,1) $iif($1 > 3,1,0)
}
alias -l _sdping {
  var %line,%num = $1
  :loop
  if ($1 == 6) %line = $line(@ServerDetails,%num) | else %line = $sline(@ServerDetails,%num)
  if (%line) {
    _linedance .sping $gettok($ifmatch,1,9) @ServerDetails
    rline -a @ServerDetails $iif($1 == 6,%num,$sline(@ServerDetails,%num).ln) $puttok(%line,(ping...),3,9)
    inc %num | goto loop
  }
}

; /scan dialog
dialog scan {
  title "Channel Scan"
  size -1 -1 350 216

  text "&Channel to scan:", 249, 10 14 80 20
  edit "", 100, 94 10 240 22, autohs result
  edit "", 300, 1 1 1 1, hide

  box "Scan and show:", 250, 10 40 330 106

  check "&Away / here count", 1, 20 60 120 16
  check "&Who is away", 2, 20 80 120 16
  check "&IRCops", 3, 20 100 120 16
  check "Average server &hops", 4, 20 120 120 16

  check "&Favorite server", 5, 150 60 180 16
  check "&List who is on favorite server", 6, 150 80 180 16
  check "Who is on &my server", 7, 150 100 180 16
  check "Server &details (separate window)", 8, 150 120 180 16

  check "&Route to separate window", 9, 20 156 180 16

  button "&Scan", 201, 20 182 60 25, OK default
  button "S&ave as default options", 202, 100 182 140 25, disable
  button "Cancel", 203, 260 182 60 25, cancel
}
on *:DIALOG:scan:init:*:{
  var %num = 1,%flag = $_cfgi(scan.flag)
  if ($remove(%flag,r) == $null) %flag == ahi
  :loop
  if ($mid(awihslmdr,%num,1) isin %flag) did -c $dname %num
  if (%num < 9) { inc %num | goto loop }
  if (%.chan.ci != $null) did -o $dname 100 1 %.chan.ci
  unset %.chan.ci
}
alias -l _scanflag {
  var %flags,%num = 1
  :loop
  if ($did(%num).state) %flags = %flags $+ $mid(awihslmdr,%num,1)
  if (%num < 9) { inc %num | goto loop }
  return %flags
}
on *:DIALOG:scan:sclick:201:{
  if ($_ischan($did(100))) did -o $dname 100 1 $did(100) $_scanflag
  else { did -f $dname 100 | halt }
}
on *:DIALOG:scan:sclick:202:{
  var %flag = $_scanflag,%old = $did(300),%new = %old
  scan = $+ %flag
  did -b $dname 202 | did -t $dname 202 | did -ft $dname 201
  if ((%old == $null) && (%flag == awih)) inc %new
  if ((%old == 1) && (%flag == slmd)) inc %new
  if ((%old == 2) && (%flag == wilm)) {
    .timer.scam -om 0 50 _scanhide
    dialog -t $dname Channel Scam
    did -a $dname 201 Nyaa!
    var %new
  }
  did -o $dname 300 1 %new
}
on *:DIALOG:scan:sclick:*:{
  if ($remove($_scanflag,r)) did -e $dname 201,202
  else did -b $dname 201,202
}
alias -l _scanhide {
  if ($dialog(scan) == $null) { .timer.scam off | return }
  var %x = $calc($dialog(scan).x + 52 - $mouse.dx),%y = $calc($dialog(scan).y + 214 - $mouse.dy)
  if (%x == 0) %x = 1
  if (%y == 0) %y = 1
  if ((%x < 0) && ($dialog(scan).x < 0)) %x = 1
  if ((%y < 0) && ($dialog(scan).y < 0)) %y = 1
  if ((%x > 0) && ($calc($dialog(scan).x + $dialog(scan).w) > $window(-1).w)) %x = -1
  if ((%y > 0) && ($calc($dialog(scan).y + $dialog(scan).h) > $window(-1).h)) %y = -1
  if (($abs(%x) < 80) && ($abs(%y) < 50)) {
    if (%x > 0) { %x = $calc((80 - %x) / 3) | if (%x < 0) %x = 0 | if (%x < -5) %x = -5 }
    else { %x = $calc((-80 - %x) / 3) | if (%x > 0) %x = 0 | if (%x > 5) %x = 5 }
    if (%y > 0) { %y = $calc((50 - %y) / 3) | if (%y < 0) %y = 0 | if (%y < -5) %y = -5 }
    else { %y = $calc((-50 - %y) / 3) | if (%y > 0) %y = 0 | if (%y > 5) %y = 5 }
    dialog -s scan $calc(%x + $dialog(scan).x) $calc(%y + $dialog(scan).y) 350 216
  }
}

; /sping nick|server
;;; multiple nicks or other no such user causes problems
alias _dosping sping %-mwho.nick %-mwho.serv | unset %-mwho.*
alias sping {
  if ($1 == $null) _qhelp /sping
  if (. !isin $1) {
    if ($2 == $null) {
      var %target = $_nc($1)
      disps $:n(%target) Looking up server of user...
      _Q.whois %target _dosping
      return
    }
    if (* isin $2) %-servmask = %-servmask $2
    %-servping. [ $+ [ $2 ] ] = $ticks $1
    .raw time $2
    disps $:n($1) Pinging server $:s($2)
    return
  }
  if (* isin $1) %-servmask = %-servmask $1
  %-servping. [ $+ [ $1 ] ] = $ticks $2
  .raw time $1
  disps Pinging server $:s($1)
}

;
; Port scan
;

alias ports .enable #-portscan | _dowclose @Ports | window -c @Ports | .raw stats l

#-portscan off

raw &211:*:{
  if (($2 !isnum) && ($3 !isnum)) halt
  if (($window(@Ports) == $null) || ($gettok($line(@Ports,1),1,32) == Found)) {
    %_port.serv = $nick
    unset %_port.speed
    if ($window(@Ports)) clear @Ports
    else _window 2.6 -lk -t16,22+l @Ports $_center(350,350) @Ports
    titlebar @Ports for $nick (currently on $iif($server == $nick,$port,another server) $+ )
  }
  elseif (%_port.serv != $nick) halt
  if ($nick !isin $2) halt
  var %mask = $remove($gettok($2,2,91),])
  if (%mask == $null) %mask = *.6667
  var %port = $gettok(%mask,$numtok(%mask,46),46)
  if ((%port !isnum) || (%port < 256)) halt
  if (($nick == $server) && (%port == $port)) goto okay
  if ($remove(%mask,%port,.,!,@,*,?,-,[,],unknown) != $null) halt
  if ((%_port.speed > 1000) && ($5 < 10)) halt
  :okay
  var %switch,%speed = $5 + $7
  if ((%speed < %_port.speed) || (%_port.speed == $null)) { %_port.speed = %speed | %switch = -s }
  var %num = 1
  if (%_portsort == 0) {
    :loop0
    if ((%num <= $line(@Ports,0)) && ($strip($remove($gettok($line(@Ports,%num),2,32),[,])) < %port)) { inc %num | goto loop0 }
  }
  else {
    :loop1
    if ((%num <= $line(@Ports,0)) && ($strip($gettok($gettok($line(@Ports,%num),4,32),1,107)) < $calc(%speed / $8))) { inc %num | goto loop1 }
  }
  %port = [[ $+ %port $+ ]]
  var %ks =  $+ $round($calc(%speed / $8),2)
  iline %switch @Ports %num Port $:t(%port) >> $+ $_p2s($:s(%ks)) $+ k/s	 	( $+ $:s($round($calc(%speed / 1024),0)) $+ mb total traffic)
  halt
}
raw 219:*:{
  if (($window(@Ports)) && ($nick == %_port.serv)) {
    iline @Ports 1 Found $:t($line(@Ports,0)) active ports on $nick
    iline @Ports 2 Currently sorted by $iif(%_portsort == 0,port number,speed (fastest ports first))
    iline @Ports 3 Double click to connect to a port, right-click for options
    iline @Ports 4 (note- 'total traffic' is measured over entire uptime of port)
    iline @Ports 5  
    if ($sline(@Ports,1).ln) rline -s @Ports $ifmatch $puttok($sline(@Ports,1),$:b((fastest)),2,9)
    unset %_port.serv %_port.speed
    .disable #-portscan
    halt
  }
}

#-portscan end

on 1:DISCONNECT:if ($window(@ports)) titlebar @Ports $gettok($window(@ports).titlebar,1-2,32)
on 1:CONNECT:{
  if ($window(@ports)) {
    if ($server == $gettok($window(@ports).titlebar,2,32)) titlebar @Ports for $gettok($window(@ports).titlebar,2,32) (currently on $port $+ )
    else titlebar @Ports for $gettok($window(@ports).titlebar,2,32) (currently on another server)
  }
}

menu @Ports {
  dclick:if ($1 < 6) halt | server $gettok($window(@ports).titlebar,2,32) $remove($strip($gettok($line(@Ports,$1),2,32)),[,])
  Connect to port:if ($sline(@Ports,1).ln < 6) halt | server $gettok($window(@ports).titlebar,2,32) $remove($strip($gettok($sline(@Ports,1),2,32)),[,])
  -
  $iif(%_portsort == 0,Sort by speed):{
    _dosort @Ports 6 4 32 1 0
    %_portsort = 1
    rline @Ports 2 Currently sorted by speed (fastest ports first)
  }
  $iif(%_portsort != 0,Sort by port number):{
    _dosort @Ports 6 2 91 1 0
    %_portsort = 0
    rline @Ports 2 Currently sorted by port number
  }
  Get new list:ports
}

;
; Nearby servers
;
#-nearserv off
raw 364:*:{
  if (($4 >= %-ns.min) && ($4 <= %-ns.max)) {
    disp $:+ $:s($2) ( $+ $4 hops)
    %_ns.found = %_ns.found $2
  }
  halt
}
raw 365:*:{
  .disable #-nearserv
  if (%_ns.found) {
    _Q.fkey 1 $calc($ctime + 300) _randserv %_ns.found
    disp Found $:t($numtok(%_ns.found,32)) servers. Press $:s($result) to select one randomly.
    unset %_ns.found
  }
  else disp No servers found in this range.
  halt
}
#-nearserv end
alias _randserv server $gettok($1-,$_pprand($numtok($1-,32)),32) ?

dialog nearserv {
  title "Nearby Servers"
  size -1 -1 176 114

  text "List servers that are-", 1, 10 10 100 20

  text "At least", 2, 10 32 66 20, right
  edit "1", 3, 80 28 25 22, autohs result
  text "hop(s) away", 4, 108 32 60 20

  text "No more than", 5, 10 54 66 20, right
  edit "", 6, 80 50 25 22
  text "hop(s) away", 7, 108 54 60 20

  button "OK", 101, 30 80 55 25, OK default
  button "Cancel", 102, 96 80 55 25, cancel
}
on *:DIALOG:nearserv:sclick:101:did -o $dname 3 1 $gettok($did(3),1,32) $gettok($iif($did(6),$did(6),+),1,32)

alias nearserv {
  var %min = 1,%max = 2
  if ($1 == ?) {
    %min = $$dialog(nearserv,nearserv,-4)
    %max = $gettok(%min,2,32)
    %min = $gettok(%min,1,32)
  }
  elseif ($1) { %min = $1 | %max = $iif($2,$2,$1) }
  if (%max == +) %max = 99
  if (%min !isnum) %min = 1
  if (%max !isnum) %max = 2
  if (%min > %max) { var %tmp = %min | %min = %max | %max = %tmp }
  if (%min == %max) disp Nearby servers- (exactly $:t(%max) $iif(%max == 1,hop,hops) away)
  elseif (%max >= 99) disp Nearby servers- ( $+ $:t(%min) or more hops away)
  elseif (%min == 1) disp Nearby servers- (up to $:t(%max) hops away)
  else disp Nearby servers- ( $+ $:t(%min) to $:t(%max) $iif(%max == 1,hop,hops) away)
  links | .enable #-nearserv | unset %_ns.found
  %-ns.min = %min | %-ns.max = %max
}

alias stats {
  if ($1) var %stats = $1-
  else var %stats = $_entry(-1,$null,Server stats to request?(Enter a single lowercase or uppercase letter.))
  stats %stats
  if ((%stats !isincs gkmou) && ($len(%stats) == 1) && (%stats isletter)) _recent stats 3 %stats
}