xServ+ — File Browser

xServv3.2 / xServv3.2 / xserv / xserv.mrc

xserv.mrc — 173.44 KB — Download this file

; xServ+ 3.2
; 1044682582
; ^--< DO NOT EDIT OR REMOVE ANYTHING OR XSERV WILL NOT WORK >--^
; ---< Credits >---
; Written by David Cramer (zeeg)
; Tested and Rated by many people, a few include, stylee311, piglywigly, >> hemmy <<, |Neptune|, Z2000, and others
; If it wasn't for them this woulda taken forever.
; ---< Contact Information >---
; IRC: irc.evilcoder.net, #evilcoder (I'm zeeg)
; MSN: ZeeG_IRC@hotmail.com
; AIM: CrmrDvd
; ICQ: 155412574
; Email: zeeg@evilcoder.net                
; ---< Other Information >---
; Want more features, WELL TALK TO ME, it'll get added, I guarantee it.
; dialog tables generated by Dialog Studio

on *:start:{
  set %!xserv.ticks $ticks
  echo -it2a $xserv.prefix Startup beginning..
  set %~xserv.uptime $ctime
  xserv.mkdirs
  qstart
  xserv.loadt
  xserv.kvars 
  $iif($isfile($xserv.queuefile),.remove $xserv.queuefile)
  if (!%xstring) { set %xstring default }
  if ($hget(xserv.styles)) { hfree xserv.styles }
  hmake xserv.styles
  hload -b xserv.styles $xserv.sldir(%xstring)
  xserv.ads -start
  xtdcc.ads -start
  xdcc.adstart
  xftp.ads -start
  if ($xcfg(@find,onstartup) = 1 && $xcfg(@find,status) = 1) xfind.index
  cachestyles
  echo -i2ta $xserv.prefix Styles cached..
  echo -i2ta $xserv.prefix Startup completed in $round($calc(($ticks - %!xserv.ticks) / 1000),3) $+ s
  qstart
  xupd.chkh
}
alias xserv.rstats {
  var %a = $hget(xserv.top,$replace($1-,$chr(32),$chr(44)))
  return $iif(%a > 0,%a,0)
}
alias xserv.wstats {
  hadd -m xserv.top $replace($1-,$chr(32),$chr(44)) $calc($xserv.rstats($1-) + 1)
}
alias xserv.settop {
  var %a = 0, %b = 1, %c
  while (%a < $hget(xserv.top,0).item) {
    inc %a
    if (!%c) { %c = $hget(xserv.top,%a).item).item }
    elseif ($hget(xserv.top,$hget(xserv.top,%a).item) > $hget(xserv.top,%c)) { %c = $hget(xserv.top,%a).item }
  }
  if ($isid) { return Top Download: $nopath($replace(%c,$chr(44),$chr(32))) $+($chr(40),,$hget(xserv.top,%c) download,$iif($hget(xserv.top,%c) != 1,$+(s,)),$chr(41)) }
  set %~xserv.top %c
}
alias xserv.frmt {
  if ($1 = fserv.list) {
    var %a = $iif($hget($+(xstyle:,$replace($readini($xconf,!list,fserv),$chr(32),<space>)),fserv:!list),$ifmatch,[File Server] Active Triggers: <triggers>)
    return %a
  }
  elseif ($1 = tdcc.list) {
    var %a = $iif($hget($+(xstyle:,$replace($readini($xconf,!list,tdcc),$chr(32),<space>)),tdcc:!list),$ifmatch,[TDCC Server] Active Triggers: <triggers>)
    return %a
  }
  elseif ($1 = full_queues) {
    var %a = $iif($hget(xserv.styles,error.full_queues),$ifmatch,There are too many sends in progress and all the queue slots have been taken.)
    return %a
  }
  elseif ($1 = full_sends) {
    var %a = $iif($hget(xserv.styles,error.full_sends),$ifmatch,There are too many sends in progress. You have been added to queue slot $+($2,.))
    return $replace(%a,<queue_num>,$2)
  }
  elseif ($1 = full_users) {
    var %a = $iif($hget(xserv.styles,error.full_users),$ifmatch,The fileserver is currently full.)
    return %a
  }
  elseif ($1 = server_offline) {
    var %a = $iif($hget(xserv.styles,error.server_offline),$ifmatch,This fileserver has been shutdown)
    return %a
  }
  elseif ($1 = clones) {
    var %a = $iif($hget(xserv.styles,error.clones),$ifmatch,I do not allow clones on my file server.)
    return %a
  }
  elseif ($1 = restricted) {
    var %a = $iif($hget(xserv.styles,error.restricted),$ifmatch,Only voiced (+) and opped (@) users may access my file server.)
    return %a
  }
}
alias xserv.clones {
  var %a = 0
  while (%a < $fserv(0)) {
    inc %a
    if ($address($fserv(%a),2) = $address($1,2)) { return $true }
  }
  return $false
}
ctcp *:*:*:{
  if ($1 = XDCC && $target) {
    if ($2 = LIST) {
      var %a = 0
      while (%a < $lines($xdcc.pdir)) {
        inc %a
        .msg $nick $$xdcc.disp(%a,$xdcc.style(list1)).long
      }
      .msg $nick $xdcc.disp($1-,$xdcc.style(mid1))
    }
    elseif ($2 = SEND && $right($3,-1) isnum) {
      writeini $xdcc.sdir stats $right($3,-1) $iif($calc($readini($xdcc.sdir,stats,$right($3,-1)) + 1) > 0,$ifmatch,1)
      var %file = $gettok($read($xdcc.pdir,$right($3,-1)),1,127)
      if (!$isfile(" $+ %file $+ ")) { .msg $nick No such package | return }
      elseif ($send(0) >= $xcfg(sends,totalmax) || $send($nick,0) >= $xcfg(sends,usermax)) {
        if ($queue(0) >= $xcfg(queues,totalmax) || $queue($nick,0) >= $xcfg(queues,usermax)) {
          .notice $nick $xserv.frmt(full_queues)
        }
        else {
          var %a = 0
          while (%a < $queue($nick,0)) {
            inc %a
            if ($queue($nick,%a).file = %file) { .notice $nick You are already waiting for this file in the queue. | return }
          }
          set %~xserv. [ $+ [ $nick ] ] $cid
          queue add $cid $nick %file
          .notice $nick $xserv.frmt(full_sends,$queue(0))
        }
      }
      else {
        set %xresend. [ $+ [ $nick ] ] %file
        xsend -bypass $nick " $+ %file $+ "
        window -n $+(",Send $nick $nopath(%file),")
      }
    }
    halt
  }
  elseif ($istrig($1-) == tdcc:ctcp && $target) {
    if ($isban($fulladdress)) return
    elseif ($readini($xtdcc.gdir($1-),main,status) = 1) {
      var %file = $xtdcc.file($1-)
      writeini $xtdcc.gdir($1-) main hits $calc($readini($xtdcc.gdir($1-),main,hits) + 1)
      if (!$isfile(" $+ %file $+ ")) { return }
      elseif ($send(0) >= $xcfg(sends,totalmax) || $send($nick,0) >= $xcfg(sends,usermax)) {
        if ($queue(0) >= $xcfg(queues,totalmax) || $queue($nick,0) >= $xcfg(queues,usermax)) {
          .notice $nick There are too many sends in progress, and $iif($queue(0) >= $xcfg(queues,totalmax),all the queue slots have been taken...,you have used all of your queue slots..)
        }
        else {
          var %a = 0
          while (%a < $queue($nick,0)) {
            inc %a
            if ($queue($nick,%a).file = %file) { .notice $nick You are already waiting for this file in the queue. | return }
          }
          set %~xserv. [ $+ [ $nick ] ] $cid
          queue add $cid $nick %file
          .notice $nick $xserv.frmt(full_sends,$queue(0))
        }
      }
      else {
        set %xresend. [ $+ [ $nick ] ] %file
        xsend -bypass $nick " $+ %file $+ "
        window -n $+(",Send $nick $nopath(%file),")
      }
    }
  }
  elseif ($istrig($1-) == ctcp && $target) {
    if ($isban($fulladdress)) return
    elseif ($xtrigs = <none> || !$xtrigs) { .notice $nick $xserv.frmt(server_offline) }
    elseif ($fserv(0) >= $xcfg(users,totalmax)) { .notice $nick $xserv.fmrt(full_users) }
    elseif ($xserv.clones($nick)) { .notice $nick $xserv.frmt(clones) }
    elseif (!$xstat($1-) || $isdir($xdir($1-)) = $false || !$xdir($1-)) { .notice $nick That file server is not active.. }
    ;elseif (!%true) { return }
    ;elseif ($xfile($1-,serv+@) = 1 && !%serv) { .notice $nick $xserv.frmt(restricted) | return }
    else { set %xserv. [ $+ [ $nick ] ] $1- | xset main access $calc($iif($xcfg(main,access) < 0 || $xcfg(main,access) = <none>,0,$xcfg(main,access)) + 1) | xfserve $server $nick 999 " $+ $xdir($1-) $+ " $iif($xfile($1-,showmotd) = 1 && $isfile($+(",$xfile($1-,motd),")),$+(",$xfile($1-,motd),")) }
    return
    halt
  }
  elseif ($1 = $decrypt(eHZlcg==)) { .ctcpreply $nick $decrypt(eHZlcg==) $xinfo | haltdef | return }
  elseif ($1 = xresend && $target) {
    if (%xresend. [ $+ [ $nick ] ]) {
      haltdef
      var %file = %xresend. [ $+ [ $nick ] ]
      if ($send(0) >= $xcfg(sends,totalmax) || $send($nick,0) >= $xcfg(sends,usermax)) {
        if ($queue(0) >= $xcfg(queues,totalmax) || $queue($nick,0) >= $xcfg(queues,usermax)) {
          $iif($fserv($nick),.msg =$nick,.notice $nick) $xserv.frmt(full_queues)
        }
        else {
          queue add $cid $nick %file
          $iif($fserv($nick),.msg =$nick,.notice $nick) $xserv.frmt(full_sends,$queue(0))
          echo $colour(info) -sti2 $xserv.prefix Requeueing %file to $nick by xResend request
        }
      }
      else {
        set %xresend. [ $+ [ $nick ] ] %file
        xsend $nick " $+ %file $+ "
        window -n $+(",Send $nick $nopath(%file),")
        echo $colour(info) -sti2 $xserv.prefix Resending %file to $nick by xResend request
        $iif($fserv($nick),.msg =$nick,.notice $nick) Sending file..
      }
    }
    halt
  }
}
alias xbuild { return $gettok($read($script,1),3,32) }
alias xserv.uptime { return $xserv.dur($calc($ctime - %~xserv.uptime)) }
alias xserv.dur { return $replace($duration($1-),secs,s,sec,s,mins,m,min,m,hours,h,hour,h,days,d,day,d,wks,w,wk,w) }
alias addstyle {
  if ($hget(xserv.tmp)) { hfree xserv.tmp } | hmake xserv.tmp
  hadd xserv.tmp Author $iif($me,$me,N/A)
  hadd xserv.tmp Name $$1
  hadd xserv.tmp Website N/A
  hadd xserv.tmp Email $emailaddr
  hadd xserv.tmp Version 1.0
  if ($2 = -ad) {
    hadd xserv.tmp ad $3-
  }
  hsave -bo xserv.tmp $xserv.sldir($replace($1,$chr(32),_))
}
on *:serv:*:{
  ;if (%xserv.lcmd. [ $+ [ $nick ] ] = $1) { inc %xserv.lcmdfld. [ $+ [ $nick ] ] }
  ;if (%xserv.lcmdfld. [ $+ [ $nick ] ] > 10) { unset %xserv.lcmdfld. [ $+ [ $nick ] ] | close -f $nick }
  ;set -u50 %xserv.lcmd. [ $+ [ $nick ] ] $1
  if ($1 = c || $1 = s) { return }
  if ($1 = rules) {
    if ($xfile(%xserv. [ $+ [ $nick ] ],showrules) = 1) {
      var %file $+(",$xfile(%xserv. [ $+ [ $nick ] ],rules),")
      if (%file = "PRESET: Pirated Software") { %file = $+(",$xserv.dir,rules\,pirated_software.txt") | if (!$isfile(%file)) { createrules pirated_software } }
      .play =$nick %file
    }
    else { .msg =$nick There aren't any rules set =) }
    unset %xrules. [ $+ [ $nick ] ]
    haltdef | return
  }
  elseif (%xrules. [ $+ [ $nick ] ]) { .msg =$nick There have been RULES set for this server, please read them before you continue (e.g. type rules) | haltdef | return }
  elseif ($1 = help) {
    if ($2 = cd) { .msg =$nick cd <directory> - change to the specified directory }
    elseif ($2 = dir) { .msg =$nick dir [-b|k] [-#] [/w] - lists the name and size of each file in the current directory. The /w switch forces a wide listing. The [-b|k] selects bytes or k's. The [-#] specifies the number of files on each line in a horizontal listing. }
    elseif ($2 = who) { .msg =$nick who - lists all users currently browsing my file servers }
    elseif ($2 = ls) { .msg =$nick ls [-b|k] [-#] - lists the name of each file in the currenty directory using a wide listing. }
    elseif ($2 = get) { .msg =$nick get <filename> - asks the fileserver to DCC Send the specified file. }
    elseif ($2 = read) { .msg =$nick read [-numlines] <filename.txt> - reads the specified text file. The user will be sent a default of 20 lines and then prompted whether to continue listing. The -numlines option changes the default number of lines to a value between 5 and 50. }
    elseif ($2 = sends) { .msg =$nick sends - lists all sends in progress }
    elseif ($2 = queues) { .msg =$nick queues - lists all files in the queues }
    elseif ($2 = credits) { .msg =$nick credits - shows file server credits }
    elseif ($2 = sclear) { .msg =$nick sclear - cancels all of your current file transfers (NOT queues) }
    elseif ($2 = sdel) { .msg =$nick sdel <#> - cancel the specified send of yours }
    elseif ($2 = rules) { .msg =$nick rules - displays rules, if set }
    elseif ($2 = motd) { .msg =$nick motd - displays Message of the Day, if set }
    elseif ($2 = drives) { .msg =$nick drives - list file server drives information }
    elseif ($2 = drive) { .msg =$nick drive <#> - switch file servers }
    elseif ($2 = find) { .msg =$nick find *string* - searches the file server for the specified file string }
    elseif ($2 = stats) { .msg =$nick stats - displays file server statistics }
    elseif ($2 = qdel) { .msg =$nick qdel # - delete one of YOUR OWN queues }
    elseif ($2 = qclear) { .msg =$nick qclear - clear all of YOUR queues }
    elseif ($2 = getx) { .msg =$nick getx - get this file serving script }
    elseif ($2 = quit || $2 = bye) { .msg =$nick  $+ $lower($2) $+  - terminates the connection. }
    else {
      .msg =$nick xServ+ build  $+ $xbuild $+  help file..
      .msg =$nick Commands: dir, ls, cd, get, bye, quit, queues, sends, sdel, sclear, qdel, qclear, motd, rules, find, drive, drives, getx, credits, who, and stats
      .msg =$nick For more information use help <command>..
    }
    haltdef
  }
  elseif ($1 = credits) {
    .msg =$nick -= File Server Credits =-
    .msg =$nick Author: (zeeg) [zeeg@evilcoder.net]
  }
  elseif ($1 = who) {
    var %` 0
    .msg =$nick Who's online you ask? There are currently $fserv(0) users online..
    while (%` < $fserv(0)) {
      inc %`
      .msg =$nick $+(,$fserv(%`)) is browsing %xserv. [ $+ [ $fserv(%`) ] ] . They are currently $fserv(%`).status with $send($fserv(%`),0) sends and $queue($fserv(%`),0) queues.
    }
  }
  elseif ($1 = stats) {
    .msg =$nick -= File Server Statistics =-
    .msg =$nick Leech Status (All): $lower($bytes($xcfg(snagged,bytes)).suf) in $xcfg(snagged,files) files
    .msg =$nick Record CPS: $lower($bytes($xcfg(topcps,bytes)).suf) $+ ps set by $xcfg(topcps,nick)
    .msg =$nick Failed Sends: $xcfg(main,sendfail)
    .msg =$nick Trigger Hits: $xcfg(main,access)
    haltdef
  }
  elseif ($1 = find) {
    if ($xcfg(main,@find) != 1) { .msg =$nick The find command has been disabled.. }
    elseif (!$2) { .msg =$nick Syntax: find *search string* }
    else {
      .msg =$nick Searching the file server for $2-
      var %a = 0
      while (%a < $findfile($xfile(%xserv. [ $+ [ $nick ] ],directory),$2-,0)) {
        inc %a
        if (%a < 6) { .msg =$nick %a $+ . Filename: $nopath($findfile($xfile(%xserv. [ $+ [ $nick ] ],directory),$2-,%a)) Path: $remove($nofile($findfile($xfile(%xserv. [ $+ [ $nick ] ],directory),$2-,%a)),$fserv($nick).cd) Size: $bytes($file($findfile($xfile(%xserv. [ $+ [ $nick ] ],directory),$2-,%a)).size).suf }
        else { .msg =$nick Search Overflow, more then 5 matches found.. | break }
      }
      if (%a = 0) { .msg =$nick No matches found for $2- $iif($chr(42) != $left($2,1) && $chr(42) != $right($2,1),$+(,$chr(40),try find *,$2-,* instead,$chr(41))) }
    }
    haltdef
  }
  elseif ($1 = sclear) { close -s $nick | .msg =$nick All of your file transfers have been closed | echo $colour(info) -sti2 $xserv.prefix $nick requested all his sends be canceled }
  elseif ($1 = sdel) {
    if ($2 !isnum) { .msg =$nick Syntax: sdel number }
    elseif ($send($nick,$2)) { .msg =$nick Your current send #'s are: 1 $+ - $+ $send($nick,0) }
    else {
      .msg =$nick Your file transfer of $send($nick,$2).file has been closed | close -s $+ $2 $nick
    }
  }
  elseif ($1 = queues) {
    if ($queue(0) = 0) { .msg =$nick There are no files in the queue.. }
    elseif ($queue(0) = 1) { .msg =$nick There is currently 1 file queued.. }
    else { .msg =$nick There are currently $queue(0) files queued.. }
    var %a = 0
    while (%a < $queue(0) && %a < 10) {
      inc %a
      .msg =$nick Queue $chr(35) $+ %a $+ ) User: $queue(%a) File: $nopath($queue(%a).file) ( $+ $lower($queue(%a).size) $+ ) Queue Time: $date($queue(%a).time) $+ @ $+ $time($queue(%a).time,h:nnt)
    }
    haltdef
  }
  elseif ($1 = sends) {
    if ($send(0) = 0) { .msg =$nick There are no sends in progress.. }
    elseif ($send(0) = 1) { .msg =$nick There is currently 1 send in progress.. }
    else { .msg =$nick There are currently $send(0) sends in progress.. }
    var %a = 0
    while (%a < $send(0)) {
      inc %a
      .msg =$nick Send $chr(35) $+ %a $+ ) User: $send(%a) File: $nopath($send(%a).file) ( $+ $lower($bytes($send(%a).size).suf) $+ ) Speed: $lower($bytes($send(%a).cps).suf)) $+ ps (% $+ $send(%a).pc done)
    }
    haltdef
  }
  elseif ($1 = motd) {
    if ($xfile(%xserv. [ $+ [ $nick ] ],showmotd) = 1 && $exists($xfile(%xserv. [ $+ [ $nick ] ],motd))) {
      .play =$nick " $+ $xfile(%xserv. [ $+ [ $nick ] ],motd) $+ "
    }
    else { .msg =$nick There isn't an MOTD =) }
  }
  elseif ($1 = qclear) {
    if ($queue($nick,0) <= 0) { .msg =$nick You don't have anything in the queue.. }
    else {
      var %a = 0
      while (%a < $queue(0)) {
        inc %a
        if ($queue(%a).nick = $nick) { queue del %a }
      }
      .msg =$nick All of your queues have been removed
      haltdef
    }
  }
  elseif ($1 = qdel) {
    if (!$2) { .msg =$nick Syntax: qdel QUEUE# }
    elseif ($2 !isnum) { .msg =$nick Syntax: qdel QUEUE# }
    elseif (!$read($xserv.queuefile,$2)) { .msg =$nick The queue $chr(35) $+ $2 does not exist }
    elseif ($gettok($read($xserv.queuefile,$2),1,44) != $nick) { .msg =$nick That queue doesn't belong to you =) }
    else {
      queue del $2
      .msg =$nick The queue has been removed..
    }
    haltdef
  }
  elseif ($1 = drive) {
    if (!$xserv($2)) { .msg =$nick Syntax: drive <DRIVE #> }
    elseif ($2 = $xdrive(%xserv. [ $+ [ $nick ] ])) { .msg =$nick You are already on that drive.. }
    elseif ($readini($xsdir($xserv($2)),main,status) != 1) || ($readini($xsdir($xserv($2)),main,mdrive) != 1) { .msg =$nick Drive  $+ $2 $+  is not available through the multi-drive.. }
    else {
      .msg =$nick Switching file servers..
      close -f $nick
      set %xserv. [ $+ [ $nick ] ] $readini($xsdir($xserv($2)),main,trigger)
      xset main access $calc($xcfg(main,access) + 1)
      xfserve $scid(%~xserv. [ $+ [ $nick ] ]).server $nick 999 $+(",$$xdir(%xserv. [ $+ [ $nick ] ]),") $iif($xfile(%xserv. [ $+ [ $nick ] ],showmotd) = 1 && $isfile($xfile(%xserv. [ $+ [ $nick ] ],motd)),$xfile(%xserv. [ $+ [ $nick ] ],motd))
    }
    haltdef
  }
  elseif ($1 = drives) {
    var %a = 0
    while (%a < $xserv(0)) {
      inc %a
      if ($readini($xsdir($xserv(%a)),main,status) = 1) && ($readini($xsdir($xserv(%a)),main,mdrive) = 1) { var %b = $iif(%b,%b $+ $chr(44) $+ $chr(32)) $+ %a }
    }
    .msg =$nick Drives Online: %b
    var %a = 0
    while (%a < $xserv(0)) {
      inc %a
      if ($readini($xsdir($xserv(%a)),main,status) = 1) && ($readini($xsdir($xserv(%a)),main,mdrive) = 1) { .msg =$nick  $+ %a $+ . ( $+ $readini($xsdir($xserv(%a)),main,trigger) $+ ) - $readini($xsdir($xserv(%a)),main,description) }
    }
    .msg =$nick To switch file servers use drive number
    .msg =$nick You are currently on drive $xdrive(%xserv. [ $+ [ $nick ] ])
    haltdef
  }
  elseif ($1 = top) { .msg =$nick Top Download: $nopath($replace(%~xserv.top,$chr(44),$chr(32))) $+($chr(40),,$hget(xserv.top,%~xserv.top),x,$chr(41)) }
  elseif ($1 = getx) {
    haltdef
    var %file = $script
    if ($send(0) >= $xcfg(sends,totalmax) || $send($nick,0) >= $xcfg(sends,usermax)) {
      if ($queue(0) >= $xcfg(queues,totalmax) || $queue($nick,0) >= $xcfg(queues,usermax)) {
        .msg =$nick There are too many sends in progress, and $iif($queue(0) >= $xcfg(queues,totalmax),all the queue slots have been taken...,you have used all of your queue slots..)
        if ($xcfg(main,anti-camp) = 1 && $queue($nick,0) >= $xcfg(queues,usermax)) { .msg =$nick You have filled your queues, the file server will close in 10 seconds.. | .timerxclose. [ $+ [ $nick ] ] 1 10 close -f $nick }
      }
      else {
        queue add $cid $nick %file
        ..msg =$nick $xserv.frmt(full_sends,$queue(0))
      }
    }
    else {
      set %xresend. [ $+ [ $nick ] ] %file
      scid $cid dcc send $nick " $+ %file $+ "
      window -n $+(",Send $nick $nopath(%file),")
      .msg =$nick Sending xServ+ ver $xbuild $+ ..
    }
    %file = $replace(%file,$chr(32),_)
  }
  elseif ($1 = get) {
    haltdef
    var %file = $cd $+ \ $+ $2-
    if (!$isfile($shortfn(%file))) { msg =$nick Incorrect filename.. | return }
    xserv.wstats %file
    if ($xcfg(isend,status) = 1 && $file(%file).size <= $calc($xcfg(isend,bytes) * 1024)) {
      set %xresend. [ $+ [ $nick ] ] %file
      scid $cid dcc send $nick " $+ %file $+ "
      window -n $+(",Send $nick $nopath(%file),")
      .msg =$nick Sending file..
    }
    elseif ($send(0) >= $xcfg(sends,totalmax) || $send($nick,0) >= $xcfg(sends,usermax)) {
      if ($queue(0) >= $xcfg(queues,totalmax) || $queue($nick,0) >= $xcfg(queues,usermax)) {
        .msg =$nick $xserv.frmt(full_queues)
        if ($xcfg(main,anti-camp) = 1) { .msg =$nick You have filled your queues, the file server will close in 10 seconds.. | .timerxclose. [ $+ [ $nick ] ] 1 10 close -f $nick }
      }
      else {
        var %a = 0
        while (%a < $queue($nick,0)) {
          inc %a
          if ($queue($nick,%a).file = %file) { .msg =$nick You are already waiting for this file in the queue. | return }
        }
        queue add $cid $nick %file
        .msg =$nick $xserv.frmt(full_sends,$queue(0))
      }
    }
    else {
      set %xresend. [ $+ [ $nick ] ] %file
      scid $cid dcc send $nick $+(",%file,")
      window -n $+(",Send $nick $nopath(%file),")
      .msg =$nick Sending file..
    }
    %file = $replace(%file,$chr(32),_)
  }
  elseif ($1 = cd || $1 = cd.. || $1 = dir || $1 = ls || $1 = read || $1 = help || $1 = exit || $1 = bye || $1 = quit) { return }
  else {
    if ($xcfg(main,noidle) = 1 && *Anti*Idle* iswm $1-) { .msg =$nick Idling is NOT allowed on this server, (*Anti*Idle* detected), closing file server session.. | close -f $nick | haltdef }
    elseif ($xcfg(main,fchat) = 1) { var %a = 0 | while (%a < $fserv(0)) { inc %a | if ($fserv(%a) != $nick) { msg = $+ $fserv(%a) < $+ $nick $+ > $1- } } | haltdef }
  }
  halt
}
on *:text:*:#:{
  if ($1- = !list) {
    if ($isban($fulladdress)) return
    elseif ($readini($xconf,!list,status) != 1) return
    elseif ($xtrigs = <none> || !$xtrigs) { goto next }
    elseif ($istok($getnet($server,$network).fserv,$chan,44)) && ($readini($_xconfig,!list,fstatus) = 1) { .notice $nick $xlist.frmt(fserv,$xserv.frmt(fserv.list)) }
    :next
    if ($xtdcc.trigs = <none> || !$xtdcc.trigs) { return }
    elseif ($istok($getnet($server,$network).tdcc,$chan,44)) && ($readini($_xconfig,!list,tstatus) = 1) { .notice $nick $xlist.frmt(tdcc,$xserv.frmt(tdcc.list)) }
    return
  }
  if ($1 = @Find && $chr(3) !isin $2- && $chr(2) !isin $2- && $chr(31) !isin $2- && $remove($2-,*) && $remove($2-,*) != . && $isfile($xfind.file)) {
    if ($xcfg(@find,status) = 1 && $istok($getnet($server,$network).fserv,$chan,44)) {
      if (!%xfind.flood. [ $+ [ $site ] ]) {
        set -u15 %xfind.flood. [ $+ [ $site ] ]
        var %string $+(*,$2-,*), %file $+(",$xserv.dir,$site,.xfind")
        filter -cff $xfind.file %file %string
        write -il1 %file I found $lines(%file) match $+ $iif($lines(%file) != 1,es) for %string
        var %a 1 | while (%a < $lines(%file)) { inc %a | write $+(-l,%a) %file $+(#,$calc(%a - 1),:) [file]; $gettok($read(%file,%a),1,127) - [trigger]; $readini($xsdir($gettok($read(%file,%a),2,127)),main,trigger) }
        write %file Ignoring further @find requests for 15 seconds
        .play $nick %file
      }
    }
  }
  if ($istrig($1-) == text && $trigok($server,$network,$chan,$1-).fserv) {
    echo -a $xstat($1-) - $xdir($1-) - $1-
    if ($isban($fulladdress)) return
    elseif ($xfile($1-,status) != 1) { .notice $nick $xserv.frmt(server_offline) }
    elseif ($fserv(0) >= $xcfg(users,totalmax)) { .notice $nick $xserv.frmt(full_users) }
    elseif ($xserv.clones($nick)) { .notice $nick $xserv.frmt(clones) }
    elseif (!$xstat($1-) || $isdir($xdir($1-)) = $false || !$xdir($1-)) { .notice $nick That file server is not active.. }
    elseif (!$xcfg(sends,totalmax)) { echo -i2ta $xserv.prefix ERROR: You didn't set your Total Max Sends | .notice $nick Sorry, there was an error with the file server | return }
    elseif (!$xcfg(sends,usermax)) { echo -i2ta $xserv.prefix ERROR: You didn't set your User Max Sends | .notice $nick Sorry, there was an error with the file server | return }
    elseif (!$xcfg(queues,totalmax)) { echo -i2ta $xserv.prefix ERROR: You didn't set your Total Max Queues | .notice $nick Sorry, there was an error with the file server | return }
    elseif (!$xcfg(queues,usermax)) { echo -i2ta $xserv.prefix ERROR: You didn't set your User Max Queues | .notice $nick Sorry, there was an error with the file server | return }
    else { set %~xserv. [ $+ [ $nick ] ] $cid | set %xserv. [ $+ [ $nick ] ] $1- | xset main access $calc($iif($xcfg(main,access) < 0 || $xcfg(main,access) = <none>,0,$xcfg(main,access)) + 1) | xfserve $server $nick 999 " $+ $$xdir($1-) $+ " $iif($xfile($1-,showmotd) = 1 && $exists(" $+ $xfile($1-,motd) ")," $+ $xfile($1-,motd) $+ ") }
    return
  }
  elseif ($istrig($1-) == tdcc:text && $trigok($server,$network,$chan,$1-).tdcc) {
    if ($isban($fulladdress)) return
    elseif ($readini($xtdcc.gdir($1-),main,serv+@) = 1 && $nick isreg #) { .notice $nick $xserv.frmt(restricted) }
    elseif ($readini($xtdcc.gdir($1-),main,status) = 1) {
      var %file = $xtdcc.file($1-)
      writeini $xtdcc.sdir($1-) main hits $calc($readini($xtdcc.gdir($1-),main,hits) + 1)
      if (!$isfile(" $+ %file $+ ")) { return }
      elseif ($send(0) >= $xcfg(sends,totalmax) || $send($nick,0) >= $xcfg(sends,usermax)) {
        if ($queue(0) >= $xcfg(queues,totalmax) || $queue($nick,0) >= $xcfg(queues,usermax)) {
          .msg $nick There are too many sends in progress, and $iif($queue(0) >= $xcfg(queues,totalmax),all the queue slots have been taken...,you have used all of your queue slots..)
        }
        else {
          var %a = 0
          while (%a < $queue($nick,0)) {
            inc %a
            if ($queue($nick,%a).file = %file) { .msg $nick You are already waiting for this file in the queue. | return }
          }
          set %~xserv. [ $+ [ $nick ] ] $cid
          queue add $cid $nick %file
          .msg $nick $xserv.frmt(full_sends,$queue(0))
        }
      }
      else {
        set %xresend. [ $+ [ $nick ] ] %file
        xsend -bypass $nick " $+ %file $+ "
        window -n $+(",Send $nick $nopath(%file),")
      }
    }
  }
}
on *:connect:qstart
on *:open:!:{
  .msg =$nick Welcome to my File Server! [running xServ $+($xbuild,])
  .msg =$nick To see a list of commands use the help command
  if ($xcfg(main,changuard) = 1) { .msg =$nick Warning: Channel Guard is enabled, do NOT leave the channel unless you wish to have all of your queues, sends, and file server sessions canceled.. }
  if ($xcfg(main,anti-camp) = 1) { .msg =$nick Warning: Anti-Camp has been enabled, your file server session will end once you have filled your queue slots. }
  if ($xcfg(main,noidle) = 1) { .msg =$nick Warning: Anti-Idlers will be kicked off the file server (Disable any Anti-Idle Scripts) }
  if ($xcfg(mincps,status) = 1 && $xcfg(mincps,bytes) isnum) { .msg =$nick Warning: Minimum CPS has been enabled, all sends that go slower then $lower($bytes($xcfg(mincps,bytes)).suf) $+ ps will be canceled.. }
  if ($xcfg(main,fchat) = 1) { .msg =$nick File Server chatting is enabled, anything that is not a command will be sent to everyone else on the server }
  if ($xcfg(isend,status) = 1) { .msg =$nick Instant-Send has been enabled, anything $bytes($calc($xcfg(isend,bytes) * 1024)).suf or less will send automatically }
  .msg =$nick 
  .msg =$nick Server Trigger: $xfile(%xserv. [ $+ [ $nick ] ],trigger)
  .msg =$nick Server Description: $xfile(%xserv. [ $+ [ $nick ] ],description)
  .msg =$nick 
  .msg =$nick $xserv.settop
  if ($xfile(%xserv. [ $+ [ $nick ] ],showrules) = 1) { set %xrules. [ $+ [ $nick ] ] 1 | .msg =$nick You MUST read the rules before continuing.. }
  halt
}
alias queue {
  if ($isid) {
    if ($1 = 0) { return $iif($lines($xserv.queuefile) > 0,$ifmatch,0) }
    elseif (!$prop) {
      if ($1 !isnum) {
        if ($2 = 0) { var %a = 0 | var %b = 0 | while (%a < $lines($xserv.queuefile)) { inc %a | if ($gettok($read($xserv.queuefile,%a),2,44) = $1) { inc %b } } | return %b }
        elseif ($2 isnum) { var %a = 0 | var %b = 0 | while (%a < $lines($xserv.queuefile)) { inc %a | if ($gettok($read($xserv.queuefile,%a),2,44) = $1) { inc %b } | if (%b = $2) { return $read($xserv.queuefile,%a) | break } } | return }
        else { return }
      }
      elseif ($1 > $lines($xserv.queuefile)) { return }
      else { return $gettok($read($xserv.queuefile,$1),2,44) }
    }
    elseif ($prop) {
      var %string = $read($xserv.queuefile,$1)
      if ($prop = size) { return $bytes($file($gettok($read($xserv.queuefile,$1),4-,44)).size).suf }
      elseif ($prop = file) { return $gettok($read($xserv.queuefile,$1),4-,44) }
      elseif ($prop = time) { return $gettok($read($xserv.queuefile,$1),3,44) }
      elseif ($prop = cid) { return $gettok($read($xserv.queuefile,$1),1,44) }
      else { return $gettok($read($xserv.queuefile,$1),2,44) }
    }
    else { return }
  }
  else {
    if (!$1) { echo $colour(info) -i2ta ** /queue: insufficient parameters }
    elseif ($1 = add) {
      if (!$3) { echo $colour(info) -i2ta ** /queue: insufficient parameters }
      else {
        var %queuel = $2 $+ $chr(44) $+ $3 $+ $chr(44) $+ $ctime $+ $chr(44) $+ $4- 
        write $xserv.queuefile %queuel
      }
    }
    elseif ($1 = del) {
      if ($2 !isnum) { echo $colour(info) -i2ta ** /queue: insufficient parameters }
      else {
        write -dl $+ $2 $xserv.queuefile
      }
    }
    elseif ($1 = send) {
      if ($2 !isnum) { echo $colour(info) -i2ta ** /queue: insufficient parameters }
      else {
        var %queue = $read($xserv.queuefile,$2)
        write -dl $+ $2 $xserv.queuefile
        scid $gettok(%queue,1,44) dcc send $gettok(%queue,2,44) " $+ $gettok(%queue,4-,44) $+ "
        window -n $+(",Send $gettok(%queue,1,44) $nopath($gettok(%queue,3-,44)),")
      }
    }
    else { echo $colour(info) -i2ta ** /queue: insufficient parameters }
  }
}
alias xserv.int {
  xserv.settop
  xserv.exp-bans
}
alias xserv.exp-bans var %a 0, %b | while (%a < $lines($xserv.banf)) { inc %a | %b = $read($xserv.banf,%a) | if ($ctime > $ctime($gettok(%b,3,124)) && $gettok(%b,3,124)) { write $+(-dl,%a) $xserv.banf | echo -i2ts $xserv.prefix Expiring ban: $gettok(%b,1,124) | dec %a } }
alias qstart {
  .timerqueues -im 0 500 qcheck
  .timerxserv~internal -i 0 300 xserv.int
}
alias qcheck {
  set %~xlbuild $xbuild
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
  if ($queue(0) > 0) {
    if ($send(0) < $xcfg(sends,totalmax)) {
      var %a = 0
      while (%a < $queue(0)) {
        inc %a
        if ($send($queue(%a),0) < $xcfg(sends,usermax)) {
          scid $queue(%a).cid dcc send $queue(%a) " $+ $queue(%a).file $+ "
          window -n $+(",Send $queue(%a) $nopath($queue(%a).file),")
          queue del %a
        }
        if ($send(0) >= $xcfg(sends,totalmax)) { goto end }
      }
    }
  }
  :end
  var %a = 0
  while (%a < $send(0)) {
    inc %a
    if ($send(%a).cps > $xcfg(topcps,bytes) || !$xcfg(topcps,bytes)) { xset topcps bytes $send(%a).cps | xset topcps nick $send(%a) }
    if ($send(%a).done) { echo $colour(info) -sti2 $xserv.prefix $send(%a) has successfully received $send(%a).file | close -s $+ %a }
    if ($send(%a).status = inactive || ($send(%a).secs >= 60 && $send(%a).status = waiting)) { echo $colour(info) -sti2 $xserv.prefix $send(%a) has failed to receive $send(%a).file | close -s $+ %a }
    if ($xcfg(maxcps,status) = 1) { .dcc maxcps $iif($calc($xcfg(maxcps,user) * $send(0)) < $xcfg(maxcps,total),$ifmatch,$xcfg(maxcps,total)) }
    else { .dcc maxcps 0 }
    if ($xcfg(mincps,status) = 1 && $xcfg(mincps,bytes) isnum && $send(%a).cps < $xcfg(mincps,bytes) && $send(%a).status = active && $send(%a).cps != 0) { $iif($fserv(%a),msg $+(=,$send(%a)),.notice $send(%a)) Your send of $send(%a).file have stopped because it was sending slower then $lower($bytes($xcfg(mincps,bytes)).suf) $+ ps | close -s [ $+ [ %a ] ] | echo $colour(info) -sti2 $xserv.prefix $send(%a) had his send of $filename canceled due to minimum cps failure }
  }
  .fsend on
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
}
alias xcfg { return $iif($readini($xconf,$1,$$2),$ifmatch) }
alias x2cfg { return $iif($readini($xconf,$1,$$2),$ifmatch) }
alias xset { writeini $xconf $1 $2 $iif($3- = 0,1,$iif($3-,$ifmatch,<none>)) }
alias x2set { $iif($3,writeini $xconf $1 $2 $3-,remini $xconf $1 $2) }
on *:snotice:*The user * is not accepting DCC sends of filetype*:{
  close -s [ $+ [ $send($3,0) ] ] $3
  echo $colour(info) -sti2 $xserv.prefix $3 had his send canceled due to dccallow failure (xresend $iif($replace($nopath(%xresend. [ $+ [ $3 ] ]),$chr(32),_) = $16,active,inactive) $+ )
  $iif($fserv($3),msg = $+ $3,.notice $3) Send Canceled, please type /dccallow + $+ $me and then retry downloading $16 $+ .. $iif($replace($nopath(%xresend. [ $+ [ $3 ] ]),$chr(32),_) = $16,(to resend use /ctcp $me xresend))
}
on *:filesent:*:{
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
  xset snagged files $calc($xcfg(snagged,files) + 1)
  xset snagged bytes $calc($xcfg(snagged,bytes) + $file($filename).size)
  close -s1 $nick
  if ($filename = $script) { .notice $nick xServ just finished sending, you can load it with this command: //load -rs $ $+ +(",$ $+ sfile($ $+ getdirxserv.mrc,Please select the xserv.mrc file,Load!),") }
  unset %xresend. [ $+ [ $nick ] ]
}
alias -l xtrigs {
  unset %a,%b,%c
  var %a = 0
  var %c = 0
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,status) = 1) {
      inc %c
      var %b = $iif(%b,%b $+ $chr(32) $+ -or- $+ $chr(32)) $+ $iif($readini($xsdir($xserv(%a)),main,type) = ctcp,/ctcp $me $+ $chr(32)) $+ $readini($xsdir($xserv(%a)),main,trigger)
    }
    if (%c >= 5) { return %b }
  }
  return $iif(%b,$ifmatch,<none>)
}
alias -l xtdcc.trigs {
  unset %a,%b,%c
  var %a = 0
  var %c = 0
  while (%a < $xtdcc(0)) {
    inc %a
    if ($readini($xtdcc.sdir($xtdcc(%a)),main,status) = 1) {
      inc %c
      var %b = $iif(%b,%b $+ $chr(32) $+ -or- $+ $chr(32)) $+ $iif($readini($xtdcc.sdir($xtdcc(%a)),main,type) = ctcp,/ctcp $me $+ $chr(32)) $+ $readini($xtdcc.sdir($xtdcc(%a)),main,trigger)
    }
    if (%c >= 5) { return %b }
  }
  return $iif(%b,$ifmatch,<none>)
}
alias -l istrig {
  var %a = 0
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,trigger) = $1 && $1 != <none> && $1) { return $iif($readini($xsdir($xserv(%a)),main,type) = ctcp,ctcp,text) }
  }
  var %a = 0
  while (%a < $xtdcc(0)) {
    inc %a
    if ($readini($xtdcc.sdir($xtdcc(%a)),main,trigger) = $1 && $1 != <none> && $1) { return $iif($readini($xtdcc.sdir($xtdcc(%a)),main,type) != ctcp,tdcc:text,tdcc:ctcp) }
  }
  return $false
}
alias xdir {
  var %a = 0
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,trigger) = $1-) { return $readini($xsdir($xserv(%a)),main,directory) }
  }
  return $getdir
}
alias xfile {
  var %a = 0
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,trigger) = $1) {
      var %b = main
      var %c = $2
      if ($2 = showmotd) { %b = motd | %c = show }
      if ($2 = showrules) { %b = rules | %c = show }
      if ($2 = motd) { %b = motd | %c = file }
      if ($2 = rules) { %b = rules | %c = file }
      return $readini($xsdir($xserv(%a)),%b,%c)
    }
  }
  return $getdir
}
alias xstat {
  var %a = 0
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,trigger) = $1) { return $iif($readini($xsdir($xserv(%a)),main,status) = 1,$true,$false) }
  }
  return $false
}
alias xserve {
  if ($1 = add) {
    var %name = $$?="Choose a Server Name"
    var %a = $true
    if ($exists($xsdir(%name))) { %a = $$input(This Server already exists $+ $chr(44) Overwrite It?) }
    if (%a) {
      var %directory = $$sdir($left($mircdir,3),Choose a Directory,Ok) 
      var %trigger = $$?="Choose a Trigger"
      write $xsdir(%name) 
      writeini $xsdir(%name) main trigger %trigger
      writeini $xsdir(%name) main directory %directory
      writeini $xsdir(%name) main status off
      writeini $xsdir(%name) main description No Description Available
      did -a xserv.fserv 42 %name
      if (!$did(xserv.fserv,42).sel) { did -c xserv.fserv 42 1 }
      xd loadserv $did(xserv.fserv,42).seltext
    }
  }
  elseif ($1 = del && $exists($xsdir($2-))) {
    .remove $xsdir($2-)
    var %a = 0 | did -r xserv.fserv 42 | while (%a < $xserv(0)) { inc %a | did -a $dname 42 $xserv(%a) }
    did -c xserv.fserv 42 1
    xd loadserv $did(xserv.fserv,42).seltext
  }
}
alias xserv.rquote {
  var %quote = $r(1,8)
  if (%quote = 1) %quote = w00t!
  elseif (%quote = 2) %quote = Check us out on irc.evilcoder.net, #corix =)
  elseif (%quote = 3) %quote = Remember, 1.x styles are not compatible with 2.x
  elseif (%quote = 4) %quote = Report bugs/comments/suggestions to $xserv.mail
  elseif (%quote = 5) %quote = Did you know this message is random? =P
  elseif (%quote = 6) %quote = Don't want a message to show? Just put it as <none>
  elseif (%quote = 7) %quote = Want to use the default message? Just leave the space empty
  elseif (%quote = 8) %quote = These are little tips & tricks, to see more click that button ->
  did -ra xserv.disp 90 %quote
}
on *:dialog:xserv:*:*:{
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
  if ($devent = INIT) {
    xd loadhelp
    xd loadqueues
    xd loadbans
    xd loadsettings
    didtok $dname 3 44 FileServer Setup,FTP Setup,TDCC Setup,XDCC Setup,Display Setup,@Find Setup,!list Setup,Stats Display,Update Utility,XS
    did -c $dname 3 1
  }
  if ($devent = SCLICK) {
    if ($did = 11) {
      var %a = $did(3).sel
      if (%a = 1) xfserv
      if (%a = 2) xftp
      if (%a = 3) xtdcc
      if (%a = 4) xdcc
      if (%a = 5) xdisp
      if (%a = 6) xfind
      if (%a = 7) xserv.list
      if (%a = 8) xstats
      if (%a = 9) xservupdate
      if (%a = 10) xs
    }
    if ($did = 13) run http://www.evilcoder.net/index.php?act=SF&f=17
    if ($did = 96) server -m irc.evilcoder.net -j #corix
    if ($did = 144) { write $xserv.banf $+($$?="Who do you wish to ban? (e.g. Guest????!*@*.*)",|,$?="Enter a reason [Optional]",|,$?="Expiration Date [Enter for Never]")) | xd loadbans }
    if ($did = 145 && $did(7).seltext) { write $+(-dl,$did(7).sel) $xserv.banf | xd loadbans }
    if ($did = 146) { .remove $xserv.banf | xd loadbans }
    if ($did = 83) xdisp
    if ($did = 40 && $did(16).seltext) { queue send $did(16).sel | xd loadqueues }
    if ($did = 153) xset main fchat $iif($did(153).state = 1,on,off)
    if ($did = 16) did $iif($did(xserv,16).seltext,-e,-b) xserv 105,113,40,129,104
    if ($did = 7) did $iif($did(xserv,7).seltext,-e,-b) xserv 145
    if ($did = 55) xset mincps status $iif($did(55).state = 1,on,off)
    if ($did = 158) xset main !list $iif($did(158).state = 1,on,off)
    if ($did = 159) xset main @find $iif($did(159).state = 1,on,off)
    if ($did = 104 && $did(16).seltext) { write -dl $+ $did(16).sel $xserv.queuefile | xd loadqueues }
    if ($did = 44) { xset main anti-camp $iif($did(44).state = 1,on,off) }
    if ($did = 114) { $iif($exists($xserv.queuefile),.remove $xserv.queuefile) | xd loadqueues }
    if ($did = 113 && $did(16).seltext) { var %a = $read($xserv.queuefile,$did(16).sel) | write -dl $+ $did(16).sel $xserv.queuefile | write -il $+ $calc($did(16).sel + 1) $xserv.queuefile %a | xd loadqueues }
    if ($did = 105 && $did(16).seltext) { var %a = $read($xserv.queuefile,$did(16).sel) | write -dl $+ $did(16).sel $xserv.queuefile | write -il $+ $calc($did(16).sel - 1) $xserv.queuefile %a | xd loadqueues }
    if ($did = 129) { xd loadqueues }
    if ($did = 163) { xhelp $did($did).seltext }
    if ($did = 152) { xset main changuard $iif($did($did).state = 1,on,off) }
    if ($did = 154) { xset main noidle $iif($did($did).state = 1,on,off) }
    if ($did = 130) { xset maxcps status $iif($did($did).state = 1,on,off) }
    if ($did = 27) { xset isend status $iif($did($did).state = 1,on,off) }
  }
  if ($devent = EDIT) {
    if ($did = 100) { xset sends totalmax $iif($did($did),$ifmatch,2) }
    if ($did = 102) { xset sends usermax $iif($did($did),$ifmatch,0) }
    if ($did = 108) { xset queues totalmax $iif($did($did),$ifmatch,0) }
    if ($did = 109) { xset queues usermax $iif($did($did),$ifmatch,0) }
    if ($did = 115) { xset users totalmax $iif($did($did),$ifmatch,0) }
    if ($did = 60) { xset mincps bytes $iif($did($did),$ifmatch,0) }
    if ($did = 127) { xset maxcps total $iif($did($did),$ifmatch,10000) }
    if ($did = 26) { xset maxcps user $iif($did($did),$ifmatch,10000) }
    if ($did = 29) { xset isend bytes $iif($did($did),$ifmatch,100) }
  }
}
alias xd {
  if ($1 = loaddstats) {
    writeini $xconf snagged files 1
    writeini $xconf snagged bytes 1
    writeini $xconf topcps bytes 1
    writeini $xconf topcps nick ???
  }
  if ($1 = loaddstyles) {
    if (!$hget(xserv.styles)) { hmake xserv.styles }
    xserv.mkprestyle default
    cachestyles
    ;createstyle Montana  12<Montana §crîpt> 3 Fserve Up: 14 <triggers> 3 Files Sent: 14 <lf> 3 Bytes Sent: 14 <lb> 3 Slots Used: 14 <users> 3 Send Slots In Use: 14 <sends> 3 Users Served: 14 <access> 3 Queue Slots: 14 <queues> 3 Serving: 14 <notes>
    ;createstyle AssimilatedIRC 4(05FServers Online04) 04Triggers (05<triggers>04) 04Transfered (05<lb> in <lf> files04) 04Online (05<users_now>/<users_max>04) 04Sends (05<sends>04) 04Queues (05<queues_now>/<queues_max>04) 04Assimilations (05<access> drones04) 04Note (05<notes>04) 04Next Send (05<next_send>04) 04\º05/04 å§§îmî|åtËÐmî®Ç 05\04º/4(05TDCC Online04) 04Triggers (05<trigger>04) 04Transfered (05<lb> in <lf> files04) 04Sends (05<sends>04) 04Queues (05<queues_now>/<queues_max>04) 04Assimilations (05<hits> drones04) 04Note (05<notes>04) 04Next Send (05<next_send>04) 04\º05/04 å§§îmî|åtËÐmî®Ç 05\04º/
    ;createstyle Polaris_Old (File Server Online) Trigger: <triggers>. Snagged: <lb> in <lf> files. Record CPS: <tcb> by <tcn>. Accessed: <access >times. Online: <users>. Sends: <sends>. Queues: <queues>. Note: <notes>. «~{Polaris IRC '97}~»
    ;createstyle SiliCon 15(09[F§ËRVs uP]15) [t®îggË®]s:(09<triggers>15) [§Ë®VËÐ]:(09<lb> in <lf> files15) [Må× CPS]:(09 <tcb> by <tcn>15) [peepS]:(09<users>15) [SeNDs]:(09<sends>15) [QuEuEs]:(09<queues>15) [eXtrA]:(09<notes>15) 14,1.:15,1[ 9,1SiliCon iRC 15,1]14,1:.
    ;createstyle Polaris_New (File Servers Online) Trigger:(<triggers>) Snagged:(<lb> in <lf> files) Record CPS:(<tcb> by <tcn>) Online:(<users>) Sends:(<sends>) Queues:(<queues>) Accessed:(<access> times) Note:(<notes>) «~{Polaris IRC '97}~»
    ;createstyle WalruS 14(04File Servers Online14) Trigger:(04<triggers>14) Snagged:(04<lb> in <lf> files14) Record CPS:(04<tcb> by <tcn>14) Online:(04<users>14) Sends:(04<sends>14) Queues:(04<queues>14) Accessed:(04<access> times14) Note:(04<notes>14) «~{04WalruS mIRC14}~»
    ;createstyle xCustom 12(10xServ12+02 <ver>12) 10triggers12:(02<triggers>12)10 counter12:(02<access>12)10 online12:(02<users_now>!<users_max>12)10 queues12:(02<queues_now>!<queues_max>12)10 sends12:(02<sends_now>!<sends_max>12)10 snatched12:(02<lf> files & <lb>12)10 record12:(02<tcn> @ <tcb>12)10 bandwidth12:(02<bandwidth>12)10 serving12:(02<notes>12)
    xset xstats uploads_-_info_display Send <b>#<number><b>: <b>Address:<b>(<u><user><u>) <b>File:<b>(<u><file> - <filesize><u>) <b>Speed:<b>(<u><speed> - <pcdone>% done<u>) <b>Time Left:<b>(<u><time_left><u>)
    xset xstats downloads_-_info_display Get <b>#<number><b>: <b>Address:<b>(<u><user><u>) <b>File:<b>(<u><file> - <filesize><u>) <b>Speed:<b>(<u><speed> - <pcdone>% done<u>) <b>Time Left:<b>(<u><time_left><u>)
    xset xstats queues_-_info_display Queue <b>#<number><b>: <b>Address:<b>(<u><user><u>) <b>File:<b>(<u><file> - <filesize><u>) <b>Time:<b>(<u><queue_time><u>)
  }
  if ($1 = loadhelp) {
    if ($dialog(xserv)) {
      did -r xserv 163
      didtok xserv 163 44 Main,-----------------------------,Options,Queues,Servers,-----------------------------,Styles,-----------------------------,Contact,Credits,-----------------------------,Aliases
      did -c xserv 163 1
      xhelp main
    }
  }
  if ($1 = loaddefaults) {
    xset snagged bytes 1
    xset ad delay 600
    xset ad active off
    xset snagged files 1
    xset snagged bytes 1
    xset topcps bytes 1
    xset topcps nick <none>
    xset main fserv off
    xset main notes <none>
    xset users totalmax 2
    xset sends totalmax 2
    xset queues totalmax 10
    xset sends usermax 1
    xset queues usermax 2
    xset main access 10
    set %xstring Default
  }
  if ($1 = loadbans) {
    if ($dialog(xserv)) {
      did -r xserv 7
      var %a = 0
      while (%a < $lines($xserv.banf)) {
        inc %a
        did -a xserv 7 $+(#,%a,:) $gettok($read($xserv.banf,%a),1,124) - $gettok($read($xserv.banf,%a),2,124)
      }
      did -c xserv 7 1
      did $iif($did(xserv,7).seltext,-e,-b) xserv 145
    }
  }
  if ($1 = loadstyles) {
    if ($dialog(xserv.disp)) {
      did -r xserv.disp 150
      var %a = $findfile($+(",$xserv.dir,fserv.styles\,"),*.hsh,0,did -a xserv.disp 150 $left($nopath($1-),-4))
      var %a = 0
      while (%a < $did(xserv.disp,150).lines) {
        inc %a
        if ($did(xserv.disp,150,%a).text = %xstring) { did -c xserv.disp 150 %a | goto end }
      }
      :end
      set %xstring $$did(xserv.disp,150).seltext | if ($hget(xserv.styles)) { hfree xserv.styles } | hmake xserv.styles | hload -b xserv.styles $xserv.sldir($$did(xserv.disp,150).seltext) | did -c xserv.disp 89 1 | xserv.ldnfo 1 
    }
  }
  if ($1 = loadqueues) {
    if ($dialog(xserv)) {
      did -r xserv 16
      var %a = 0
      while (%a < $lines($xserv.queuefile)) {
        inc %a
        did -az xserv 16 %a $+ . $gettok($read($xserv.queuefile,%a),1,44) queued $gettok($read($xserv.queuefile,%a),3-,44)) ( $+ $bytes($file($gettok($read($xserv.queuefile,%a),3-,44)).size).suf $+ )
      }
      did -c xserv 16 1
      did $iif($did(xserv,16).seltext,-e,-b) xserv 105,113,40,129,104
    }
  }
  if ($1 = loadsettings) {
    if ($dialog(xserv)) {
      did -ra xserv 60 $xcfg(mincps,bytes)
      did -ra xserv 100 $xcfg(sends,totalmax)
      did -ra xserv 102 $xcfg(sends,usermax)
      did -ra xserv 108 $xcfg(queues,totalmax)
      did -ra xserv 109 $xcfg(queues,usermax)
      did -ra xserv 115 $xcfg(users,totalmax)
      did -ra xserv 26 $xcfg(maxcps,user)
      did -ra xserv 127 $xcfg(maxcps,total)
      did -ra xserv 29 $xcfg(isend,bytes)
      did -rb xserv 10
      didtok xserv 10 44 Disable,User based,Filesize based
      did -c xserv 10 2
      did $iif($xcfg(main,noidle) = 1,-c,-u) xserv 154
      did $iif($xcfg(main,changuard) = 1,-c,-u) xserv 152
      did $iif($xcfg(main,anti-camp) = 1,-c,-u) xserv 44
      did $iif($xcfg(main,@find) = 1,-c,-u) xserv 159
      did $iif($xcfg(maxcps,status) = 1,-c,-u) xserv 130
      did $iif($xcfg(mincps,status) = 1,-c,-u) xserv 55
      did $iif($xcfg(isend,status) = 1,-c,-u) xserv 27
    }
  }
}
alias xserv.ldnfo {
  if (!$did(xserv.disp,89).sel) { did -c xserv.disp 89 1 | tokenize 32 Advertisement }
  if ($1- = FServ: Advertisement) {
    did -ra xserv.disp 17 $hget(xserv.styles,ad)
    return
  }
  elseif ($1- = FTP: Advertisement) {
    did -ra xserv.disp 17 $hget(xserv.styles,ftp:ad)
    return
  }
  elseif ($1- = FServ: !list) {
    did -ra xserv.disp 17 $hget(xserv.styles,fserv:!list)
    return
  }
  elseif ($1- = TDCC: !list) {
    did -ra xserv.disp 17 $hget(xserv.styles,tdcc:!list)
    return
  }
  elseif ($1- = TDCC: Advertisement) {
    did -ra xserv.disp 17 $hget(xserv.styles,tdcc:ad)
    return
  }
  elseif ($1- = XDCC: One Lined Ad) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:single)
    return
  }
  elseif ($1- = XDCC: Begin) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:begin)
    return
  }
  elseif ($1- = XDCC: Syntax) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:mid1)
    return
  }
  elseif ($1- = XDCC: List [Short]) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:mid2)
    return
  }
  elseif ($1- = XDCC: List [Long]) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:list1)
    return
  }
  elseif ($1- = XDCC: Stats) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:mid3)
    return
  }
  elseif ($1- = XDCC: End) {
    did -ra xserv.disp 17 $hget(xserv.styles,xdcc:end)
    return
  }
  elseif ($1- = Error: Queues Full) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.full_queues)
    return
  }
  elseif ($1- = Error: Server full (max users)) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.full_users)
    return
  }
  elseif ($1- = Error: Sends Full) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.full_sends)
    return
  }
  elseif ($1- = Error: Server Offline) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.server_offline)
    return
  }
  elseif ($1- = Error: No Clones) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.clones)
    return
  }
  elseif ($1- = Error: No Clones) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.clones)
    return
  }
  elseif ($1- = Error: Ops/Voice Only) {
    did -ra xserv.disp 17 $hget(xserv.styles,error.restricted)
    return
  }
  else {
    did -r xserv.disp 17
    return
  }
}
alias xserv.svnfo {
  if (!$hget(xserv.styles)) { hmake xserv.styles | hload -b $xsdir($iif(%xstring,$ifmatch,default)) }
  if ($1 = FServ: Advertisement) {
    hadd xserv.styles ad $2-
  }
  elseif ($1 = FTP: Advertisement) {
    hadd xserv.styles ftp:ad $2-
  }
  elseif ($1 = FServ: !list) {
    hadd xserv.styles fserv:!list $2-
  }
  elseif ($1 = TDCC: Advertisement) {
    hadd xserv.styles tdcc:ad $2-
  }
  elseif ($1 = TDCC: !list) {
    hadd xserv.styles tdcc:!list $2-
  }
  elseif ($1 = XDCC: One Lined Ad) {
    hadd xserv.styles xdcc:single $2-
  }
  elseif ($1 = XDCC: Begin) {
    hadd xserv.styles xdcc:begin $2-
  }
  elseif ($1 = XDCC: Syntax) {
    hadd xserv.styles xdcc:mid1 $2-
  }
  elseif ($1 = XDCC: List [Short]) {
    hadd xserv.styles xdcc:mid2 $2-
  }
  elseif ($1 = XDCC: List [Long]) {
    hadd xserv.styles xdcc:list1 $2-
  }
  elseif ($1 = XDCC: Stats) {
    hadd xserv.styles xdcc:mid3 $2-
  }
  elseif ($1 = XDCC: End) {
    hadd xserv.styles xdcc:end $2-
  }
  elseif ($1 = Error: Queues Full) {
    hadd xserv.styles error.full_queues $2-
  }
  elseif ($1 = Error: Server full (max users)) {
    hadd xserv.styles error.full_users $2-
  }
  elseif ($1 = Error: Sends Full) {
    hadd xserv.styles error.full_sends $2-
  }
  elseif ($1 = Error: Server Offline) {
    hadd xserv.styles error.server_offline $2-
  }
  elseif ($1 = Error: No Clones) {
    hadd xserv.styles error.clones $2-
  }
  elseif ($1 = Error: Ops/Voice Only) {
    hadd xserv.styles error.restricted $2-
  }
  hsave -bo xserv.styles $xserv.sldir(%xstring)
  var %- $+(xstyle:,$replace(%xstring,$chr(32),<space>))
  if (!$hget(%-)) { hmake %- }
  hload -b %- $xserv.sldir(%xstring)
}
alias xsdir { return $+(",$xserv.dir,$1-,.srv") }
alias xserv.dir { return $mircdirxdb\ }
alias xserv {
  if ($isid) {
    if ($1 = 0) { return $findfile($xserv.dir,*.srv,0) }
    elseif ($1 !isnum) { return }
    else { return $left($nopath($findfile($xserv.dir,*.srv,$1)),-4) }
  }
  else { dialog -mx _xserv _xserv }
}
alias xserv.sldir {
  mkdir $+(",$xserv.dir,fserv.styles\")
  return $+(",$xserv.dir,fserv.styles\,$1-,.hsh")
}
alias xserv.disp {
  var %xsdir, %txt
  if ($prop) { %xsdir = $xsdir($1-) | %txt = $hget($+(xstyle:,$replace($$iif($readini(%xsdir,main,style),$ifmatch,$xserv.style(1)),$chr(32),<space>)),ad) }
  else { %xsdir = $xsdir($xserv(1)) | %txt = $1- }
  var %trig = $iif($readini(%xsdir,main,type) = ctcp,/ctcp $me) $readini(%xsdir,main,trigger)
  return $xserv.eval($replace(%txt,<me>,$me,<next_send>,$xserv.nsend,<triggers>,%trig,<access>,$iif($xcfg(main,access),$ifmatch,0),<users_now>,$fserv(0),<users_max>,$xcfg(users,totalmax),<users>,$fserv(0) $+ / $+ $xcfg(users,totalmax),<queues_now>,$queue(0),<queues_max>,$xcfg(queues,totalmax),<queues>,$queue(0) $+ / $+ $xcfg(queues,totalmax),<uptime>,$xserv.uptime,<bandwidth>,$xserv.bw,<sends_now>,$send(0),<sends_max>,$xcfg(sends,totalmax),<sends>,$send(0) $+ / $+ $xcfg(sends,totalmax),<ver>,$xbuild,<mincps>,$lower($bytes($xcfg(mincps,bytes)).suf) $+ ps,<notes>,$readini(%xsdir,main,description),<lf>,$xcfg(snagged,files),<lb>,$lower($bytes($xcfg(snagged,bytes)).suf),<tcn>,$xcfg(topcps,nick),<tcb>,$remove($lower($bytes($xcfg(topcps,bytes)).suf),b) $+ B $+ ps))
}
alias xstring {
  if ($prop = b && $$1) {
    return $replace($xserv.disp($1-),<queue_num>,$r(1,100))
  }
  var %p = $iif($1,$iif($2,$2,$1),ad), %o = $iif($1,$1)
  if ($isfile($xserv.sldir(%o))) { var %a = %o }
  elseif (%xstring) { var %a = %xstring }
  else { var %a = default }
  if (!%p || %p = ad) {
    if ($hget(xserv.tmp)) { hfree xserv.tmp } | hmake xserv.tmp | hload -b xserv.tmp $xserv.sldir(%a)
    var %b = $hget(xserv.tmp,ad)
    return $iif(!$prop,$xserv.disp(%b),%b)
  }
  else {
    if ($hget(xserv.tmp)) { hfree xserv.tmp } | hmake xserv.tmp | hload -b xserv.tmp $xserv.sldir(%a)
    var %b = $hget(xserv.tmp,%p)
    return %b
  }
}
alias xd.p {
  mkdir $+(",$xserv.dir,tmp\")
  var %prv = $+(",$xserv.dir,tmp\,xserv.bmp")
  window -phf @xserv 0 0 426 16
  drawtext -pc @xserv 1 Tahoma -8 1 1 426 16 $1- $+(0,$str(-,75))
  drawsave @xserv %prv
  window -c @xserv
  return %prv
}
alias adstart { xserv.ads -start }
menu menubar,status,channel,nicklist,query {
  xServ
  .Setup
  ..Main [/xserv]:_xserv
  ..Display [/xdisp]:xdisp
  ..-
  ..Update xServ [/xservupdate]:xupd.chk
  ..Download Styles [/xs]:xs
  .-
  .Display
  ..$iif($xserv(0) > 0,FServ Ad [/xshow <server>]):xshow $$xserv.input(-s)
  ..$iif($xftp(0) > 0,FTP Ad [/xftp.show <server>]):xftp.show $$xserv.input(-f)
  ..XDCC Ad [/xdcc.show]:xdcc.show
  ..$iif($xtdcc(0) > 0,TDCC Ad [/xtdcc.show <server>]):xtdcc.show $$xserv.input(-t)
  ..-
  ..$iif($server,Version [/xver]):xver
  .User Control
  ..$iif($isban($address($$1,5)),Unban $1,Ban $1):$iif($isban($address($1,5)),xserv.ban -u $address($1,5),xserv.ban $address($1,5))
  .Load Options
  ..Reload [/xrload]:xrload
  ..Unload [/xunload]:xunload
  .Updates
  ..Check for Updates:xupd.CHK
  ..Get Newest Version:xupd.GET
  ..-
  ..Get more styles:xs
  .-
  .About xServ:xabout
}
on *:load:xserv.loadproc
alias xconf { return " $+ $mircdirxdb\xserv.ini" }
on *:unload:.timerqueues off | .timerxupd off | .timerxserv.* off | .timerxdcc off | .timerxftp.* off | .timerxtdcc.* off | .timerxserv~internal off | xserv.savet | xserv.kvars
on *:exit:xserv.savet
on *:part:#:{
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
  if ($nick = $me) { return }
  if ($queue($nick,0) <= 0 && $send($nick,0) <= 0 && $fserv($nick,0) <= 0) { var %b = 1 }
  ;var %a = 0
  ;while (%a < $comchan($nick,0)) {
  ;  inc %a
  ;  if ($istok($xcfg(main,channels),$comchan($nick,%a),44)) { var %b = 1 }
  ;}
  if (!%b && $xcfg(main,changuard) = 1) { xclear $nick | echo $colour(info) -sti2 $xserv.prefix All of $nick $+ 's Sends/Queues/File Server Sessions have been canceled because he has left all channels you are serving in.. | .notice $nick All of your File Server Sessions, Sends, and Queues have been canceled because you have left all channels that are being served.. }
}
alias xclear {
  var %a = 0
  while (%a < $queue(0)) {
    inc %a
    if ($queue(%a).nick = $1) { queue del %a }
  }
  close -fs $nick
}
on *:close:!:unset %*xserv. [ $+ [ $nick ] ]
alias xdrive {
  var %a = 0
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,trigger) = $1-) { return %a }
  }
  return
}
on *:sendfail:*:xset main sendfail $calc($iif($xcfg(main,sendfail) isnum,$ifmatch,0) + 1)
alias xhelp {
  did -r xserv 166
  if (-* !iswm $1) { did -a xserv 166 xServ+ Help File.. $upper($1) $crlf }
  if ($1 = main) {
    did -a xserv 166 $crlf
    did -a xserv 166 What is xServ? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 xServ is a File Server addon created by zeeg with help from normal IRC Users. It has been created in order to suit your needs, everything in here has been a choice of a user on IRC. I have asked many people what they wanted in a File Serving addon, and this is what it came out to be =) $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Who created xServ? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 xServ was created by our friend, zeeg.
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 How can I contact zeeg? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 You can contact zeeg on EvilCoder (irc.evilcoder.net), in #corix $crlf
    did -a xserv 166 Or, by email: zeeg@evilcoder.net
  }
  if ($1 = Options) {
    did -a xserv 166 $crlf
    did -a xserv 166 What are the differences between Max(Total) and Max(User)? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Well, Max (Total), is the maximum of that item for EVERYONE. And, Max (User), is the maximum of that item for each USER. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What are the Channels for? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 The channels are the channels you serve in, if the channel is not in the list, or ALL CHANNELS is not checked, it will not be served too, !list/triggers won't work, and the ad won't be shown here. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is Channel Guard? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Channel Guard tries to prevent users from leaving the channels you serve in. If they do all of their sends, queues, and file server sessions are cleared. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is FServ Chat? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 The FServ Chat, or File Server Chat, allows users who are on your file server simply talk to each other. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is the Flood Protection? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 The Flood Protection stops users from lagging your file server sessions, by trying to flood you. The flood protection is set to 8 lines in 3 seconds and cannot be changed as of yet. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is "Stop Idlers"? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Well, The "Stop Idlers" button is used to prevent Anti-Idle scripts from keeping their file server sessions online. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is the Serv Find Option? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 The Serv Find option allows users on your file server to use the "find" command, as there is not an @find implemented in this script. (WARNING: This will lag on large file servers!) $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is the !list option for? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 The !list option allows you to enable or disable the !list command. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is Anti-Camp? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Anti-Camp is an option, brought to you by user ideas, that closes the file server 10 seconds after they have filled all of their queue slots. $crlf
  }
  if ($1 = aliases) {
    did -a xserv 166 $crlf
    did -a xserv 166 /xserv - opens the file server dialog $crlf
    did -a xserv 166 /xshow - shows your ad to the current active window $crlf
    did -a xserv 166 /xdcc.show - Shows your XDCC ad to the current active window $crlf
    did -a xserv 166 /xtdcc.show <server name> - Shows your TDCC ad to the current active window $crlf
    did -a xserv 166 /adstart - starts the file server ad $crlf
    did -a xserv 166 /adstop - stops the file server ad $crlf
    did -a xserv 166 /xad - shows your ad to all channels served $crlf
    did -a xserv 166 /xver - shows script information to active chan $crlf
    did -a xserv 166 /xpre - shows a preview of your ad in the active window $crlf
    did -a xserv 166 /xunload - unloads xServ $crlf
    did -a xserv 166 /xrload - reloads the script $crlf
  }
  if ($1 = queues) {
    did -a xserv 166 $crlf
    did -a xserv 166 What are Queues? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Well, queues are made so people can "wait in line" for files, they queue up a file, and it tells them the queue number, then they wait until there is a free send slot and it sends them the file they have been waiting for $crlf
  }
  if ($1 = servers) {
    did -a xserv 166 $crlf
    did -a xserv 166 What are Triggers? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Well, you SHOULD know this by now...but, Triggers are what the other users type in order to access your file server, you MUST set one of these if you wish to use that server. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is the Directory? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Common Sense, the directory is the main file server directory on that server, users can only go back as far as that directory, BUT, they can go into any sub-directories there may be. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What are the RULES? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Rules are set for reasons, so people read them. That is why RULES are enforced on xServ File Servers, users MUST read them before they can do anything.
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is the MOTD? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 MOTD's are a short form of, Message of the Day. It's a simple welcome message on your file server. $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 What is the Multi-Drive? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Well, the Multi-Drive is simply a system to let users access your other file servers that are online, without exiting and typing the trigger.
  }
  if ($1 = contact) {
    did -a xserv 166 $crlf
    did -a xserv 166 DALnet: #corix
  }
  if ($1 = credits) {
    did -a xserv 166 $crlf
    did -a xserv 166 Main Author: (zeeg) [zeeg@evilcoder.net] $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Bugs/Suggestions: (Z2000) [NA] $crlf
    did -a xserv 166 Bugs/Suggestions: (piglywigly) [piglywigly38@yahoo.com] $crlf
    did -a xserv 166 Bugs/Suggestions: (hemmy) [NA] $crlf
    did -a xserv 166 Bugs/Suggestions: (stylee311) [NA] $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 Wanting to be here: (equak-) [NA] $crlf
    did -a xserv 166 Wanting to be here: (|Neptune|) [www.winbeta.org] $crlf
  }
  if ($1 = styles) {
    did -a xserv 166 $crlf
    did -a xserv 166 What are Styles? $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 You always see ads, like Polaris IRC, Excursion, etc. Well with xServ, you can BE anyone of those scripts users, or be your own, xServ's file serving ad is entirely customizable..
    did -a xserv 166 $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 String Syntax? $crlf
    did -a xserv 166 $crlf
    did -a xServ 166 * For any of the users/sends/queues tags you can do max and now additions (e.g. <queues_now> <sends_max>) $crlf
    did -a xserv 166 $crlf
    did -a xServ 166 All Styles $crlf
    did -a xServ 166 ~ <sends> - returns current sends/max sends $crlf
    did -a xServ 166 ~ <queues> - returns current queues/max queues $crlf
    did -a xServ 166 ~ <lb> - returns leeched bytes $crlf
    did -a xServ 166 ~ <lf> - returns leeched files $crlf
    did -a xServ 166 ~ <tcb> - returns top cps speed $crlf
    did -a xServ 166 ~ <tcn> - returns top cps nickname $crlf
    did -a xServ 166 ~ <notes> - returns file server notes $crlf
    did -a xServ 166 ~ <mincps> - returns the minimum cps bytes $crlf
    did -a xServ 166 ~ <ver> - returns xServ build infomration $crlf
    did -a xServ 166 ~ <bandwidth> - returns current mIRC bandwidth in use $crlf
    did -a xServ 166 ~ <next_send> - returns when the next available send is available, or Now, or Never $crlf
    did -a xServ 166 ~ <me> - returns your current nickname $crlf
    did -a xserv 166 $crlf
    did -a xserv 166 File Server $crlf
    did -a xserv 166 ~ [Error: Full Sends] <queue_num> - returns the queue number the user has been put into $crlf
    did -a xServ 166 ~ <triggers> - returns file server trigger $crlf
    did -a xServ 166 ~ <users> - returns current users/max users $crlf
    did -a xServ 166 ~ <uptime> - returns the time your file servers have been active $crlf
    did -a xServ 166 ~ <access> - returns number of times your servers have been accessed $crlf
    did -a xserv 166 $crlf
    did -a xServ 166 XDCC $crlf
    did -a xServ 166 ~ [List (Long)] <number> - returns package number $crlf
    did -a xServ 166 ~ [List (Long)] <desc> - returns package description $crlf
    did -a xServ 166 ~ [List (Long)] <file> - returns package filename $crlf
    did -a xServ 166 ~ [List (Long)] <hits> - returns number of downloads $crlf
    did -a xServ 166 ~ <packs> - returns total number of packages $crlf
    did -a xserv 166 $crlf
    did -a xServ 166 TDCC $crlf
    did -a xServ 166 ~ <trigger> - returns download trigger $crlf
    did -a xServ 166 ~ <file> - returns filename $crlf
    did -a xServ 166 ~ <filesize> - returns the size of the file $crlf
    did -a xServ 166 ~ <hits> - returns number of downloads $crlf
    did -a xServ 166 (Control codes are supported)
  }
  did -c xserv 166 1
}
alias xshow { say $iif(c isincs $chan($active).mode,$strip($xserv.disp($$1-).p,c),$xserv.disp($$1-).p) }
alias xunload {
  echo $colour(info) -sti2 $xserv.prefix xServ+ build $build unload successful..
  xserv.kvars
  .unload -rs $script
}
alias xpre { echo -a PREVIEW $xstring }
alias xver { describe $active is running xServ+ build $xbuild file serving utilities - tested on mIRC 6.03 32bit }
alias xinfo { var %a = [xServ! Information] version, $xbuild - crc check, $crc($script) - file size, $bytes($file($script).size).suf - lines, $lines($script) - script compiled on $asctime($gettok($read($script,2),2,32),m/d/yy) | $iif($isid,return %a,say %a) }
alias xrload { .load -rs $+(",$script,") }
alias xserv.bw {
  var %a = 0
  var %b = 0
  while (%a < $send(0)) {
    inc %a
    var %b = $calc($iif(%b,%b,0) + $send(%a).cps))
  }
  var %a = 0
  while (%a < $get(0)) {
    inc %a
    var %b = $calc($iif(%b,%b,0) + $get(%a).cps))
  }
  return $bytes(%b).suf $+ /s
}
on *:notice:Send Canceled, please type /dccallow +* and then retry downloading *..:?:.dccallow + $+ $nick
raw 401:*:if ($send($nick)) { close -s $nick | haltdef | halt }

;Disabled cuz i havent added much multi-serv to queues yet..
;on *:nick:if ($queue($nick,0) > 0) { .notice $newnick Please change your nickname back to $nick if you wish your queued files to send }

alias send { var %nick $iif($1,$1,$$input(Enter nickname:,1)),%file $iif($2,$2,$$sfile($mircdir,Choose a File,Send)) | xsend %nick %file | window -n $+(",Send %nick $nopath(%file),") | set %xresend. [ $+ [ %nick ] ] %file }
alias xserv.savet {
  if (!$hget(xserv.top)) hmake xserv.top
  hsave -bo xserv.top $+(",$xserv.dir,xtop.db")
  if (!$hget(xserv.dialog)) hmake xserv.dialog
  hsave -bo xserv.dialog $+(",$xserv.dir,xdialog.db")
  $iif($1 != -h,echo $colour(info) -sti2 $xserv.prefix xServ Hash files saved successfully..)
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
}
alias xserv.loadt {
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
  set %xstring $iif(%xstring,$ifmatch,default)
  if (!$hget(xserv.styles)) { hmake xserv.styles | hload -b xserv.styles $xserv.sldir(%xstring) }
  if (!$hget(xserv.styles,tdcc:ad)) { hadd xserv.styles tdcc:ad xTDCC04! 04< file: <filename> 04[<size>04] 04/ trigger: <trigger> 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04] 04> <notes> 04< <hits> downloads! }
  hsave -bo xserv.styles $xserv.sldir(%xstring)
  if (!$hget(xserv.top)) { hmake xserv.top }
  hload -b xserv.top $+(",$xserv.dir,xtop.db")
  if (!$hget(xserv.dialog)) { hmake xserv.dialog }
  hload -b xserv.dialog $+(",$xserv.dir,xdialog.db")
  $iif($1 != -h,echo $colour(info) -sti2 $xserv.prefix Configuration files loaded successfully..)
}
alias xserv.queuefile { return " $+ $mircdirxdb\queues.txt" }
alias xserv.prefix { return [x] }
alias xserv.kvars { unset %xserv.*,%xresend.*,%fflood.*,%xstring,%oldstring,%~xserv.* }
alias xupd.INSTALL { xupd.ECHO Installing Update.. | .run $+(",$mircdirxdb\xserv-install.mrc,") }
alias xupd.CHK { if ($sock(xupd.chk)) { return } | unset %xupd.chk | sockopen xupd.CHK evilcoder.net 80 | xupd.ECHO Connecting to update server... }
alias xupd.CHKh { if ($sock(xupd.chk)) { return } | set %xupd.chk 1 | sockopen xupd.CHK evilcoder.net 80 }
alias xupd.ECHO { xservUpdate | did -ra xservUpdate 4 $1- }
alias xupd.ECHO2 { xservUpdate | did -a xservUpdate 6 $eval($1-,3) | did -c xservUpdate 6 1 }
alias xupd.DCHK { xservUpdate | did $1 xservUpdate 2 }
alias xupd.RNAME { xservUpdate | did -ra xservUpdate 1 $1- }
alias xservUpdate { if ($dialog(xservUpdate)) { dialog -v xservUpdate } | else { dialog -m xservUpdate xservUpdate } }
on *:sockopen:xupd.CHK:{
  if (%xupd.chk != 1) { xupd.ECHO Connected. Checking verisons.. }
  sockwrite -n $sockname GET /xserv/xserv.mrc
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Host: evilcoder.net
  sockwrite -n $sockname $crlf
}
alias xupd.GET if (!$sock(xupd.get)) sockopen xupd.GET evilcoder.net 80
on *:sockopen:xupd.GET:{
  if ($isfile($mircdirxdb\xserv-install.mrc)) .remove $mircdirxdb\xserv-install.mrc
  sockwrite -n $sockname GET /xserv/xserv.mrc
  sockwrite -n $sockname $crlf
  xupd.ECHO Downloading file...
  xupd.DCHK -b
}
on *:sockread:xupd.GET:{
  if ($sockerr > 0) { xupd.ECHO Error downloading update.. | return }
  :n
  sockread 4096 &n
  if ($sockbr) {
    bwrite $mircdirxdb\xserv-install.mrc -1 -1 &n
    goto n
  }
}
on *:sockclose:xupd.CHK:xupd.ECHO Connection closed
on *:sockclose:xupd.GET:xupd.ECHO Download complete | xupd.INSTALL
on *:sockread:xupd.CHK:{
  if ($sockerr > 0) { xupd.ECHO Unable to connect | return }
  :n
  sockread %n
  if ($sockbr = 0) { return }
  tokenize 32 %n
  if ($3 != $xbuild && $remove($3,a,b,c,d,e,f,g,h,i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z) >= $xbuild) {
    if (%xupd.chk = 1) { echo -ta $xserv.prefix xServ $3 is available for download. If you wish to update, simple type /xserv.update }
    else {
      xupd.ECHO xServ $3 is available
      xupd.DCHK -e
    }
  }
  else {
    if (%xupd.chk != 1) {
      xupd.ECHO You are running the newest version
      xupd.DCHK -b
      xupd.RNAME Close
    }
  }
  unset %xupd.chk
  sockclose $sockname
}
on *:chat:*:{
  if ($1- = Closing Idle connection in 30 seconds) {
    ..msg =$nick cd
  }
}
dialog xservUpdate {
  title "[xServ] Update Utility"
  size -1 -1 139 39
  option dbu
  icon $xserv.icon(update), 0
  button "Cancel", 1, 103 27 34 10, ok cancel
  button "Update", 2, 66 27 34 10, disable
  box "Status", 3, 1 0 137 24
  text "Connecting to server", 4, 5 10 130 8
}
on *:dialog:xservUpdate:*:*:{
  if ($devent = INIT) {
    if (!$sock(xupd.chk) && !$sock(xupd.get)) { xupd.chk }
  }
  if ($devent = SCLICK) {
    if ($did = 2) {
      if (!$sock(xupd.get)) { xupd.get }
    }
    if ($did = 1) { sockclose xupd.* }
  }
}
alias xerror {
  echo $colour(info) -ati2 $xserv.prefix ERROR: $1-
}
alias xfserve {
  set %~xserv. [ $+ [ $2 ] ] $$scon($1).cid
  fserve $$2-
}
alias xsend {
  if ($1 = -bypass) {
    dcc send $2-
  }
  elseif ($version > 6) {
    scid %~xserv. [ $+ [ $1 ] ] dcc send $1-
  }
  else {
    dcc send $1-
  }
}
alias xdcc.disp {
  var %b $2-
  if ($prop = long) {
    var %line $read($xdcc.pdir,$1)
    var %s $left($round($bytes($file($gettok(%line,1,127)).size),1),3)
    %s = $iif($len(%s) < 3,$str($+(,$chr(32)),$calc(3 - $len(%s)))) $+ %s $+ $iif($right($remove($bytes($file($gettok(%line,1,127)).size).suf,b),1),$ifmatch,B)
    %b = $replace(%b,<number>,$readn,<desc>,$gettok(%line,2,127),<file>,$nopath($gettok(%line,1,127)),<filesize>,%s,<hits>,$iif($readini($xdcc.sdir,stats,$readn) > 0,$ifmatch,0),<me>,$me))
  }
  var %a 0, %s 0 | while (%a < $xdcc.packs) { inc %a | %s = $calc(%s + $file($+(",$gettok($read($xdcc.pdir,%a),1,127),")).size) } 
  return $xserv.eval($replace(%b,<mincps>,$upper($bytes($xcfg(mincps,bytes)).suf) $+ /s,<xdccsize>,$bytes(%s).suf,<next_send>,$xserv.nsend,<me>,$me,<ver>,$xbuild,<bandwidth>,$xserv.bw,<packets>,$xdcc.packs,<packs>,$xdcc.packs,<trigger>,/ctcp $me XDCC LIST,<sends_now>,$send(0),<sends_max>,$xcfg(sends,totalmax),<queues_now>,$queue(0),<queues_max>,$xcfg(queues,totalmax),<notes>,$readini($xdcc.sdir,main,notes),<lf>,$xcfg(snagged,files),<lb>,$bytes($xcfg(snagged,bytes)).suf,<tcn>,$xcfg(topcps,nick),<uptime>,$xserv.uptime,<tcb>,$bytes($xcfg(topcps,bytes)).suf $+ /s))
}
alias xdcc.packs {
  return $lines($xdcc.pdir)
}

alias xdcc.show {
  var %c = $active
  msg %c $xdcc.disp($1-,$xdcc.style(begin))
  if ($readini($xdcc.sdir,ad,short) = 1) {
    msg %c $xdcc.disp($1-,$xdcc.style(mid1))
    msg %c $xdcc.disp($1-,$xdcc.style(mid2))
  }
  else {
    msg %c $xdcc.disp($1-,$xdcc.style(mid1))
    var %a = 0
    while (%a < $lines($xdcc.pdir)) {
      inc %a
      var %line = $read($xdcc.pdir,%a)
      msg %c $xdcc.disp(%a,$xdcc.style(list1)).long
    }
  }
  msg %c $xdcc.disp($1-,$xdcc.style(mid3))
  msg %c $xdcc.disp($1-,$xdcc.style(end))
}
alias xdcc.sdir { return $+(",$xserv.dir,xdcc server.xdcc") }
alias xdcc.pdir { return $+(",$xserv.dir,xdcc server.pkg") }
alias xdcc {
  dialog $iif(!$dialog(xdcc),-mx,-v) xdcc xdcc
}
dialog xdcc {
  title "XDCC Configuration"
  size -1 -1 217 103
  option dbu
  icon $xserv.icon(xdcc), 0
  button "&Close", 15, 177 94 37 9, ok cancel
  link "Feedback", 49, 3 95 25 8
  combo 16, 14 14 60 50, size drop
  text "Packages", 17, 14 4 60 8, center
  text "Desc:", 19, 2 42 25 8
  edit "", 22, 29 41 57 10, autohs
  button "(click to set)", 23, 30 54 56 10
  button "New", 24, 16 29 25 10
  button "Delete", 25, 44 29 29 10
  text "File:", 20, 2 55 25 8
  text "Advertisement", 43, 90 4 60 8, center
  check "Enable Ad", 44, 96 13 50 10
  text "Interval:", 45, 96 23 24 8
  edit "", 46, 123 22 20 9
  text "(time is in minutes)", 47, 92 33 59 8, center
  button "Restart Ad", 48, 103 42 37 9
  text "Notes:", 1, 1 68 16 8
  edit "", 4, 19 67 76 10, autohs
  button "Add", 2, 169 32 20 9
  button "Delete", 3, 191 32 23 9
  combo 11, 161 9 54 50, sort drop
  text "Networks", 12, 161 1 54 8, center
  text "Channels", 6, 161 43 54 8, center
  combo 5, 161 51 54 50, sort drop
  button "Add", 7, 169 74 20 9
  button "Delete", 9, 191 74 23 9
  box "", 13, 0 88 217 4
  check "Short Ad", 14, 96 54 50 10
  text "Style:", 18, 1 80 17 8
  combo 21, 19 79 76 50, size drop
}
alias xdcc.adstart { .timerxdcc.ad -i 0 $calc($$readini($xdcc.sdir,ad,interval) * 60) xdcc.ad | xdcc.ad }
alias -l decrypt return $decode($1,m)
alias crchk return n/a
dialog xstats {
  title "xStats Setup"
  size -1 -1 227 65
  icon $xserv.icon(stats)
  option dbu
  box "", 1, 0 38 228 4
  button "&Close", 2, 204 55 23 9,  ok cancel
  edit "", 3, 1 15 224 10, autohs
  icon 4, 2 3 222 8
  button "Refresh Preview", 5, 172 27 53 9, 
  combo 6, 2 28 60 50, size drop
  text "Help file comes later", 8, 79 29 51 8
  text "<u> <b> <k> <total> <number> <user> <file> <filesize> <queue_time> <speed> <pcdone>", 9, 1 45 224 8
  text "^-- Those are the style tags.", 7, 3 56 198 8, center
}
on *:dialog:xstats:*:*:{
  if ($devent = INIT) {
    didtok $dname 6 46 Uploads - Begin.Uploads - Info Display.Uploads - End.Downloads - Begin.Downloads - Info Display.Downloads - End.Queues - Begin.Queues - Info Display.Queues - End
    did -c $dname 6 1
    did -ra $dname 3 $xstats.read($replace($did(6),$chr(32),_))
    did -g $dname 4 $xstats.p($did(3))
  }
  if ($devent = SCLICK) {
    if ($did = 5) { did -g $dname 4 $xstats.p($did(3)) }
    if ($did = 6) {
      did -ra $dname 3 $xstats.read($replace($did($did),$chr(32),_))
      did -g $dname 4 $xstats.p($did(3))
    }
  }
  if ($devent = EDIT) {
    if ($did = 3) {
      xset xstats $replace($did(6),$chr(32),_) $iif($did($did),$ifmatch,$chr(32))
    }
  }
}
alias xstats.read { return $xcfg(xstats,$$1) }
alias xstats.write { xset xstats $1 $$2- }
alias xstats.p {
  mkdir $+(",$xserv.dir,tmp\")
  var %prv = $+(",$xserv.dir,tmp\,xstats.bmp")
  window -phf @xstats 0 0 444 16
  %a = $replace($1-,<u>,,<b>,,<o>,,<k>,,<queue_time>,$+($date($ctime),@,$time($ctime)),<total>,$r(1,10),<number>,$r(1,3),<user>,$me,<file>,$nopath($mircexe),<filesize>,$bytes($file($mircexe).size).suf,<speed>,2.13kbps,<pcdone>,$r(00,100))
  drawtext -pc @xstats 1 Tahoma -8 1 1 444 16 $iif(%a = <none>,This message will not be displayed,%a) $+(0,$str(-,120))
  drawsave @xstats %prv
  window -c @xstats
  return %prv
}
alias xdcc.p {
  mkdir $+(",$xserv.dir,tmp\")
  var %prv = $+(",$xserv.dir,tmp\,xdcc.bmp")
  window -phf @xdcc 0 0 438 16
  %a = $xdcc.disp(a,$1-)
  drawtext -pc @xdcc 1 Tahoma -8 1 1 438 16 $iif(%a = <none>,This message will not be displayed,%a) $+(0,$str(-,120))
  drawsave @xdcc %prv
  window -c @xdcc
  return %prv
}

alias xstats {
  if (!$1) { dialog -m xstats xstats }
  if ($1 = sends) {
    $iif($xstats.read(uploads_-_begin) != <none> && $ifmatch,say $replace($xstats.read(uploads_-_begin),<total>,$send(0)))
    var %a = 0
    while (%a < $send(0) && $xstats.read(uploads_-_info_display) != <none>) {
      inc %a
      say $replace($xstats.read(uploads_-_info_display),<time_left>,$iif($duration($calc(($send(%a).size - $send(%a).sent) / $send(%a).cps)),$ifmatch,N/A),<total>,$send(0),<number>,%a,<user>,$send(%a),<file>,$nopath($send(%a).file),<filesize>,$lower($bytes($send(%a).size).suf),<speed>,$+($lower($bytes($send(%a).cps).suf),ps),<pcdone>,$send(%a).pc,<u>,,<b>,,<k>,,<o>,)
    }
    $iif($xstats.read(uploads_-_end) != <none> && $ifmatch,say $replace($xstats.read(uploads_-_end),<total>,$send(0)))
  }
  if ($1 = gets) {
    $iif($xstats.read(downloads_-_begin) != <none> && $ifmatch,say $replace($xstats.read(downloads_-_begin),<total>,$get(0)))
    var %a = 0
    while (%a < $get(0)) {
      inc %a
      say $replace($xstats.read(downloads_-_info_display),<time_left>,$iif($duration($calc(($get(%a).size - $get(%a).rcvd) / $get(%a).cps)),$ifmatch,N/A),<total>,$get(0),<number>,%a,<user>,$get(%a),<file>,$nopath($get(%a).file),<filesize>,$lower($bytes($get(%a).size).suf),<speed>,$+($lower($bytes($get(%a).cps).suf),ps),<pcdone>,$get(%a).pc,<u>,,<b>,,<k>,,<o>,)
    }
    $iif($xstats.read(downloads_-_end) != <none> && $ifmatch,say $replace($xstats.read(downloads_-_end),<total>,$get(0)))
  }
  if ($1 = queues) {
    $iif($xstats.read(queues_-_begin) != <none> && $ifmatch,say $replace($xstats.read(queues_-_begin),<total>,$queue(0)))
    var %a = 0
    while (%a < $queue(0) && %a < 10) {
      inc %a
      say $replace($xstats.read(queues_-_info_display),<total>,$queue(0),<number>,%a,<user>,$queue(%a),<file>,$nopath($queue(%a).file),<filesize>,$lower($queue(%a).size),<queue_time>,$+($date($queue(%a).time),@,$time($queue(%a).time,h:nnt)),<u>,,<b>,,<k>,,<o>,)
    }
    $iif($xstats.read(queues_-_end) != <none> && $ifmatch,say $replace($xstats.read(queues_-_end),<total>,$queue(0)))
  }
}
alias xstats.build { return 1019192002 }
alias xdcc.build { return 1139172002 }
alias xserv.build { return 2129232002 }
alias xtdcc.build { return 1019232002 }
dialog xtdcc {
  title "[xServ] TDCC Configuration"
  size -1 -1 170 119
  option dbu
  icon $xserv.icon(tdcc), 0
  button "&Close", 4, 138 108 31 9, ok cancel
  combo 5, 1 2 60 50, size drop
  box "", 10, 0 13 169 4
  button "New", 27, 63 3 24 9
  button "Remove", 28, 90 3 27 9
  button "Add", 8, 5 82 24 9
  button "Delete", 9, 34 82 24 9
  combo 6, 1 69 60 50, size drop
  text "Channels", 7, 1 61 60 8
  text "Networks", 24, 1 18 60 8
  button "Add", 26, 5 39 24 9
  button "Delete", 29, 34 39 24 9
  combo 25, 1 26 60 50, size drop
  check "Enable Ad", 17, 79 58 37 10
  edit "", 18, 121 58 20 10
  text "minute(s)", 19, 143 59 25 8
  check "@/+ Only", 31, 79 78 50 10
  check "CTCP Trigger", 23, 79 68 50 10
  text "Trigger:", 16, 79 25 25 8
  edit "", 15, 106 24 62 10, autohs
  text "File:", 11, 79 37 25 8
  text "Notes:", 12, 79 48 25 8
  edit "", 14, 106 47 62 10, autohs
  button "(click to set)", 13, 107 36 61 9
  box "", 32, 0 101 169 4
  check "Server [Off]", 33, 2 107 44 10, push
  button "Restart Ads", 34, 104 108 31 9
  button "Restart Ad", 35, 137 70 31 9
  text "Style:", 2, 79 93 13 8
  combo 3, 95 92 74 50, size drop
}
alias xtdcc {
  if ($isid) {
    if ($1 = 0) { return $findfile($xtdcc.dir,*.tdcc,0) }
    elseif ($1 !isnum) { return }
    else { return $left($nopath($findfile($xtdcc.dir,*.tdcc,$1)),-5) }
  }
  else {
    dialog -m xtdcc xtdcc
  }
}
on *:dialog:xtdcc:*:*:{
  if ($devent = init) {
    var %a = $findfile($+(",$xtdcc.dir,"),*.tdcc,0,did -a $dname 5 $left($nopath($1-),-5))
    did -c $dname 5 1
    loadxtdcc $did(5)
  }
  if ($devent = sclick) {
    if ($did = 5) { loadxtdcc $did(5) }
    if ($did = 3) { writeini $xtdcc.sdir($$did(5)) main style $$did(3) }
    if ($did = 27) {
      var %a = $$input(Enter a name for the new TDCC server,e,Create Server)
      writeini $xtdcc.sdir(%a) main trigger $iif($input(Enter a trigger for the server,e,Create Server),$ifmatch,$+(!,%a))
      writeini $xtdcc.sdir(%a) main file $iif($sfile($mircdir,Select a file,Ok),$ifmatch,$mircdir)
      writeini $xtdcc.sdir(%a) main notes No notes for this damn thing
      writeini $xtdcc.sdir(%a) main hits 1
      did -r $dname 5
      var %a = $findfile($+(",$xtdcc.dir,"),*.tdcc,0,did -a $dname 5 $left($nopath($1-),-5))
      did -c $dname 5 1
      loadxtdcc $did(5)
    }
    if ($did = 17) { writeini $xtdcc.sdir($$did(5)) ad status $did($did).state }
    if ($did = 28) {
      .remove $$xtdcc.sdir($did(5))
      did -r $dname 5
      var %a = $findfile($+(",$xtdcc.dir,"),*.tdcc,0,did -a $dname 5 $left($nopath($1-),-5))
      did -c $dname 5 1
      loadxtdcc $did(5)
    }
    if ($did = 13) { writeini $xtdcc.sdir($$did(5)) main file $$sfile($readini($xtdcc.sdir($did(5)),main,file),Select a file,Ok) }
    if ($did = 23) { writeini $xtdcc.sdir($$did(5)) main type $iif($did($did).state = 1,ctcp,text) | did $iif($did($did).state = 1,-b,-e) $dname 31 }
    if ($did = 31) { writeini $xtdcc.sdir($$did(5)) main serv+@ $did($did).state }
    if ($did = 33) { writeini $xtdcc.sdir($$did(5)) main status $did($did).state | did -ra $dname $did $iif($did($did).state = 1,Server [On],Server [Off]) }
    if ($did = 25) { did -r $dname 6 | var %a = 0, %read = $readini($xtdcc.sdir($$did(5)),networks,$$did(25)) | while (%a < $numtok(%read,44)) { inc %a | did -a $dname 6 $gettok(%read,%a,44) } | did -c $dname 6 1 }
    if ($did = 26) { var %a = $$xserv.input | writeini $xtdcc.sdir($$did(5)) main networks $addtok($readini($xtdcc.sdir($$did(5)),main,networks),%a,44) | did -a $dname 25 %a }
    if ($did = 29) { $iif($did(25).lines = 1,remini,writeini) $xtdcc.sdir($$did(5)) main networks $iif($did(25).lines > 1,$remtok($readini($xtdcc.sdir($$did(5)),main,networks),$did(25).seltext,1,44)) | did -r $dname 25 | %read = $readini($xtdcc.sdir($$did(5)),main,networks) | didtok $dname 25 44 %read | did -c $dname 25 1 | didtok $dname 6 44 $readini($xtdcc.sdir($$did(5)),networks,$did(25).seltext) | did -c $dname 6 1  }
    if ($did = 8) { var %a = $$input(Enter a channel name (e.g. #mychannel),e,Add Channel) | writeini $xtdcc.sdir($$did(5)) networks $$did(25) $addtok($readini($xtdcc.sdir($$did(5)),networks,$did(25)),%a,44) | did -a $dname 6 %a | if (!$did(6)) { did -c $dname 6 1 } }
    if ($did = 9) { $iif($did(6).lines = 1,remini,writeini) $xtdcc.sdir($$did(5)) networks $$did(25) $iif($did(6).lines > 1,$remtok($readini($xtdcc.sdir($$did(5)),networks,$$did(25)),$did(6).seltext,1,44)) | did -r $dname 6 | var %a = 0, %read = $readini($xtdcc.sdir($$did(5)),networks,$$did(25)) | while (%a < $numtok(%read,44)) { inc %a | did -a $dname 6 $gettok(%read,%a,44) } | did -c $dname 6 1 }
    if ($did = 34) { xtdcc.ads -stop | xtdcc.ads -start }
    if ($did = 35 && $did(17).state = 1) { .timerxtdcc. [ $+ [ $did(5).sel ] ] -i 0 $calc($did(18) * 60) xtdcc.ad $did(5) }
  }
  if ($devent = edit) {
    if ($did = 15) { writeini $xtdcc.sdir($$did(5)) main trigger $$iif($did($did),$ifmatch,$chr(32)) }
    if ($did = 14) { writeini $xtdcc.sdir($$did(5)) main notes $$iif($did($did),$ifmatch,$chr(32)) }
    if ($did = 18) { writeini $xtdcc.sdir($$did(5)) ad interval $$iif($did($did),$ifmatch,5) }
  }
}
alias xtdcc.sdir { return $+(",$xtdcc.dir,$1,.tdcc") }
alias xtdcc.cdir { return $+(",$xtdcc.dir,$1,.tchn") }
alias xtdcc.dir return $mircdirxdb\
alias loadxtdcc {
  did -b xtdcc 9,28,6,14,15,8,17,19,13
  did -r xtdcc 6,25,14,15,18
  if ($1) { did -e xtdcc 9,28,6,14,15,8,17,19,13 }
  did $iif($did(6),-e,-b) xtdcc 9
  did -ra xtdcc 15 $readini($xtdcc.sdir($did(5)),main,trigger)
  did -ra xtdcc 14 $readini($xtdcc.sdir($did(5)),main,notes)
  did $iif($did(5),-e,-b) xtdcc 28
  did $iif($readini($xtdcc.sdir($did(5)),ad,status) = 1,-c,-u) xtdcc 17
  did $iif($readini($xtdcc.sdir($did(5)),main,status) = 1,-c,-u) xtdcc 33
  did -ra xtdcc 33 $iif($readini($xtdcc.sdir($did(5)),main,status) = 1,Server [On],Server [Off])
  did $iif($readini($xtdcc.sdir($did(5)),main,type) = ctcp,-c,-u) xtdcc 23
  did $iif($readini($xtdcc.sdir($did(5)),main,serv+@) = 1,-c,-u) xtdcc 31
  did -ra xtdcc 18 $readini($xtdcc.sdir($did(5)),ad,interval)
  var %a = 0, %read = $readini($xtdcc.sdir($did(5)),main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a xtdcc 25 $gettok(%read,%a,44) }
  did -c xtdcc 25 1
  var %a = 0, %read = $readini($xtdcc.sdir($did(5)),networks,$$did(25)) | while (%a < $numtok(%read,44)) { inc %a | did -a xtdcc 6 $gettok(%read,%a,44) }
  did -c xtdcc 6 1
  did -r xtdcc 3
  var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),tdcc:ad)) { inc %; | did -a xtdcc 3 $xserv.style(%`) | if ($xserv.style(%`) = $readini($xtdcc.sdir($$did(5)),main,style)) { did -c xtdcc 3 %; } } }
}
alias xtdcc.file {
  var %a = 0
  while (%a < $xtdcc(0)) {
    inc %a
    if ($readini($xtdcc.sdir($xtdcc(%a)),main,trigger) = $1) { return $readini($xtdcc.sdir($xtdcc(%a)),main,file) }
  }
}
alias xtdcc.gdir {
  var %a = 0
  while (%a < $xtdcc(0)) {
    inc %a
    if ($readini($xtdcc.sdir($xtdcc(%a)),main,trigger) = $1) { return $xtdcc.sdir($xtdcc(%a)) }
  }
}
alias xtdcc.ad {
  var %a = 0, %b, %c = $readini($xtdcc.sdir($1-),main,networks), %e, %d
  if ($readini($xtdcc.sdir($1-),ad,status) != 1) return
  if (!$readini($xtdcc.sdir($1-),main,file)) { echo -it2a $xserv.prefix ERROR: File not defined for server $1- | return }
  if (!%c) { echo -i2ta $xserv.prefix WARNING: No networks defined for server $1- | return }
  while (%a < $scon(0)) {
    inc %a
    %e = 0
    while (%e < $numtok(%c,44)) {
      inc %e
      if ($gettok(%c,%e,44) iswm $scon(%a).server || $gettok(%c,%e,44) = $scon(%a).network) {
        %b = 0
        %d = $readini($xtdcc.sdir($1-),networks,$gettok(%c,%e,44))
        while (%b < $numtok(%d,44)) {
          inc %b
          if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xtdcc.disp($1-,$xstring(tdcc:ad))
        }
      }
    }
  }
}
alias xtdcc.disp {
  if ($1 = <none>) {
    return $replace($xstring(tdcc:ad),<hits>,$r(5,1500),<filename>,$nopath($mircexe),<size>,$lower($bytes($file($mircexe).size).suf),<trigger>,!xTDCC 0wnz me,<sends_now>,$r(1,5),<sends_max>,$r(5,10),<queues_now>,$r(1,5),<queues_max>,$r(5,10),<notes>,This is a l33t file download it now!)
  }
  var %default = xServ04! 04< file: <filename> 04[<size>04] 04/ trigger: <trigger> 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04] 04> <notes> 04< <hits> downloads!
  var %` $hget($+(xstyle:,$replace($readini($xtdcc.sdir($1),main,style),$chr(32),<space>)),tdcc:ad)
  return $xserv.eval($replace($iif(%`,%`,%default),<hits>,$readini($xtdcc.sdir($1),main,hits),<filename>,$nopath($readini($xtdcc.sdir($1),main,file)),<size>,$lower($bytes($file($readini($xtdcc.sdir($1),main,file)).size).suf),<trigger>,$+($iif($readini($xtdcc.sdir($1),main,type) = ctcp,/ctcp $me $+ $chr(32)),$readini($xtdcc.sdir($1),main,trigger)),<sends_now>,$send(0),<sends_max>,$xcfg(sends,totalmax),<queues_now>,$queue(0),<queues_max>,$xcfg(queues,totalmax),<notes>,$readini($xtdcc.sdir($1),main,notes),<sends>,$+($send(0),/,$xcfg(sends,totalmax)),<lf>,$xcfg(snagged,files),<lb>,$bytes($xcfg(snagged,bytes)).suf,<next_send>,$xserv.nsend,<tcb>,$remove($lower($bytes($xcfg(topcps,bytes)).suf),b) $+ Bps,<tcn>,$xcfg(topcps,nick),<access>,$xcfg(main,access),<queues>,$+($queue(0),/,$xcfg(queues,totalmax))))
}
alias xtdcc.ads {
  if ($1 = -start) {
    .timerxtdcc.* off
    var %a = 0
    while (%a < $xtdcc(0)) {
      inc %a
      var %b = $xtdcc.sdir($xtdcc(%a))
      if ($readini(%b,ad,interval) isnum) { .timerxtdcc. [ $+ [ %a ] ] -i 0 $calc($readini(%b,ad,interval) * 60) xtdcc.ad $xtdcc(%a) }
    }
    if (%a > 0) xserv.astart TDCC
  }
  if ($1 = -stop) {
    .timerxtdcc.* off
  }
}
alias xtdcc.p {
  mkdir $+(",$xserv.dir,tmp\")
  var %prv = $+(",$xserv.dir,tmp\,tdcc.bmp")
  window -phf @xtdcc 0 0 344 16
  drawtext -pc @xtdcc 1 Tahoma -8 1 1 344 16 $xtdcc.disp(<none>,$1-) $+(0,$str(-,75))
  drawsave @xtdcc %prv
  window -c @xtdcc
  return %prv
}
alias xbuildi {
  return [Build! Information] XDCC: $xdcc.build :: File Server: $xserv.build :: TDCC: $xtdcc.build :: Stats: $xstats.build
}
alias xtdcc.show { say $xtdcc.disp($1-,$xstring(tdcc:ad)) }
alias xserv.nsend {
  if ($send(0) < $xcfg(sends,totalmax)) { return Now }
  elseif (0 = $xcfg(sends,totalmax)) { return Never }
  else {
    var %a = 0
    while (%a < $send(0)) {
      inc %a
      var %left = $calc(($send(%a).size - $send(%a).sent) / $send(%a).cps)
      if (%left < %tleft || !%tleft) { var %tleft = %left }
    }
    return $duration(%tleft)
  }
}
dialog xserv.disp {
  title "[xServ] Advanced Style Editor"
  size -1 -1 219 107
  icon $xserv.icon(display)
  option dbu
  text "Editable Messages:", 38, 4 3 98 8
  combo 89, 4 12 98 60, size drop
  text "Archived Styles:", 86, 131 2 77 8
  combo 150, 131 11 80 50, size drop
  button "New", 97, 132 24 22 8
  button "Delete", 22, 156 24 22 8
  text "Choose a style from the list to load it and all of its custom messages.", 88, 132 33 78 23
  text "Be sure to check the help file for help on the new 2.x style coding syntaxes, there have been a lot of improvements. =)", 87, 4 24 98 20
  text "Quick Tag Insert:", 35, 3 47 42 8
  combo 33, 48 46 60 50, size drop
  button "!", 131, 110 47 8 8
  edit "", 17, 2 57 215 10, autohs
  icon 21, 3 70 213 8,  $mircexe, 10
  text "xServ 1.x style codes are not compatible with 2.x", 90, 3 82 155 8, center
  button "!", 112, 160 82 7 7
  button "Refresh Preview", 142, 173 81 44 9
  box "", 1, 1 89 217 4
  button "&Close", 2, 184 96 33 10, ok cancel default
}
on *:dialog:xserv.disp:*:*:{
  if ($devent = init) {
    xserv.rquote
    didtok $dname 89 46 FServ: Advertisement.FServ: !list. $+ $str(-,50) $+ .FTP: Advertisement. $+ $str(-,50) $+ .TDCC: Advertisement.TDCC: !list. $+ $str(-,50) $+ .XDCC: One Lined Ad.XDCC: Begin.XDCC: Syntax.XDCC: List [Short].XDCC: List [Long].XDCC: Stats.XDCC: End. $+ $str(-,50) $+ .Error: Queues Full.Error: Server Full (max users).Error: Sends Full.Error: No clones.Error: Server Offline
    didtok $dname 33 46 <triggers>.<sends>.<queues>.<users>.<uptime>.<notes>.<bandwidth>.<next_send>.<tcb>.<tcn>.<lb>.<lf>
    did -c $dname 89 1
    xd loadstyles
    xserv.ldnfo $did(89).seltext
    did -g xserv.disp 21 $xd.p($xstring($did(17)).b)
  }
  if ($devent = sclick) {
    if ($did = 89) { xserv.ldnfo $did($did).seltext | did $iif($did($did).seltext = Advertisement,-e,-b) $dname 33,131 | did -g $dname 21 $xd.p($iif($did($did).seltext = TDCC Advertisement,$xtdcc.disp($xtdcc(1),$hget(xserv.styles,tdcc:ad)),$iif(XDCC: * iswm $did($did).seltext,$xdcc.disp(default,$did(17)),$xstring($did(17)).b))) }
    if ($did = 131) { var %b = $did(17).selstart, %a = $+($mid($did(17),1,%b),$$did(33).seltext,$right($did(17),$+(-,%b))) | did -ra $dname 17 %a | xserv.svnfo $did(89).seltext | did -c $dname 17 %b }
    if ($did = 150) { set %xstring $did(150).seltext | if ($hget(xserv.styles)) { hfree xserv.styles } | hmake xserv.styles | hload -b xserv.styles $xserv.sldir($did(150).seltext) | did -c $dname 89 1 | xserv.ldnfo $did(89).seltext | did -g xserv.disp 21 $xd.p($xstring($did(17)).b) }
    if ($did = 112) { xserv.rquote }
    if ($did = 142) { did -g xserv.disp 21 $xd.p($xstring($did(17)).b) }
    if ($did = 97) { var %name = $$input(Enter a name for your style,e,Save Style,$+(MyStyle,$r(00,99))) | var %b = $true | if ($isfile($xserv.sldir(%name))) { %b = $$input(Would you like to overwrite the old file?,y,File Exists) } | if (%b) { addstyle %name } | dialog -v $dname | xd loadstyles }
    if ($did = 22) { .remove $xserv.sldir($did(150).seltext) | xd loadstyles }
  }
  if ($devent = edit) {
    if ($did = 17) {
      ; Edit message string here
      var %a = $xserv.svnfo($$did(89).seltext,$did($did))
    }
  }
}
dialog xserv.fserv {
  title "[xServ] File Servers"
  size -1 -1 254 134
  option dbu
  icon $xserv.icon(fserv), 0
  combo 42, 3 2 50 51, size drop
  box "", 34, 0 13 254 4
  button "New", 43, 56 3 17 9
  button "Delete", 46, 75 3 23 9
  check "Server [Off]", 32, 2 122 42 10, push
  check "@/+ Only", 85, 73 20 44 9
  check "CTCP Trigger", 84, 73 29 45 9
  check "Use Rules", 36, 119 21 42 9
  check "Show MOTD", 37, 119 29 43 9
  edit "", 39, 93 104 157 10, autohs
  edit "", 29, 93 78 120 10, read autohs
  edit "", 25, 93 65 138 10, read autohs
  edit "", 27, 93 52 157 10, autohs
  button "···", 121, 233 66 16 8
  button "···", 122, 215 79 16 8
  button "!", 4, 232 79 9 8
  button "···", 123, 215 92 16 8
  button "!", 5, 232 92 9 8
  text "Trigger", 1, 70 53 22 8
  text "Select a File Server from the list to load it's settings", 2, 103 4 148 8
  combo 3, 2 26 60 50, size drop
  text "Networks", 6, 3 18 25 8
  button "Add", 7, 6 39 20 9
  button "Delete", 8, 31 39 25 9
  text "Channels", 10, 3 58 25 8
  combo 11, 2 66 60 50, size drop
  button "Add", 12, 6 79 20 9
  button "Delete", 13, 31 79 25 9
  text "Directory", 15, 71 66 22 8
  text "MOTD", 16, 71 79 22 8
  text "Rules", 17, 71 92 22 8
  text "Notes", 18, 71 105 22 8
  box "", 19, 0 114 254 4
  text "<-- Click here to Turn this server on and off", 20, 46 123 105 8
  text "These are server specific options, they will only apply for this server", 21, 165 21 84 16
  button "&Close", 22, 222 122 30 10, ok cancel
  check "Enable Ad", 23, 73 38 38 10
  text "Interval", 24, 119 39 25 8
  edit "", 26, 145 38 17 10
  text "(in minutes)", 28, 165 39 34 8
  button "Restart Ads", 30, 186 122 33 10
  combo 31, 94 91 119 49, size drop
  button "X", 33, 242 79 9 8
  button "X", 35, 242 92 9 8
  text "Style:", 38, 3 97 25 8
  combo 40, 2 105 61 50, size drop
}
on *:dialog:xserv.fserv:*:*:{
  if ($devent = init) {
    var %a = 0 | did -r $dname 42 | while (%a < $xserv(0)) { inc %a | did -a $dname 42 $xserv(%a) }
    did -c $dname 42 1
    xd loadserv $did(42).seltext
  }
  if ($devent = sclick) {
    if ($did = 42) { xd loadserv $did(42).seltext }
    if ($did = 43) { xserve add }
    if ($did = 40) { writeini $xsdir($did(42).seltext) main style $$did(40).seltext }
    if ($did = 33) { remini $xsdir($did(42).seltext) motd file | did -ra $dname 29 Click the button marked '···' to set a file }
    if ($did = 35) { remini $xsdir($did(42).seltext) rules file | did -ra $dname 31 Click the button marked '···' to set a file | didtok xserv.fserv 31 44 PRESET: Pirated Software | did -c xserv.fserv 31 1 }
    if ($did = 46) { xserve del $$did(42).seltext }
    if ($did = 31) { writeini $xsdir($did(42).seltext) rules file $did(31).seltext }
    if ($did = 121) { writeini $xsdir($did(42).seltext) main directory $$sdir($iif($readini($xsdir($did(42).seltext),main,directory),$ifmatch,$left($mircdir,3)),Choose a Directory,Ok) | xd loadserv $did(42).seltext }
    if ($did = 122) { writeini $xsdir($did(42).seltext) motd file $$sfile($iif($readini($xsdir($did(42).seltext),motd,file),$ifmatch,$mircdir*.txt),Choose an MOTD File,Ok) | xd loadserv $did(42).seltext }
    if ($did = 123) { writeini $xsdir($did(42).seltext) rules file $$sfile($iif($readini($xsdir($did(42).seltext),rules,file),$ifmatch,$mircdir*.txt),Choose a Rules File,Ok) | xd loadserv $did(42).seltext }
    if ($did = 85) { writeini $xsdir($did(42).seltext) main serv+@ $iif($did(85).state = 1,on,off) }
    if ($did = 4 && $isfile($did(29))) { run notepad.exe $did(29) }
    if ($did = 5 && $isfile($did(31))) { run notepad.exe $did(31) }
    if ($did = 36) { writeini $xsdir($did(42).seltext) rules show $iif($did($did).state = 1,on,off) }
    if ($did = 84) { writeini $xsdir($did(42).seltext) main type $iif($did($did).state = 1,ctcp,text) }
    if ($did = 37) { writeini $xsdir($did(42).seltext) motd show $iif($did($did).state = 1,on,off) }
    if ($did = 32) { writeini $xsdir($did(42).seltext) main status $iif($did($did).state = 1,on,off) | did -ra $dname $did $iif($did($did).state = 1,Server [On],Server [Off]) }
    if ($did = 23) { writeini $xsdir($did(42).seltext) ad status $iif($did($did).state = 1,on,off) }
    if ($did = 3) { did -r $dname 11 | var %a = 0, %read = $readini($xsdir($did(xserv.fserv,42).seltext),networks,$$did(3).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a xserv.fserv 11 $gettok(%read,%a,44) } | did -c xserv.fserv 11 1 }
    if ($did = 7) { var %a = $$xserv.input | writeini $xsdir($did(42).seltext) main networks $addtok($readini($xsdir($did(42).seltext),main,networks),%a,44) | did -a $dname 3 %a }
    if ($did = 8) { $iif($did(3).lines = 1,remini,writeini) $xsdir($did(42).seltext) main networks $iif($did(3).lines > 1,$remtok($readini($xsdir($did(42).seltext),main,networks),$did(3).seltext,1,44)) | did -r $dname 3 | didtok $dname 3 44 $readini($xsdir($did(42).seltext),main,networks) | did -c $dname 3 1 | didtok $dname 11 $readini($xsdir($did(42).seltext),networks,$$did(3).seltext) | did -c $dname 11 1 }
    if ($did = 12) { var %a = $$input(Enter a channel name (e.g. #mychannel),e,Add Channel) | writeini $$xsdir($did(42).seltext) networks $$did(3).seltext $addtok($readini($xsdir($did(42).seltext),networks,$did(3).seltext),%a,44) | did -a $dname 11 %a | if (!$did(11).seltext) { did -c $dname 11 1 } }
    if ($did = 13) { $iif($did(11).lines = 1,remini,writeini) $xsdir($did(42).seltext) networks $$did(3).seltext $iif($did(11).lines > 1,$remtok($readini($xsdir($did(42).seltext),networks,$$did(3).seltext),$did(11).seltext,1,44)) | did -r $dname 11 | if ($readini($xsdir($did(42).seltext),networks,$$did(3).seltext)) { didtok $dname 11 $ifmatch } | did -c $dname 11 1 }
    if ($did = 30) { xserv.ads -stop | xserv.ads -start }
  }
  if ($devent = edit) {
    if ($did = 27) { writeini $xsdir($did(42).seltext) main trigger $$did($did) }
    if ($did = 39) { writeini $xsdir($did(42).seltext) main description $iif($did($did),$ifmatch,No description available) }
    if ($did = 26) { writeini $xsdir($did(42).seltext) ad interval $$did($did) }
  }
}
alias xserv.dlg { dialog -m $1 $$1 }
alias xads {
  if ($1 = -start) {
    xserv.ads -start
    xtdcc.ads -start
    xftp.ads -start
    xdcc.ads -start
  }
  if ($1 = -stop) .timerx*.* off
}
alias xserv.ads {
  if ($1 = -start) {
    .timerxfserv.* off
    var %a = 0
    while (%a < $xserv(0)) {
      inc %a
      if ($readini($xsdir($xserv(%a)),ad,interval) isnum) { .timerxfserv. [ $+ [ %a ] ] -i 0 $calc($readini($xsdir($xserv(%a)),ad,interval) * 60) xserv.ad $xserv(%a) }
    }
    if (%a > 0) xserv.astart File Server
  }
  if ($1 = -stop) {
    .timerxfserv.* off
  }
}
alias xserv.ad {
  var %a = 0, %b, %c = $readini($xsdir($1-),main,networks), %e, %d
  if ($readini($xsdir($1-),main,status) != 1) || ($readini($xsdir($1-),ad,status) != 1) return
  if (!$readini($xsdir($1-),main,directory)) { echo -it2a $xserv.prefix ERROR: Directory not defined for server $1- | return }
  if (!%c) { echo -i2ta $xserv.prefix WARNING: No networks defined for server $1- | return }
  while (%a < $scon(0)) {
    inc %a
    %e = 0
    while (%e < $numtok(%c,44)) {
      inc %e
      if ($gettok(%c,%e,44) iswm $scon(%a).server || $gettok(%c,%e,44) = $scon(%a).network) {
        %b = 0
        %d = $readini($xsdir($1-),networks,$gettok(%c,%e,44))
        while (%b < $numtok(%d,44)) {
          inc %b
          if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xserv.disp($1-).p
        }
      }
    }
  }
}
dialog xserv.input {
  title ""
  size -1 -1 92 25
  option dbu
  combo 1, 1 12 60 50, size drop result edit
  text "", 2, 2 2 90 8
  button "Ok", 3, 63 13 28 9, ok cancel default
}
alias xserv.input {
  set %~xserv.input $iif($1 = -s,s,$iif($1 = -t,t,$iif($1 = -f,f,n)))
  return $dialog(xserv.input,xserv.input)
}  
on *:dialog:xserv.input:*:*:{
  did $iif($did(1),-e,-b)) $dname 3
  if ($devent = init) {
    if (%~xserv.input = n) {
      did -ra $dname 2 Network: (i.e. *.dal.net)
      dialog -t $dname Enter a network name
      var %a = 0 | while (%a < $scon(0)) { inc %a | did -a xserv.input 1 *. $+ $gettok($$scon(%a).server,-2-,46) }
    }
    elseif (%~xserv.input = s) {
      did -ra $dname 2 Server:
      dialog -t $dname Select a file server
      var %a = 0 | while (%a < $xserv(0)) { inc %a | did -a xserv.input 1 $xserv(%a) }
    }
    elseif (%~xserv.input = t) {
      did -ra $dname 2 Server:
      dialog -t $dname Select a tdcc server
      var %a = 0 | while (%a < $xtdcc(0)) { inc %a | did -a xserv.input 1 $xtdcc(%a) }
    }
    elseif (%~xserv.input = f) {
      did -ra $dname 2 Server:
      dialog -t $dname Select an ftp server
      var %a = 0 | while (%a < $xftp(0)) { inc %a | did -a xserv.input 1 $xftp(%a) }
    }
    did -c $dname 1 1
    if (!$did(1).seltext) { dialog -c $dname }
  }
  if ($devent = edit && $did = 1 && %~xserv.input != n) { did -c $dname 1 1 }
}
alias xdisp xserv.dlg xserv.disp
alias xfserv xserv.dlg xserv.fserv
alias xdcc.ads {
  if ($1 = -start) {
    .timerxdcc.* off
    if ($readini($xdcc.sdir,ad,interval) isnum) { .timerxdcc.1 -i 0 $calc($readini($xdcc.sdir,ad,interval) * 60) xdcc.ad }
    if (%a > 0) xserv.astart XDCC
  }
  if ($1 = -stop) {
    .timerxdcc.* off
  }
}
alias xdcc.ad {
  var %a 0, %b 0, %c $readini($xdcc.sdir,main,networks), %e 0, %d
  if ($readini($xdcc.sdir($1-),ad,status) != 1) return
  if (!%c) { echo -i2ta $xserv.prefix WARNING: No networks defined for server $1- | return }
  while (%a < $scon(0)) {
    inc %a
    %e = 0
    while (%e < $numtok(%c,44)) {
      inc %e
      if ($gettok(%c,%e,44) iswm $scon(%a).server || $gettok(%c,%e,44) = $scon(%a).network) {
        %b = 0
        %d = $readini($xdcc.sdir,networks,$gettok(%c,%e,44))
        while (%b < $numtok(%d,44)) {
          inc %b
          if ($readini($xdcc.sdir,ad,type) = 3) {
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(single))
          }
          elseif ($readini($xdcc.sdir,ad,type) = 2) {
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(begin))
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(mid1))
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(mid2))
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(mid3))
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(end))
          }
          else {
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(begin))
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(mid1))
            var %e = 0
            while (%e < $lines($xdcc.pdir)) {
              inc %e
              var %line = $read($xdcc.pdir,%e)
              if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp(%e,$xdcc.style(list1)).long
            }
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(mid3))
            if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xdcc.disp($1-,$xdcc.style(end))
          }
        }
      }
    }
  }
}
alias xserv.shownew {
}
alias xdcc.style { if ($isid) { return $hget($+(xstyle:,$replace($$iif($readini($xdcc.sdir,main,style),$ifmatch,$xserv.style(1)),$chr(32),<space>)),xdcc: $+ $1) } | else { hadd xserv.styles xdcc: $+ $1 $2- } }
alias xfind.file return $+(",$xserv.dir,xfind.dat")
alias xfind.index {
  echo -it2a $xserv.prefix Indexing files for @Find - started at $asctime(h:nnt) $+ ..
  var %` $ticks
  if ($isfile($xfind.file)) { .remove $xfind.file }
  var %a 0, %c 0, %b
  while (%a < $xserv(0)) {
    inc %a
    if ($readini($xsdir($xserv(%a)),main,@find) = 1) {
      inc %c
      %b = $findfile($+(",$readini($xsdir($xserv(%a)),main,directory),"),*,0,write $xfind.file $+($remove($1-,$readini($xsdir($xserv(%a)),main,directory)),$chr(127),$xserv(%a)))
    }
  }
  echo -it2a $xserv.prefix Index complete, %c servers allocated ( $+ $lines($xfind.file) file(s)) - elapsed time: $+($round($calc(($ticks - %`) / 1000),2),s)
}
alias xserv.icon {
  var %` $+(",$xserv.dir,xtras\,$1,.ico")
  if ($isfile(%`)) { return %` }
  else { return $mircexe }
}
alias xserv.mkdserver {
  var %` $iif($?="Name your server.",$ifmatch,$+(Untitled,$r(0000,9999)))
  writeini $xsdir(%`) main trigger $+(!,%`)
  writeini $xsdir(%`) main directory $getdir
  writeini $xsdir(%`) main status off
  writeini $xsdir(%`) main description no description available
  writeini $xsdir(%`) ad status off
  writeini $xsdir(%`) ad interval 30
}
dialog xserv.about {
  title "[xServ] About"
  size -1 -1 63 39
  option dbu
  icon $xserv.icon(about)
  link "zeeg@evilcoder.net", 1, 1 21 50 8
  icon 2, 1 2 15 15, $xserv.icon(pic)
  text "xServ x.x.x", 3, 20 2 41 8
  text "Author: zeeg", 4, 20 11 41 8
  link "www.evilcoder.net", 5, 1 31 46 8
  button "", 6, 53 35 8 4
  edit "", 7, 0 42 63 54, read multi 
}
on *:dialog:xserv.about:*:*:{
  if ($devent = init) {
    did -ra $dname 3 xServ $xbuild
    did -ra $dname 1 $xserv.mail
    did -a $dname 7 Please if you like the addon, share it with your friends. $crlf
    did -a $dname 7 Spread the word, just get me some more ideas that you'd like to see in the addon =)
  }
  if ($devent = sclick) {
    if ($did = 6) { dialog -sb $dname -1 -1 63 96 | did -b $dname 6 }
    if ($did = 1) { run $+(mailto:,$xserv.mail) }
    if ($did = 5) { run http://www.evilcoder.net/ }
  }
}
alias xabout { dialog -m xserv.about xserv.about }
alias xserv.loaddefaults {
  echo -i2ts $xserv.prefix Creating default settings..
  xd loaddefaults
  echo -i2ts $xserv.prefix Loading default styles..
  xd loaddstyles
  set %xstring default
  echo -i2ts $xserv.prefix Creating default file server
  xserv.mkdserver
}
alias -l addtostyle {
  if ($hget(xserv.newstyle)) hfree xserv.newstyle
  hmake xserv.newstyle
  %name = $$1
  if ($isfile($+(",$xserv.dir,fserv.styles\,%name,.hsh"))) hload -b xserv.newstyle $+(",$xserv.dir,fserv.styles\,%name,.hsh")
  hadd xserv.newstyle $$2 $$3-
  hsave -bo xserv.newstyle $+(",$xserv.dir,fserv.styles\,%name,.hsh")
  hfree xserv.newstyle
  cachestyles
}
alias -l createstyle {
  if ($hget(xserv.newstyle)) hfree xserv.newstyle
  hmake xserv.newstyle
  %name = $$1
  hsave -bo xserv.newstyle $+(",$xserv.dir,fserv.styles\,%name,.hsh")
  hfree xserv.newstyle
  cachestyles
}
alias xlist.frmt {
  return $xserv.eval($replace($2-,<triggers>,$$iif($1 = fserv,$xtrigs,$iif($1 = tdcc,$xtdcc.trigs)),<users>,$+($fserv(0),/,$xcfg(users,totalmax)),<users_now>,$fserv(0),<users_max>,$xcfg(users,totalmax),<sends>,$+($send(0),/,$xcfg(sends,totalmax)),<sends_now>,$send(0),<sends_max>,$xcfg(sends,totalmax),<queues>,$+($queue(0),/,$xcfg(queues,totalmax)),<queues_now>,$queue(0),<queues_max>,$xcfg(queues,totalmax),<access>,a lot of,<notes>,Just type one of the triggers,<tcn>,$xcfg(topcps,nick),<next_send>,$xserv.nsend,<lf>,$xcfg(snagged,files),<lb>,$bytes($xcfg(snagged,bytes)).suf,<tcb>,$remove($lower($bytes($xcfg(topcps,bytes)).suf),b) $+ B $+ ps,<bandwidth>,$xserv.bw,<ver>,$xbuild))
}
alias createrules {
  mkdir $+(",$xserv.dir,rules\")
  if ($1 = pirated_software) {
    var %a write $+(",$xserv.dir,rules\pirated_software.txt")
    %a By connecting to this file server
    %a you that you are not affiliated in away way with
    %a a federal agency, government, anti-piracy group,
    %a recording industry, movie industry, or law official agency.
    %a If you are affiliated with any such group in the above list,
    %a you must disconnect from the network immediately. By
    %a issuing any further commands other then quit or exit you agree to the above
    %a statement therefore making all interactions illegal on
    %a your side.
    echo -i2ta $xserv.prefix Rules file "Priated Software" created.
  }
}
alias xserv.style return $remove($nopath($findfile($+(",$xserv.dir,fserv.styles\"),*.hsh,$1)),.hsh)
alias cachestyles var %` 0, %- | while (%` < $xserv.style(0)) { inc %` | %- = $+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)) | if (!$hget(%-)) { hmake %- } | hload -b %- $+(",$xserv.dir,fserv.styles\,$xserv.style(%`),.hsh") }
alias xserv.mkdirs {
  mkdir $+(",$xserv.dir,")
  mkdir $+(",$xserv.dir,fserv.styles\")
  mkdir $+(",$xserv.dir,tmp\")
  mkdir $+(",$xserv.dir,rules\")
}
alias xserv.eval { var %a 0, %string, %nstring = $1-, %find, %nfind
  while (%a < $pos($1-,<eval>,0)) { inc %a | %find $mid($1-,$pos($1-,<eval>,%a),$calc(($pos($1-,</eval>,%a) + 7) - $pos($1-,<eval>,%a))), %nfind $mid($1-,$calc($pos($1-,<eval>,%a) + 6),$calc($pos($1-,</eval>,%a) - ($pos($1-,<eval>,%a) + 6))), %string $eval(%nfind,2), %nstring $replace(%nstring,%find,%string) }
return %nstring }

alias xserv.loadproc {
  if (!$xbuild) { echo -a $xserv.prefix $+(x,S,e,r,v,$chr(32),h,a,s,$chr(32),b,e,e,n,$chr(32),c,o,r,r,u,p,t,e,d,$chr(32),p,l,e,a,s,e,$chr(32),r,e,-,i,n,s,t,a,l,l,.,$chr(32),[,u,n,l,o,a,d,e,d,/,r,e,m,o,v,e,d,$chr(32),t,o,$chr(32),p,r,e,v,e,n,t,$chr(32),a,n,y,$chr(32),d,a,m,a,g,e,],$chr(32),-,$chr(32),r,i,p,p,i,n,g,$chr(32),i,s,$chr(32),g,h,e,y) | .timer 1 1 .remove -b $script | .unload -rs $script }
  if (!$isdir($xserv.dir)) { echo -a $xserv.prefix Error loading xServ, $xserv.dir not found, did you read mr readme.txt? | .unload -rs $script }
  mkdir $+(",$xserv.dir,")
  mkdir $+(",$xserv.dir,fserv.styles")
  xd loaddstyles
  if ($version < 6.03) || ($bits != 32) { echo $colour(info) -sti2 $xserv.prefix xServ+ is only guaranteed to work on mIRC 6.03+ (you can get it at www.mirc.com) }
  if ($version < 6.0) { echo $colour(info) -sti2 $xserv.prefix xServ+ will not run on anything less then mIRC 6.0.. unloading | .unload -rs $script }
  var %~ 0, %- | while (%~ < 12) { inc %~ | if (!$isalias($+(%-,f,%~))) || ($isalias($+(%-,f,%~)).alias = xserv) { var %. = $+(%-,f,%~) | alias %. _xserv | goto cont } }
  %~ 0, %- s | while (%~ < 12) { inc %~ | if (!$isalias($+(%-,f,%~))) || ($isalias($+(%-,f,%~)).alias = xserv) { var %. = $+(%-,f,%~) | alias %. _xserv | goto cont } }
  %~ 0, %- c | while (%~ < 12) { inc %~ | if (!$isalias($+(%-,f,%~))) || ($isalias($+(%-,f,%~)).alias = xserv) { var %. = $+(%-,f,%~) | alias %. _xserv | goto cont } }
  %~ 0, %- sc | while (%~ < 12) { inc %~ | if (!$isalias($+(%-,f,%~))) || ($isalias($+(%-,f,%~)).alias = xserv) { var %. = $+(%-,f,%~) | alias %. _xserv | goto cont } }
  :cont
  if (%.) { %. = $+([or,$chr(32),$replace(%.,f,F,s,Shift,c,Ctrl),]) }
  echo $colour(info) -i2ta $xserv.prefix xServ+ Loaded - Use /xServ for Setup %.
  if ($xserv(0) = 0) { xserv.loaddefaults }
  set %xstring default
  if (!$isfile($xconf)) { xd loaddefaults }
  xserv.savet -h
  qstart
  if ($dialog(xservupdate)) { xupd.echo Installation complete, xServ updated. | xupd.rname Done }
}
dialog xserv.ftp {
  title "[xServ] FTP Servers"
  size -1 -1 205 110
  option dbu
  icon $xserv.icon(fserv), 0
  combo 42, 3 2 50 51, size drop
  box "", 34, 0 13 254 4
  button "New", 43, 56 3 17 9
  button "Delete", 46, 75 3 23 9
  edit "", 39, 92 65 112 10, autohs
  edit "", 25, 92 42 74 10, autohs
  edit "", 27, 92 31 44 10, autohs
  text "Login", 1, 70 32 22 8
  combo 3, 2 31 60 50, size drop
  text "Networks", 6, 3 23 25 8
  button "Add", 7, 6 44 20 9
  button "Delete", 8, 31 44 25 9
  text "Channels", 10, 3 58 25 8
  combo 11, 2 66 60 50, size drop
  button "Add", 12, 6 79 20 9
  button "Delete", 13, 31 79 25 9
  text "Address", 15, 70 43 22 8
  text "Speed", 17, 70 54 22 8
  text "Notes", 18, 70 66 22 8
  box "", 19, 1 90 204 4
  button "&Close", 22, 175 98 30 10, ok cancel
  check "Enable Ad", 23, 71 21 38 10
  text "Interval", 24, 117 22 25 8
  edit "", 26, 143 21 17 10
  text "(in minutes)", 28, 163 22 34 8
  button "Restart Ads", 30, 139 98 33 10
  combo 31, 92 53 111 49, size drop
  text "Style:", 38, 69 80 25 8
  combo 40, 93 80 61 50, size drop
  text "Port", 9, 166 43 15 8, center
  edit "", 14, 182 42 22 10, autohs
  edit "", 16, 160 31 44 10, autohs
  text "Password", 20, 136 32 24 8
}
alias xftp {
  if ($isid) {
    if ($1 = 0) { return $findfile($xserv.dir,*.ftp,0) }
    elseif ($1 !isnum) { return }
    else { return $left($nopath($findfile($xserv.dir,*.ftp,$1)),-4) }
  }
  else dialog $iif($dialog(xserv.ftp),-v,-m) xserv.ftp xserv.ftp
}
alias xserv.ftp {
  if ($1 = 0) { return $findfile($xserv.dir,*.ftp,0) }
  elseif ($1 !isnum) { return }
  else { return $left($nopath($findfile($xserv.dir,*.ftp,$1)),-4) }
}
on *:dialog:xserv.ftp:*:*:{
  if ($devent = INIT) {
    var %a = 0 | did -r $dname 42 | while (%a < $xserv.ftp(0)) { inc %a | did -a $dname 42 $xserv.ftp(%a) }
    did -c $dname 42 1
    xserv.loadftp $did(42).seltext
  }
  var %z = $xftp.sdir($did(42).seltext)
  if ($devent = sclick) {
    if ($did = 43) xftp.do add
    if ($did = 46) xftp.do del $did(42).seltext
    if ($did = 23) writeini %z ad status $did($did).state
    if ($did = 31) writeini %z main speed $did($did).seltext
    if ($did = 40) writeini %z main style $did($did).seltext
    if ($did = 3) { did -r $dname 11 | var %a = 0, %read = $readini(%z,networks,$$did(3).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a xserv.ftp 11 $gettok(%read,%a,44) } | did -c $dname 11 1 }
    if ($did = 7) { var %a = $$xserv.input | writeini %z main networks $addtok($readini(%z,main,networks),%a,44) | did -a $dname 3 %a }
    if ($did = 8) { $iif($did(3).lines = 1,remini,writeini) %z main networks $iif($did(3).lines > 1,$remtok($readini(%z,main,networks),$did(3).seltext,1,44)) | did -r $dname 3 | didtok $dname 3 44 $readini(%z,main,networks) | did -c $dname 3 1 | didtok $dname 11 $readini(%z,networks,$$did(3).seltext) | did -c $dname 11 1 }
    if ($did = 12) { var %a = $$input(Enter a channel name (e.g. #mychannel),e,Add Channel) | writeini %z networks $$did(3).seltext $addtok($readini(%z,networks,$did(3).seltext),%a,44) | did -a $dname 11 %a | if (!$did(11).seltext) { did -c $dname 11 1 } }
    if ($did = 13) { $iif($did(11).lines = 1,remini,writeini) %z networks $$did(3).seltext $iif($did(11).lines > 1,$remtok($readini(%z,networks,$$did(3).seltext),$did(11).seltext,1,44)) | did -r $dname 11 | didtok $dname 11 $readini(%z),networks,$$did(3).seltext) | did -c $dname 11 1 }
    if ($did = 30) xftp.ads start
  }
  if ($devent = edit) {
    if ($did = 26) writeini %z ad interval $iif($did($did),$ifmatch,15)
    if ($did = 27) writeini %z main login $iif($did($did),$ifmatch,anonymous)
    if ($did = 16) writeini %z main password $iif($did($did),$ifmatch,<nickname>)
    if ($did = 25) writeini %z main address $iif($did($did),$ifmatch,$ip)
    if ($did = 14) writeini %z main port $iif($did($did),$ifmatch,21)
    if ($did = 39) writeini %z main notes $iif($did($did),$ifmatch,$chr(32))
  }
}
alias xftp.sdir { return $+(",$xserv.dir,$1-,.ftp") }
alias xserv.loadftp {
  did -ub xserv.ftp 3,7,8,11,12,13,23,26,27,16,25,14,31,39,40,46 | did -r xserv.ftp 3,11,26,25,27,16,14,39,31,40
  if ($1-) {
    did -e xserv.ftp 3,7,8,11,12,13,23,26,27,16,25,14,31,39,40,46
    if (!$readini($xftp.sdir($1-),ad,interval)) { writeini $xftp.sdir($1-) ad interval 15 }
    did -a xserv.ftp 26 $readini($xftp.sdir($1-),ad,interval)
    did -a xserv.ftp 27 $readini($xftp.sdir($1-),main,login)
    did -a xserv.ftp 16 $readini($xftp.sdir($1-),main,password)
    did -ra xserv.ftp 25 $readini($xftp.sdir($1-),main,address)
    did -ra xserv.ftp 14 $readini($xftp.sdir($1-),main,port)
    did -ra xserv.ftp 39 $readini($xftp.sdir($1-),main,notes)
    var %a = 0, %read = 14.4k|28.8k|33.6k|56k|ISDN|DSL|Cable|T1|T3|DS3|OC3|Other|Uber Fast! | while (%a < $numtok(%read,124)) { inc %a | did -a xserv.ftp 31 $gettok(%read,%a,124) | if ($gettok(%read,%a,124) = $readini($xftp.sdir($1-),main,speed)) { did -c xserv.ftp 31 %a } }
    if ($readini($xftp.sdir($1-),ad,status) = 1) did -c xserv.ftp 23
    var %a = 0, %read = $readini($xftp.sdir($1-),main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a xserv.ftp 3 $gettok(%read,%a,44) }
    did -c xserv.ftp 3 1
    var %a = 0, %read = $readini($xftp.sdir($1-),networks,$$did(3).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a xserv.ftp 11 $gettok(%read,%a,44) }
    did -c xserv.ftp 11 1
    did -r xserv.ftp 40
    var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),ftp:ad)) { inc %; | did -a xserv.ftp 40 $xserv.style(%`) | if ($readini($xftp.sdir($1-),main,style) = $xserv.style(%`)) { did -c xserv.ftp 40 %; } } }
  }
}
alias xftp.do {
  if ($1 = add) {
    var %name = $$?="Enter a Server Name"
    var %a = $true
    if ($isfile($xftp.sdir(%name))) { %a = $$input(This Server already exists $+ $chr(44) Overwrite It?) }
    if (%a) {
      var %login = $$?="Enter a login username" 
      var %password = $$?="Enter a password"
      write $xftp.sdir(%name) 
      writeini $xftp.sdir(%name) main address $ip
      writeini $xftp.sdir(%name) main port 21
      writeini $xftp.sdir(%name) main login %login
      writeini $xftp.sdir(%name) main password %password
      writeini $xftp.sdir(%name) main notes Check out my FTP!
      writeini $xftp.sdir(%name) main name %name
      writeini $xftp.sdir(%name) ad status 0
      writeini $xftp.sdir(%name) ad interval 15
      $iif($dialog(xserv.ftp),did -a xserv.ftp 42 %name)
      if (!$did(xserv.ftp,42).sel) { did -c xserv.ftp 42 1 }
      xserv.loadftp $did(xserv.ftp,42).seltext
    }
  }
  elseif ($1 = del && $isfile($xftp.sdir($2-))) {
    .remove $xftp.sdir($2-)
    did -r xserv.ftp 42
    var %a = 0 | did -r xserv.ftp 42 | while (%a < $xserv.ftp(0)) { inc %a | did -a xserv.ftp 42 $xserv.ftp(%a) }
    did -c $dname 42 1
    xserv.loadftp $did(42).seltext
  }
}
alias xftp.ads {
  if ($1 = -start) {
    .timerxftp.* off
    var %a = 0
    while (%a < $xftp(0)) {
      inc %a
      if ($readini($xftp.sdir($xftp(%a)),ad,interval) isnum) { .timerxftp. [ $+ [ %a ] ] -i 0 $calc($readini($xftp.sdir($xftp(%a)),ad,interval) * 60) xftp.ad $xftp(%a) }
    }
    if (%a > 0) xserv.astart FTP
  }
  if ($1 = -stop) {
    .timerxftp.* off
  }
}
alias xftp.ad {
  var %a = 0, %b, %c = $readini($xftp.sdir($1-),main,networks), %e, %d
  if ($readini($xftp.sdir($1-),ad,status) != 1) return
  if (!%c) { echo -i2ta $xserv.prefix WARNING: No networks defined for server $1- | return }
  while (%a < $scon(0)) {
    inc %a
    %e = 0
    while (%e < $numtok(%c,44)) {
      inc %e
      if ($gettok(%c,%e,44) iswm $scon(%a).server || $gettok(%c,%e,44) = $scon(%a).network) {
        %b = 0
        %d = $readini($xftp.sdir($1-),networks,$gettok(%c,%e,44))
        while (%b < $numtok(%d,44)) {
          inc %b
          if ($ison(%a,$gettok(%d,%b,44))) scon %a msg $gettok(%d,%b,44) $xftp.disp($1-).p
        }
      }
    }
  }
}
alias xftp.disp {
  var %xsdir, %txt
  if ($prop) { %xsdir = $xftp.sdir($1-) | %txt = $hget($+(xstyle:,$replace($$iif($readini(%xsdir,main,style),$ifmatch,$xserv.style(1)),$chr(32),<space>)),ftp:ad) }
  else { %xsdir = $xftp.sdir($xftp(1)) | %txt = $1- }
  return $xserv.eval($replace(%txt,<me>,$me,<next_send>,$xserv.nsend,<ver>,$xbuild,<login>,$readini(%xsdir,main,login),<password>,$readini(%xsdir,main,password),<address>,$readini(%xsdir,main,address),<port>,$readini(%xsdir,main,port),<speed>,$readini(%xsdir,main,speed),<notes>,$readini(%xsdir,main,notes),<lf>,$xcfg(snagged,files),<lb>,$lower($bytes($xcfg(snagged,bytes)).suf),<tcn>,$xcfg(topcps,nick),<tcb>,$remove($lower($bytes($xcfg(topcps,bytes)).suf),b) $+ B $+ ps,<uptime>,$xserv.uptime))
}
alias xftp.show { say $iif(c isincs $chan($active).mode,$strip($xftp.disp($$1-).p,c),$xftp.disp($$1-).p) }
alias xserv.astart echo -i2ta $xserv.prefix $1- advertisements started succesfully
alias xserv.req
dialog xserv.req {
  title "[xServ] Request Ads"
  size -1 -1 205 108
  option dbu
  icon $xserv.icon(fserv), 0
  combo 42, 3 2 50 51, size drop
  box "", 34, 0 13 254 4
  button "New", 43, 56 3 17 9
  button "Delete", 46, 75 3 23 9
  edit "", 39, 89 60 112 10, autohs
  combo 3, 2 31 60 50, size drop
  text "Networks", 6, 3 23 25 8
  button "Add", 7, 6 44 20 9
  button "Delete", 8, 31 44 25 9
  text "Channels", 10, 3 58 25 8
  combo 11, 2 66 60 50, size drop
  button "Add", 12, 6 79 20 9
  button "Delete", 13, 31 79 25 9
  text "Request", 18, 67 61 22 8
  box "", 19, 1 89 204 4
  button "&Close", 22, 175 96 30 10, ok cancel
  check "Enable Ad", 23, 70 48 38 10
  text "Interval", 24, 116 49 25 8
  edit "", 26, 142 48 17 10
  text "(in minutes)", 28, 162 49 34 8
  button "Restart Ads", 30, 139 96 33 10
  text "Style:", 38, 67 75 23 8
  combo 40, 90 75 61 50, size drop
  text "These are per-ad settings, they will only apply to the selected ad in the list above", 1, 71 20 126 25
}
alias xserv.banf return $+(",$xserv.dir,bans.dat")
alias -l isban var %a 0 | while (%a < $lines($xserv.banf)) { inc %a | if ($gettok($read($xserv.banf,%a),1,124) iswm $1) { return $true } } | return $false
alias xserv.ban {
  if ($1 = -u) {
    var %a 0 | while (%a < $lines($xserv.banf)) { inc %a | if ($gettok($read($xserv.banf,%a),1,124) iswm $2) { write $+(-dl,%a) $xserv.banf | dec %a } }
    echo -it2a $xserv.prefix Removed all bans matching: $2
  }
  else {
    var %reason $?="Enter a reason [Optional]", %expire $?="Expiration Date [Optional, e.g. Oct 30 2002 1:31pm]"
    write $xserv.banf $+($1,|,%reason,|,%expire)
    echo -it2a $xserv.prefix Banned: $1 - Expires: $iif($ctime(%expire),$asctime($ctime(%expire)),Never)
  }
}
alias xserv.mail return zeeg@evilcoder.net
alias ison scon $1 return $!iif($me ison $2,$true,$false)
alias xserv.mkprestyle {
  if ($1 = default) {
    createstyle default
    addtostyle default ad xServ04! <ver>, 04(online for <uptime>04) 04< trigger: <triggers> 04/ online: <users_now> 04[<users_max> max04] 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04] 04> <notes>
    addtostyle default tdcc:ad xTDCC04! 04< file: <filename> 04[<size>04] 04/ trigger: <trigger> 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04] 04> <notes> 04< <hits> downloads!
    addtostyle default xdcc:begin xServ04! <ver> Send04[<sends_now>04/<sends_max>04] Queues04[<queues_now>04/<queues_max>04] Record04[<tcb> by <tcn>04]
    addtostyle default xdcc:mid1 Syntax:04 /ctcp <me> XDCC Send #<pack number>
    addtostyle default xdcc:mid2 4[#?04] - Type 04/ctcp <me> XDCC list
    addtostyle default xdcc:list1 4[#<number>04] 04- <desc> 04- <file> 04[<hits>x04]
    addtostyle default xdcc:mid3 Snagged04[<lb> 04/ <lf> Files04] Current04[<bandwidth>04] Packs04[<packs>04]
    addtostyle default xdcc:end Note: <notes>
    addtostyle default fserv:!list [File Server(s)] <triggers>
    addtostyle default tdcc:!list [TDCC Server(s)] <triggers>
    addtostyle default ad xServ04! <ver>, 04(online for <uptime>04) 04< trigger: <triggers> 04/ online: <users_now> 04[<users_max> max04] 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04] 04> <notes>
    addtostyle default ftp:ad xServ04! <ver> 04< ftp: ftp://<login>:<password>@<address>:<port> 04/ speed: <speed> 04> <notes>
    addtostyle default fserv:!list xServ04! <ver> 04< trigger: <triggers> 04/ online: <users_now> 04[<users_max> max04] 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04]
    addtostyle default tdcc:!list xServ04! <ver> 04< trigger: <triggers> 04/ files queued: <queues_now> 04[<queues_max> max04] 04/ current sends: <sends_now> 04[<sends_max> max04]
    addtostyle default name Default
    addtostyle default version 1.1r
    addtostyle default author zeeg
    addtostyle default email zeeg@evilcoder.net
    addtostyle default url www.evilcoder.net
  }
}
alias xs.chk { if ($sock(xs.chk)) { return } | set %xupd.chk | sockopen xs.CHK evilcoder.net 80 | xs.ECHO Connecting to update server... }
alias xs.GET { if ($sock(xs.get)) { return } | sockopen xs.GET evilcoder.net 80 }
alias xs.ECHO { xs | did -ra xs 6 $1- }
alias xs.write { xs | did -a xs 2 $1- | did -z xs 2 }
alias xs { if ($dialog(xs)) { dialog -v xs } | else { dialog -m xs xs } }
on *:sockopen:xs.CHK:{
  xs.ECHO Connected. Getting file list..
  sockwrite -n $sockname GET /xserv/styles.txt HTTP/1.0
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Host: evilcoder.net
  sockwrite -n $sockname $crlf
}
on *:sockopen:xs.GET:{
  if (!%!xs.style) { sockclose $sockname | return }
  sockwrite -nt $sockname GET /xserv/styles/ $+ %!xs.style
  write -c $+(",%!xs.style_new,")
  xs.ECHO Requesting download: %!xs.style
  did -b xs 4
}
on *:sockread:xs.GET:{
  if ($sockerr > 0) { xs.ECHO Error downloading %!xs.style | did -e xs 4 | return }
  :n
  sockread 4096 &n
  if ($sockbr) {
    inc %!xstyle.dl
    if (!%!xstyle.dl || %!xstyle.dl > 3) { set %!xstyle.dl 1 }
    xs.echo Downloading %!xs.style - $iif(%!xstyle.dl = 1,/,$iif(%!xstyle.dl = 2,|,\))
    bwrite $+(",%!xs.style_new,") -1 -1 &n
    goto n
  }
}
on *:sockclose:xs.CHK:xs.ECHO $iif(%i,$ifmatch,0) Styles found | unset %i, %!
on *:sockclose:xs.GET:xs.ECHO Style Saved: %!xs.style | did -e xs 4 | cachestyles | unset %!!!
on *:sockread:xs.CHK:{
  if ($sockerr > 0) { xs.ECHO Unable to connect | return }
  set %i 0
  :z | sockread -f %z
  tokenize 124 %z
  if (!$1-) return
  if (%!) xs.write $3 ( $+ $1 $+ ) by $2
  if (*etag* iswm $1-) set %! 1
  inc %i
  goto z
}
dialog xs {
  title "[xServ] Download Styles"
  size -1 -1 129 103
  option dbu
  icon $xserv.icon(update), 0
  button "Done", 1, 108 81 20 10, ok cancel
  list 2, 1 9 127 70, size hsbar
  text "Available Styles:", 3, 2 1 87 8
  button "Save As..", 4, 1 81 33 10
  button "Refresh", 5, 82 81 24 10, default
  edit "", 6, -1 93 130 10, read
  text "<- Click to Install", 7, 36 82 45 8
}
on *:dialog:xs:*:*:{
  if ($devent = init) xs.chk
  if ($devent = sclick) {
    if ($did = 5) { did -r xs 2 | xs.chk }
    if ($did = 4) { set %!xs.style $gettok($did(2).seltext,1,32) | set %!xs.style_new $$sfile(xdb\fserv.styles\ $+ %!xs.style,Save this as what?) | xs.get }
  }
}
alias -l getnet {
  if ($prop = fserv) {
    var %a 0, %b, %nets
    while (%a < $xserv(0)) {
      inc %a
      %nets = $readini($xsdir($xserv(%a)),main,networks)
      %b = 0
      while (%b < $numtok(%nets,44)) {
        inc %b
        if ($gettok(%nets,%b,44) iswm $1 || $gettok(%nets,b,44) = $2) {
          return $readini($xsdir($xserv(%a)),networks,$gettok(%nets,%b,44))
        }
      }
    }
  }
  if ($prop = tdcc) {
    var %a 0, %b, %nets
    while (%a < $xtdcc(0)) {
      inc %a
      %nets = $readini($xtdcc.sdir($xtdcc(%a)),main,networks)
      %b = 0
      while (%b < $numtok(%nets,44)) {
        inc %b
        if ($gettok(%nets,%b,44) iswm $1 || $gettok(%nets,b,44) = $2) {
          return $readini($xtdcc.sdir($xtdcc(%a)),networks,$gettok(%nets,%b,44))
        }
      }
    }
  }
}
alias -l trigok {
  if ($prop = fserv) {
    var %a 0, %b, %nets
    while (%a < $xserv(0)) {
      inc %a
      %nets = $readini($xsdir($xserv(%a)),main,networks)
      if ($readini($xsdir($xserv(%a)),main,trigger) = $4-) {
        %b = 0
        while (%b < $numtok(%nets,44)) {
          inc %b
          if ($gettok(%nets,%b,44) iswm $1 || $gettok(%nets,b,44) = $2) {
            if ($istok($readini($xsdir($xserv(%a)),networks,$gettok(%nets,%b,44)),$3,44)) return $true
            return $false
          }
        }
      }
    }
  }
  if ($prop = tdcc) {
    var %a 0, %b, %nets
    while (%a < $xtdcc(0)) {
      inc %a
      %nets = $readini($xtdcc.sdir($xtdcc(%a)),main,networks)
      if ($readini($xtdcc.sdir($xtdcc(%a)),main,trigger) = $4-) {
        %b = 0
        while (%b < $numtok(%nets,44)) {
          inc %b
          if ($gettok(%nets,%b,44) iswm $1 || $gettok(%nets,b,44) = $2) {
            if ($istok($readini($xtdcc.sdir($xtdcc(%a)),networks,$gettok(%nets,%b,44)),$3,44)) return $true
            return $false
          }
        }
      }
    }
  }
}


#####
# Work in progress go away
#####

alias mdx_fullpath { return $+(",$mircdirxdb\lib\mdx.dll,") }

alias mdx dll $mdx_fullpath $1-

alias mdxinit {
  dll $mdx_fullpath SetMircVersion $version
  dll $mdx_fullpath MarkDialog $dname
}
dialog _xserv {
  title "xServ Configuration"
  size -1 -1 284 133
  option dbu
  list 1, 1 2 66 111, size
  button "&Close", 2, 255 119 28 12, default ok cancel
  box "User settings", 11, 71 4 59 25
  edit "", 13, 106 15 20 10, autohs
  text "Max users:", 14, 75 16 29 8
  box "DCC Sends", 16, 71 41 59 69
  edit "", 18, 106 51 20 10, autohs
  text "Max sends:", 19, 75 52 29 8
  text "(per user)", 17, 75 63 25 8
  edit "", 20, 106 62 20 10, autohs
  check "Disable transfers", 21, 75 97 50 10
  check "Disable queues", 23, 142 97 50 10
  edit "", 24, 176 76 20 10, autohs
  edit "", 25, 176 87 20 10, autohs
  text "(per user)", 26, 142 88 25 8
  text "Max queues:", 27, 142 77 32 8
  list 28, 219 4 62 88, size
  button "Toggle item On/Off", 29, 219 98 62 12
  box "DCC Queues", 30, 137 65 63 45
  box "CPS Limits", 22, 137 4 79 52
  edit "", 31, 166 16 23 10, autohs
  edit "", 32, 166 27 23 10, autohs
  text "(per user)", 33, 140 28 25 8
  text "Max CPS:", 34, 140 17 25 8
  text "}", 36, 188 17 7 20
  check "On", 37, 195 22 18 10
  text "Min CPS:", 35, 140 43 25 8
  edit "", 38, 166 42 23 10, autohs
  check "On", 39, 195 42 18 10
  check "Instant Send", 12, 75 73 50 10
  text "Filesize (kb):", 40, 75 85 31 8
  edit "", 15, 106 84 20 10, autohs
  text "Your Servers", 4, 71 4 33 8
  list 5, 71 13 60 76, size
  button "<", 6, 133 14 21 10
  button ">", 7, 133 26 21 10
  button "All >", 8, 133 51 21 10
  button "< All", 9, 133 39 21 10
  list 10, 156 14 60 76, size
  text "Servers Active", 41, 156 5 38 8
  text "", 43, 218 6 64 106
  check "Enable @Find", 45, 72 102 50 10
  box "", 3, 0 112 284 4
  check "Index Directories", 42, 157 92 53 10
  check "Index at startup", 44, 157 102 53 10
  button "Refresh", 46, 133 78 21 10
  box "TDCC", 47, 185 3 81 71
  box "File Servers", 48, 85 3 81 71
  text "Display Style", 49, 90 13 42 8
  check "Respond to !list", 51, 89 61 50 10
  check "Respond to !list", 52, 189 61 50 10
  text "Display Style", 54, 190 13 48 8
  text "", 55, 70 78 212 35
  list 50, 89 22 73 37, size
  list 53, 189 22 73 37, size
  box "Global Options", 56, 205 93 79 23
  button "New", 57, 214 103 27 9
  button "Delete", 58, 249 103 27 9
  list 59, 184 12 96 67, size
  text "Local Options", 60, 185 3 93 8
  button "Change", 61, 185 81 26 10
  box "Advertisement Configuration", 62, 71 2 109 109
  combo 63, 77 22 71 50, size drop
  text "IRC Networks", 64, 77 12 92 8
  button "+", 65, 150 23 11 9
  button "-", 66, 163 23 11 9
  text "Channels (for network listed above)", 67, 77 36 88 8
  combo 68, 77 46 71 50, size drop
  check "Enable timed advertisement", 71, 77 58 79 10
  button "Run ad now", 72, 85 97 37 10
  button "Restart timer", 73, 131 97 37 10
  button "+", 69, 150 47 11 9
  button "-", 70, 163 47 11 9
  text "Interval (in minutes):", 74, 77 69 55 8
  edit "", 75, 135 68 24 10
  box "", 76, 72 90 107 4
  text "Display Style:", 77, 77 81 36 8
  combo 78, 116 80 60 50, size drop
  text "<- or double-click an item", 79, 213 82 67 8
  box "Packages", 80, 183 2 99 60
  text "Ad Style:", 81, 184 71 25 8
  combo 82, 210 70 72 50, size drop
  combo 83, 188 11 62 50, size drop
  box "", 84, 184 22 97 4
  button "+", 85, 254 12 11 9
  button "-", 86, 267 12 11 9
  text "File:", 87, 186 33 11 8
  text "Desc:", 88, 186 47 15 8 autohs
  edit "", 89, 203 32 62 10, read autohs
  edit "", 90, 203 46 76 10, autohs
  button "Set", 91, 267 33 12 8
  text "Notes:", 92, 184 87 24 8
  edit "", 93, 209 86 73 20, multi
}
alias _xconfig return $+(",$mircdirxdb\xserv.ini")
on *:dialog:_xserv:*:*:{
  var %i $devent, %n $did, %c $dname, %s $iif($gettok($did(1,1),4,32) = 3,$xserv($calc($gettok($did(%c,1,1),5,32) - 1)),$iif($gettok($did(1,1),4,32) = 4,$xftp($calc($gettok($did(%c,1,1),5,32) - 1)),$xtdcc($calc($gettok($did(%c,1,1),5,32) - 1))))
  if (%i = init) {
    mdxinit
    mdx SetControlMDX %c 1 TreeView haslines linesatroot hasbuttons fullrowselect > xdb\lib\views.mdx
    mdx SetControlMDX %c 28 ListView showsel report > xdb\lib\views.mdx
    mdx SetControlMDX %c 59 ListView single showsel report noheader > xdb\lib\views.mdx
    did -i %c 28 1 headerdims 84:all 34:all
    did -i %c 28 1 headertext Item $+ $chr(9) $+ On
    did -i %c 59 1 headerdims 107:all 65:all
    did -i %c 59 1 headertext Option $+ $chr(9) $+ $chr(32)
    mdx SetFont %c 36 34 700 Arial
    _xserv.dialog itree
    _xserv.dialog lview main
    _xserv.dialog lview fserv.opt
    _xserv.dialog hidetabs
    _xserv.dialog showtab Main
    var %n
    if (!$readini($_xconfig,users,totalmax)) writeini $_xconfig users totalmax 2
    did -ra %c 13 $readini($_xconfig,users,totalmax)
    if (!$readini($_xconfig,sends,totalmax)) writeini $_xconfig sends totalmax 2
    did -ra %c 18 $readini($_xconfig,sends,totalmax)
    if (!$readini($_xconfig,sends,usermax)) writeini $_xconfig sends usermax 1
    did -ra %c 20 $readini($_xconfig,sends,usermax)
    did -ra %c 15 $readini($_xconfig,isend,bytes)
    did $iif($readini($_xconfig,isend,status) = 1,-c,-u) %c 12
    did $iif($did(12).state = 1,-e,-b) %c 15
    did $iif($readini($_xconfig,sends,disable) = 1,-c,-u) %c 21
    did $iif($did(21).state = 0,-e,-b) %c 12,15,18,20
    did -ra %c 31 $readini($_xconfig,maxcps,total)
    did -ra %c 32 $readini($_xconfig,maxcps,user)
    did $iif($readini($_xconfig,maxcps,status) = 1,-c,-u) %c 37
    did $iif($did(37).state = 1,-e,-b) %c 31,32
    did -ra %c 38 $readini($_xconfig,mincps,bytes)
    did $iif($readini($_xconfig,mincps,status) = 1,-c,-u) %c 39
    did $iif($did(39).state = 1,-e,-b) %c 38
    if (!$readini($_xconfig,queues,totalmax)) writeini $_xconfig queues totalmax 10
    did -ra %c 24 $readini($_xconfig,queues,totalmax)
    if (!$readini($_xconfig,queues,usermax)) writeini $_xconfig queues usermax 4
    did -ra %c 25 $readini($_xconfig,queues,usermax)
    did $iif($readini($_xconfig,queues,disable) = 1,-c,-u) %c 23
    did $iif($did(23).state = 0,-e,-b) %c 24,25
    did -b %c 29
    _xserv.dialog ihelp @find
    _xserv.dialog ihelp !list
    _xserv.dialog lview @find
    if ($readini($_xconfig,@find,onstartup) = 1) did -c %c 44
    if ($readini($_xconfig,@find,index) = 1) did -c %c 42
    if ($readini($_xconfig,@find,status) = 1) did -c %c 45
    did $iif($did(42).state = 1,-e,-b) %c 44
    did $iif($did(45).state = 1,-e,-b) %c 5,6,7,8,9,10,46,42,44
    did $iif($readini($_xconfig,!list,fstatus) = 1,-c,-u) %c 51
    did $iif($did(51).state = 1,-e,-b) %c 50
    did $iif($readini($_xconfig,!list,tstatus) = 1,-c,-u) %c 52
    did $iif($did(52).state = 1,-e,-b) %c 53
    var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),tdcc:!list)) { inc %; | did -a %c 50 $xserv.style(%`) | if ($readini($_xconfig,!list,tdcc) = $xserv.style(%`)) { did -c %c 50 %; } } }
    var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),fserv:!list)) { inc %; | did -a %c 53 $xserv.style(%`) | if ($readini($_xconfig,!list,fserv) = $xserv.style(%`)) { did -c %c 53 %; } } }
  }
  if (%i = edit) {
    if (%_!debug) echo -a Edited $did
    if (%n = 13) writeini $_xconfig users totalmax $iif($did(%n),$ifmatch,0)
    if (%n = 18) writeini $_xconfig sends totalmax $iif($did(%n),$ifmatch,0)
    if (%n = 20) writeini $_xconfig sends usermax $iif($did(%n),$ifmatch,0)
    if (%n = 15) writeini $_xconfig isend bytes $iif($did(%n),$ifmatch,0)
    if (%n = 31) writeini $_xconfig maxcps total $iif($did(%n),$ifmatch,0)
    if (%n = 32) writeini $_xconfig maxcps user $iif($did(%n),$ifmatch,0)
    if (%n = 38) writeini $_xconfig mincps bytes $iif($did(%n),$ifmatch,0)
    if (%n = 24) writeini $_xconfig queues totalmax $iif($did(%n),$ifmatch,0)
    if (%n = 25) writeini $_xconfig queues usermax $iif($did(%n),$ifmatch,0)
    if (%n = 75) {
      if ($gettok($did(1,1),4,32) = 3) {
        writeini $xsdir(%s) ad interval $did(%n)
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        writeini $xftp.sdir(%s) ad interval $did(%n)
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        writeini $xtdcc.sdir(%s) ad interval $did(%n)
      }
      elseif ($gettok($did(1,1),4,32) = 6) {
        writeini $xdcc.sdir ad interval $did(%n)
      }
    }
    if (%n = 90) { write $+(-l,$$did(83).sel) $xdcc.pdir $+($gettok($read($xdcc.pdir,$did(83).sel),1,127),,$did(%n)) }
    if (%n = 93) writeini $xdcc.sdir main notes $$did(%n)
  }
  if (%i = sclick) {
    if (%_!debug) echo -a Clicked $did
    if (%n = 1) {
      tokenize 32 $did(1,1)
      hadd xserv.dialog treesel $4-
      _xserv.dialog hidetabs
      if ($4- = 2) _xserv.dialog showtab main
      if ($4- = 2 2) _xserv.dialog showtab @find
      if ($4- = 2 3) _xserv.dialog showtab !list
      if ($4 = 3) && ($5) _xserv.dialog showtab fserv.conf
      if ($4 = 3) && (!$5) _xserv.dialog showtab fserv.main
      if ($4 = 4) && ($5) _xserv.dialog showtab ftp.conf
      if ($4 = 4) && (!$5) _xserv.dialog showtab ftp.main
      if ($4 = 5) && ($5) _xserv.dialog showtab tdcc.conf
      if ($4 = 5) && (!$5) _xserv.dialog showtab tdcc.main
      if ($4 = 6) _xserv.dialog showtab xdcc
    }
    if (%n = 6 && $did(10).seltext) { writeini $xsdir($xserv($did(10).sel)) main @find 0 | did -d %c 10 $did(10).sel }
    if (%n = 7 && $did(5).seltext) { writeini $xsdir($xserv($did(5).sel)) main @find 1 | did -a %c 10 $did(5).seltext }
    if (%n = 8) { var %` 0 | while (%` < $xserv(0)) { inc %` | writeini $xsdir($xserv(%`)) main @find 1 | did -a %c 10 $xserv(%`) } }
    if (%n = 9) { var %` 0 | while (%` < $xserv(0)) { inc %` | writeini $xsdir($xserv(%`)) main @find 0 } | did -r %c 10 }
    if (%n = 46) _xserv.dialog lview @find
    if (%n = 44) writeini $_xconfig @find onstartup $did($did).state
    if (%n = 42) {
      writeini $_xconfig @find index $did($did).state
      did $iif($did(%n).state = 1,-e,-b) %c 44
    }
    if (%n = 45) {
      writeini $_xconfig @find status $did($did).state
      did $iif($did(%n).state = 1,-e,-b) %c 5,6,7,8,9,10,46,42,44
    }
    if (%n = 12) {
      writeini $_xconfig isend status $did(%n).state
      did $iif($did(%n).state = 1,-e,-b) %c 15
    }
    if (%n = 21) {
      writeini $_xconfig sends disable $did(%n).state
      did $iif($did(%n).state = 0,-e,-b) %c 12,15,18,20
    }
    if (%n = 37) {
      writeini $_xconfig maxcps status $did(%n).state
      did $iif($did(%n).state = 1,-e,-b) %c 31,32
    }
    if (%n = 39) {
      writeini $_xconfig mincps status $did(%n).state
      did $iif($did(%n).state = 1,-e,-b) %c 38
    }
    if (%n = 23) {
      writeini $_xconfig queues disable $did(%n).state
      did $iif($did(%n).state = 0,-e,-b) %c 24,25
    }
    if (%n = 28) did -e %c 29
    if (%n = 29) {
      var %h $gettok($gettok($did(28).seltext,1,9),6-,32), %o
      if (%h = Command: find) %o = @find
      if (%h = Channel Guard) %o = changuard
      if (%h = Kick Campers) %o = kickcamp
      if (%h = Ban Campers) %o = bancamp
      if (%h = Kick Idlers) %o = kickidle
      if (%h = Ban Idlers) %o = banidle
      if (%h = Clone Guard) %o = cloneguard
      if (%h = FServ Chat) %o = fchat
      writeini $_xconfig main %o $iif($readini($_xconfig,main,%o) = 1,0,1)
      _xserv.dialog lview main
    }
    if (%n = 51) {
      writeini $xconf !list fstatus $$did(%n).state
      did $iif($did(%n).state = 1,-e,-b) %c 50
    }
    if (%n = 52) {
      writeini $xconf !list tstatus $$did(%n).state
      did $iif($did(%n).state = 1,-e,-b) %c 53
    }
    if (%n = 50) writeini $_xconfig !list fserv $did($did).seltext
    if (%n = 53) writeini $_xconfig !list tdcc $did($did).seltext
    if (%n = 71) {
      if ($gettok($did(1,1),4,32) = 3) {
        writeini $xsdir(%s) ad status $did(%n).state
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        writeini $xftp.sdir(%s) ad status $did(%n).state
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        writeini $xtdcc.sdir(%s) ad status $did(%n).state
      }
      elseif ($gettok($did(1,1),4,32) = 6) {
        writeini $xdcc.sdir ad status $did(%n).state
      }
      did $iif($did(%n).state = 1,-e,-b) %c 75
    }
    if (%n = 78) {
      if ($gettok($did(1,1),4,32) = 3) {
        writeini $xsdir(%s) main style $did(%n)
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        writeini $xftp.sdir(%s) main style $did(%n)
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        writeini $xtdcc.sdir(%s) main style $did(%n)
      }
      elseif ($gettok($did(1,1),4,32) = 6) {
        writeini $xdcc.sdir main style $did(%n)
      }
    }
    if (%n = 59) did -e %c 61
    if (%n = 63) {
      if ($gettok($did(1,1),4,32) = 3) var %z $xsdir(%s)
      elseif ($gettok($did(1,1),4,32) = 4) var %z $xftp.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 5) var %z $xtdcc.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 6) var %z $xdcc.sdir
      did -e %c %n
      did -r %c 68
      var %a = 0, %read = $readini(%z,networks,$$did(%n).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 68 $gettok(%read,%a,44) }
      did -c %c 68 1
      did $iif($did(68),-e,-b) %c 70
    }
    if (%n = 65) {
      if ($gettok($did(1,1),4,32) = 3) var %z $xsdir(%s)
      elseif ($gettok($did(1,1),4,32) = 4) var %z $xftp.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 5) var %z $xtdcc.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 6) var %z $xdcc.sdir
      writeini %z main networks $addtok($readini(%z,main,networks),$$xserv.input,44)
      did -r %c 63,68
      var %a = 0, %read = $readini(%z,main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 63 $gettok(%read,%a,44) }
      did -c %c 63 1
      did $iif($did(63).seltext,-e,-b) %c 66,68,69,70
      var %a = 1, %read = $readini(%z,networks,$$did(63).seltext) | while ($gettok(%read,%a,44)) { did -a %c 68 $gettok(%read,%a,44) | inc %a }
      did -c %c 68 1
      did $iif($did(68).seltext,-e,-b) %c 70
    }
    if (%n = 66) {
      if ($gettok($did(1,1),4,32) = 3) var %z $xsdir(%s)
      elseif ($gettok($did(1,1),4,32) = 4) var %z $xftp.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 5) var %z $xtdcc.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 6) var %z $xdcc.sdir
      var %a $readini(%z,main,networks)
      $iif($numtok(%a,44) = 1,remini,writeini) %z main networks $$remtok(%a,$did(63).seltext,44)
      remini %z networks $result
      did -r %c 63,68
      var %a = 0, %read = $readini(%z,main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 63 $gettok(%read,%a,44) }
      did -c %c 63 1
      did $iif($did(63).seltext,-e,-b) %c 66,68,69,70
      var %a = 1, %read = $readini(%z,networks,$$did(63).seltext) | while ($gettok(%read,%a,44)) { did -a %c 68 $gettok(%read,%a,44) | inc %a }
      did -c %c 68 1
      did $iif($did(68).seltext,-e,-b) %c 70
    }
    if (%n = 69) {
      if ($gettok($did(1,1),4,32) = 3) var %z $xsdir(%s)
      elseif ($gettok($did(1,1),4,32) = 4) var %z $xftp.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 5) var %z $xtdcc.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 6) var %z $xdcc.sdir
      var %a = $$input(Enter a channel name (e.g. #mychannel),e,Add Channel)
      writeini %z networks $did(63).seltext $addtok($readini(%z,networks,$did(63).seltext),%a,44)
      did -r %c 68
      var %a = 1, %read = $readini(%z,networks,$$did(63).seltext) | while ($gettok(%read,%a,44)) { did -a %c 68 $gettok(%read,%a,44) | inc %a }
      did -c %c 68 1
      did $iif($did(68).seltext,-e,-b) %c 70
    }
    if (%n = 70) {
      if ($gettok($did(1,1),4,32) = 3) var %z $xsdir(%s)
      elseif ($gettok($did(1,1),4,32) = 4) var %z $xftp.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 5) var %z $xtdcc.sdir(%s)
      elseif ($gettok($did(1,1),4,32) = 6) var %z $xdcc.sdir
      var %a $readini(%z,networks,$did(63).seltext)
      $iif($numtok(%a,44) = 1,remini,writeini) %z networks $did(63).seltext $remtok(%a,$did(68).seltext,44)
      did -r %c 68
      var %a = 1, %read = $readini(%z,networks,$$did(63).seltext) | while ($gettok(%read,%a,44)) { did -a %c 68 $gettok(%read,%a,44) | inc %a }
      did -c %c 68 1
      did $iif($did(68).seltext,-e,-b) %c 70
    }
    if (%n = 72) {
      if ($gettok($did(1,1),4,32) = 3) {
        xserv.ad %s
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        xftp.ad %s
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        xtdcc.ad %s
      }
      elseif ($gettok($did(1,1),4,32) = 6) {
        xdcc.ad %s
      }
    }
    if (%n = 73) {
      if ($gettok($did(1,1),4,32) = 3) {
        xserv.ads -start
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        xftp.ads -start
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        xtdcc.ads -start
      }
      elseif ($gettok($did(1,1),4,32) = 6) {
        xdcc.ads -start
      }
    }
    if (%n = 61) {
      set %_xservd.server %s
      set %_xservd.thing $gettok($gettok($did(59).seltext,1,9),6-,32)
      var %a %_xservd.thing
      if (%a = Server) var %t Onoff, %b main,status
      if (%a = Trigger) var %t Edit, %b main,trigger
      if (%a = Directory) var %t Dir, %b main,directory
      if (%a = MOTD) var %t File, %b motd,file
      if (%a = Display Motd?) var %t YesNo, %b motd,show
      if (%a = Rules) var %t File, %b rules,file
      if (%a = Use Rules?) var %t YesNo, %b rules,show
      if (Desc* iswm %a) var %t Edit, %b main,description
      if (%a = CTCP Trigger?) var %t TriggerType, %b main,type
      if (%a = Address) var %t edit, %b main,address
      if (%a = Port) var %t edit, %b main,port
      if (%a = Username) var %t edit, %b main,login
      if (%a = Password) var %t edit, %b main,password
      if (%a = Speed) var %t edit, %b main,speed
      if (%a = Notes) var %t edit, %b main,notes
      if (%a = File) var %t file, %b main,file
      if (Allow* iswm %a) var %t YesNo, %b main, $+ $remove($replace(%a,half-ops,hop),$chr(32),?)
      set %_xservd.path %b
      set %_xservd.type %t
      if ($dialog(_xserv.itemmod)) dialog -c _xserv.itemmod
      dialog -m _xserv.itemmod _xserv.itemmod
    }
    if (%n = 57) {
      if ($gettok($did(1,1),4,32) = 3) {
        dialog -m xserv.wizard xserv.wizard
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        var %a $$input(What do you want to call this server?,e)
        writeini $xftp.sdir(%a) main notes No Notes Set
        writeini $xftp.sdir(%a) main login xserv
        writeini $xftp.sdir(%a) main password xserv
        writeini $xftp.sdir(%a) main speed N/A
        writeini $xftp.sdir(%a) main address $iif($ip,127.0.0.1)
        writeini $xftp.sdir(%a) main port 21
        writeini $xftp.sdir(%a) ad status 0
        writeini $xftp.sdir(%a) ad interval 15
        writeini $xftp.sdir(%a) main style default
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        var %a $$input(What do you want to call this server?,e)
        writeini $xtdcc.sdir(%a) main notes No Notes Set
        writeini $xtdcc.sdir(%a) main login xserv
        writeini $xtdcc.sdir(%a) main password xserv
        writeini $xtdcc.sdir(%a) main speed N/A
        writeini $xtdcc.sdir(%a) main address $ip
        writeini $xtdcc.sdir(%a) main port 21
        writeini $xtdcc.sdir(%a) ad status 0
        writeini $xtdcc.sdir(%a) ad interval 15
        writeini $xtdcc.sdir(%a) main style default
      }
      _xserv.dialog itree
    }
    if (%n = 58) {
      if ($gettok($did(1,1),4,32) = 3) {
        if ($input(Are you sure you want to delete the server ' $+ %s $+ '?)) .remove $xsdir(%s)
      }
      elseif ($gettok($did(1,1),4,32) = 4) {
        if ($input(Are you sure you want to delete the server ' $+ %s $+ '?)) .remove $xftp.sdir(%s)
      }
      elseif ($gettok($did(1,1),4,32) = 5) {
        if ($input(Are you sure you want to delete the server ' $+ %s $+ '?)) .remove $xtdcc.sdir(%s)
      }
      _xserv.dialog itree
      _xserv.dialog hidetabs
      _xserv.dialog showtab main
    }
    if (%n = 83) _xserv.dialog lview xdcc.opt
    if (%n = 82) writeini $xdcc.sdir ad type $did(%n).sel
    if (%n = 91) { write $+(-l,$$did(83).sel) $xdcc.pdir $+($$sfile($gettok($read($xdcc.pdir,$did(83).sel),1,127),Choose a package file,Save),,$gettok($read($xdcc.pdir,$did(83).sel),2,127)) | _xserv.dialog showtab xdcc }
    if (%n = 85) { write $xdcc.pdir $+($$sfile($mircdir,Choose a package file,Save),,$$input(Enter a description,e)) | _xserv.dialog showtab xdcc }
    if (%n = 86) { write $+(-dl,$$did(83).sel) $xdcc.pdir | _xserv.dialog showtab xdcc }
  }
  if (%i = dclick) {
    if (%n = 1) {
      tokenize 32 $did(1,1)
      if ($1 = expand) || ($1 = collapse) hadd xserv.dialog tree. $+ $3 $1
    }
    if (%n = 59) {
      set %_xservd.server %s
      set %_xservd.thing $gettok($gettok($did(59).seltext,1,9),6-,32)
      var %a %_xservd.thing
      if (%a = Server) var %t Onoff, %b main,status
      if (%a = Trigger) var %t Edit, %b main,trigger
      if (%a = Directory) var %t Dir, %b main,directory
      if (%a = MOTD) var %t File, %b motd,file
      if (%a = Display Motd?) var %t YesNo, %b motd,show
      if (%a = Rules) var %t File, %b rules,file
      if (%a = Use Rules?) var %t YesNo, %b rules,show
      if (Desc* iswm %a) var %t Edit, %b main,desc
      if (%a = CTCP Trigger?) var %t TriggerType, %b main,type
      if (%a = Address) var %t edit, %b main,address
      if (%a = Port) var %t edit, %b main,port
      if (%a = Username) var %t edit, %b main,login
      if (%a = Password) var %t edit, %b main,password
      if (%a = Speed) var %t edit, %b main,speed
      if (%a = Notes) var %t edit, %b main,notes
      if (%a = File) var %t file, %b main,file
      if (%a = Multi-Drive Access?) var %t YesNo, %b main,mdrive
      if (Allow* iswm %a) var %t YesNo, %b main, $+ $remove($replace(%a,half-ops,hop),$chr(32),?)
      set %_xservd.path %b
      set %_xservd.type %t
      if ($dialog(_xserv.itemmod)) dialog -c _xserv.itemmod
      dialog -m _xserv.itemmod _xserv.itemmod
    }
  }
}
alias _xserv.dialog {
  var %c _xserv
  if ($1 = itree) { 
    did -r %c 1
    did -a %c 1 + $+ $iif($hget(xserv.dialog,tree.2) = expand,e)  Main
    did -i %c 1 1 cb root  last 1
    did -a %c 1   @Find
    did -a %c 1   !list
    did -i %c 1 1 cb root 1
    did -a %c 1 + $+ $iif($hget(xserv.dialog,tree.3) = expand,e)  File Servers
    did -i %c 1 1 cb root  last 1
    var %a 0 | while (%a < $xserv(0)) { inc %a | did -a %c 1  $xserv(%a) }
    did -i %c 1 1 cb root 1
    did -a %c 1 + $+ $iif($hget(xserv.dialog,tree.4) = expand,e)  FTP Ads
    did -i %c 1 1 cb root  last 1
    var %a 0 | while (%a < $xftp(0)) { inc %a | did -a %c 1  $xftp(%a) }
    did -i %c 1 1 cb root 1
    did -a %c 1 + $+ $iif($hget(xserv.dialog,tree.6) = expand,e)  TDCC Servers
    did -i %c 1 1 cb root  last 1
    var %a 0 | while (%a < $xtdcc(0)) { inc %a | did -a %c 1  $xtdcc(%a) }
    did -i %c 1 1 cb root 1
    did -a %c 1 + $+ $iif($hget(xserv.dialog,tree.5) = expand,e)  XDCC Server
    did -i %c 1 1 cb root 1
    ;did -a %c 1 + $+ $iif($hget(xserv.dialog,tree.7) = expand,e) $+ b  Help
    ;did -i %c 1 1 cb root  last 1
    ;did -a %c 1   Contact
    ;did -a %c 1   Display Format
  }
  if ($1 = hidetabs) {
    var %a 3
    while (%a < 93) {
      inc %a | did -h %c %a
    }
  }
  if ($1 = showtab) {
    if ($2 = main) {
      var %a 10
      while (%a < 40) {
        inc %a | did -v %c %a
      }
    }
    if ($2 = @find) {
      var %a 3
      while (%a < 10) {
        inc %a | did -v %c %a
      }
      var %a 40
      while (%a < 46) {
        inc %a | did -v %c %a
      }
    }
    if ($2 = !list) {
      var %a 46
      while (%a < 55) {
        inc %a | did -v %c %a
      }
    }
    if ($2 = fserv.conf) {
      var %a 55
      while (%a < 79) {
        inc %a | did -v %c %a
      }
      did -r %c 63,68,75,78,59
      .timer -m 1 1 _xserv.dialog lview fserv.opt
      var %s $xserv($calc($gettok($did(%c,1,1),5,32) - 1))
      if (!$readini($xsdir(%s),ad,interval)) writeini $xsdir(%s) ad interval 15 
      did -a %c 75 $readini($xsdir(%s),ad,interval)
      did $iif($readini($xsdir(%s),ad,status) = 1,-c,-u) %c 71
      var %a = 0, %read = $readini($xsdir(%s),main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 63 $gettok(%read,%a,44) }
      did -c %c 63 1
      did $iif($did(%c,63),-e,-b) %c 66,68,69,70
      if ($did(%c,63).seltext) { var %a = 0, %read = $readini($xsdir(%s),networks,$did(%c,63).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 68 $gettok(%read,%a,44) } }
      did -c %c 68 1
      did $iif($did(%c,68),-e,-b) %c 70
      var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),ad)) { inc %; | did -a %c 78 $xserv.style(%`) | if ($readini($xsdir(%s),main,style) = $xserv.style(%`)) { did -c %c 78 %; } } }
      did -b %c 61
      did $iif($readini($xsdir(%s),ad,status) = 1,-e,-b) %c 75
    }
    if ($2 = fserv.main) {
      var %a 55
      while (%a < 58) {
        inc %a | did -v %c %a
      }
    }
    if ($2 = ftp.conf) {
      var %a 55
      while (%a < 79) {
        inc %a | did -v %c %a
      }
      did -r %c 63,68,75,78,59
      .timer -m 1 1 _xserv.dialog lview ftp.opt
      var %s $xftp($calc($gettok($did(%c,1,1),5,32) - 1))
      if (!$readini($xftp.sdir(%s),ad,interval)) writeini $xftp.sdir(%s) ad interval 15 
      did -a %c 75 $readini($xftp.sdir(%s),ad,interval)
      did $iif($readini($xftp.sdir(%s),ad,status) = 1,-c,-u) %c 71
      var %a = 0, %read = $readini($xftp.sdir(%s),main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 63 $gettok(%read,%a,44) }
      did -c %c 63 1
      did $iif($did(%c,63),-e,-b) %c 66,68,69,70
      if ($did(%c,63).seltext) { var %a = 0, %read = $readini($xftp.sdir(%s),networks,$did(%c,63).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 68 $gettok(%read,%a,44) } }
      did -c %c 68 1
      did $iif($did(%c,68),-e,-b) %c 70
      var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),ftp:ad)) { inc %; | did -a %c 78 $xserv.style(%`) | if ($readini($xftp.sdir(%s),main,style) = $xserv.style(%`)) { did -c %c 78 %; } } }
      did -b %c 61
      did $iif($readini($xftp.sdir(%s),ad,status) = 1,-e,-b) %c 75
    }
    if ($2 = ftp.main) {
      var %a 55
      while (%a < 58) {
        inc %a | did -v %c %a
      }
    }
    if ($2 = tdcc.conf) {
      var %a 55
      while (%a < 79) {
        inc %a | did -v %c %a
      }
      did -r %c 63,68,75,78,59
      .timer -m 1 1 _xserv.dialog lview tdcc.opt
      var %s $xtdcc($calc($gettok($did(%c,1,1),5,32) - 1))
      if (!$readini($xdtcc.sdir(%s),ad,interval)) writeini $xtdcc.sdir(%s) ad interval 15 
      did -a %c 75 $readini($xtdcc.sdir(%s),ad,interval)
      did $iif($readini($xtdcc.sdir(%s),ad,status) = 1,-c,-u) %c 71
      var %a = 0, %read = $readini($xtdcc.sdir(%s),main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 63 $gettok(%read,%a,44) }
      did -c %c 63 1
      did $iif($did(%c,63),-e,-b) %c 66,68,69,70
      if ($did(%c,63).seltext) { var %a = 0, %read = $readini($xtdcc.sdir(%s),networks,$did(%c,63).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 68 $gettok(%read,%a,44) } }
      did -c %c 68 1
      did $iif($did(%c,68),-e,-b) %c 70
      var %` 0, %; 0 | while (%` < $xserv.style(0)) { inc %` | if ($hget($+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>)),tdcc:ad)) { inc %; | did -a %c 78 $xserv.style(%`) | if ($readini($xtdcc.sdir(%s),main,style) = $xserv.style(%`)) { did -c %c 78 %; } } }
      did -b %c 61
      did $iif($readini($xtdcc.sdir(%s),ad,status) = 1,-e,-b) %c 75
    }
    if ($2 = tdcc.main) {
      var %a 55
      while (%a < 58) {
        inc %a | did -v %c %a
      }
    }
    if ($2 = xdcc) {
      var %a 79
      while (%a < 93) {
        inc %a | did -v %c %a
      }
      var %a 61
      while (%a < 78) {
        inc %a | did -v %c %a
      }
      did -r %c 75,78,63,68,82,83
      if (!$readini($xdcc.sdir,ad,interval)) writeini $xdcc.sdir ad interval 15 
      did -ra %c 75 $readini($xdcc.sdir,ad,interval)
      did $iif($readini($xdcc.sdir,ad,status) = 1,-c,-u) %c 71
      var %a = 0, %read = $readini($xdcc.sdir,main,networks) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 63 $gettok(%read,%a,44) }
      did -c %c 63 1
      did $iif($did(%c,63),-e,-b) %c 66,68,69,70
      if ($did(%c,63).seltext) { var %a = 0, %read = $readini($xdcc.sdir,networks,$did(%c,63).seltext) | while (%a < $numtok(%read,44)) { inc %a | did -a %c 68 $gettok(%read,%a,44) } }
      did -c %c 68 1
      did $iif($did(%c,68),-e,-b) %c 70
      var %` 0, %; 0
      while (%` < $xserv.style(0)) {
        inc %`
        var %- $+(xstyle:,$replace($xserv.style(%`),$chr(32),<space>))
        if ($hget(%-,xdcc:begin)) && ($hget(%-,xdcc:mid1)) && ($hget(%-,xdcc:mid2)) && ($hget(%-,xdcc:mid3)) && ($hget(%-,xdcc:list1)) && ($hget(%-,xdcc:end)) {
          inc %;
          did -a %c 78 $xserv.style(%`)
          if ($readini($xdcc.sdir,main,style) = $xserv.style(%`)) { did -c %c 78 %; }
        }
      }
      did -b %c 61
      did $iif($readini($xdcc.sdir,ad,status) = 1,-e,-b) %c 75
      didtok %c 82 44 Long,Short,One Line
      did -c %c 82 $readini($xdcc.sdir,ad,type)
      var %a 0 | while (%a < $lines($xdcc.pdir)) { inc %a | did -a %c 83 $nopath($gettok($read($xdcc.pdir,%a),1,127)) }
      did -c %c 83 1
      did -ra %c 93 $readini($xdcc.sdir,main,notes)
      did $iif($did(83),-e,-b) %c 86,90,91
      .timer -m 1 1 _xserv.dialog lview xdcc.opt
    }
  }
  if ($1 = lview) {
    if ($2 = main) {
      did -r %c 28
      did -a %c 28 Command: find $+ $chr(9) $+ $iif($readini($_xconfig,main,@find) = 1,Yes,No)
      did -a %c 28 Channel Guard $+ $chr(9) $+ $iif($readini($_xconfig,main,changuard) = 1,Yes,No)
      did -a %c 28 Kick Campers $+ $chr(9) $+ $iif($readini($_xconfig,main,kickcamp) = 1,Yes,No)
      did -a %c 28 Ban Campers $+ $chr(9) $+ $iif($readini($_xconfig,main,bancamp) = 1,Yes,No)
      did -a %c 28 Kick Idlers $+ $chr(9) $+ $iif($readini($_xconfig,main,kickidle) = 1,Yes,No)
      did -a %c 28 Ban Idlers $+ $chr(9) $+ $iif($readini($_xconfig,main,banidle) = 1,Yes,No)
      did -a %c 28 Clone Guard $+ $chr(9) $+ $iif($readini($_xconfig,main,cloneguard) = 1,Yes,No)
      did -a %c 28 FServ Chat $+ $chr(9) $+ $iif($readini($_xconfig,main,fchat) = 1,Yes,No)
    }
    if ($2 = fserv.opt) {
      var %s $xserv($calc($gettok($did(%c,1,1),5,32) - 1))
      did -r %c 59
      did -a %c 59 Server $+ $chr(9) $+ $iif($readini($xsdir(%s),main,status) = 1,On,Off)
      did -a %c 59 Trigger $+ $chr(9) $+ $readini($xsdir(%s),main,trigger)
      did -a %c 59 Directory $+ $chr(9) $+ $readini($xsdir(%s),main,directory)
      did -a %c 59 MOTD $+ $chr(9) $+ $iif($nopath($readini($xsdir(%s),motd,file)),../ $+ $ifmatch,$+($chr(40),None set,$chr(41)))
      did -a %c 59 Display MOTD? $+ $chr(9) $+ $iif($readini($xsdir(%s),motd,show) = 1,Yes,No)
      did -a %c 59 Rules $+ $chr(9) $+ $iif($nopath($readini($xsdir(%s),rules,file)),../ $+ $ifmatch,$+($chr(40),None set,$chr(41)))
      did -a %c 59 Use Rules? $+ $chr(9) $+ $iif($readini($xsdir(%s),rules,show) = 1,Yes,No)
      did -a %c 59 Desc $+ $chr(9) $+ $readini($xsdir(%s),main,description)
      did -a %c 59 CTCP Trigger? $+ $chr(9) $+ $iif($readini($xsdir(%s),main,type) = ctcp,Yes,No)
      did -a %c 59 Multi-drive Access? $+ $chr(9) $+ $iif($readini($xsdir(%s),main,mdrive) = 1,Yes,No)
      ;did -a %c 59 Allow Ops? $+ $chr(9) $+ $iif($readini($xsdir(%s),allow,ops) != 0,Yes,No)
      ;did -a %c 59 Allow Half-Ops? $+ $chr(9) $+ $iif($readini($xsdir(%s),allow,hops) != 0,Yes,No)
      ;did -a %c 59 Allow Voiced? $+ $chr(9) $+ $iif($readini($xsdir(%s),allow,voiced) != 0,Yes,No)
      ;did -a %c 59 Allow Regulars? $+ $chr(9) $+ $iif($readini($xsdir(%s),allow,reg) != 0,Yes,No)
      did -b %c 61
    }
    if ($2 = ftp.opt) {
      var %s $xftp($calc($gettok($did(%c,1,1),5,32) - 1))
      did -r %c 59
      did -a %c 59 Address $+ $chr(9) $+ $readini($xftp.sdir(%s),main,address)
      did -a %c 59 Port $+ $chr(9) $+ $chr(32) $+ $readini($xftp.sdir(%s),main,port)
      did -a %c 59 Username $+ $chr(9) $+ $readini($xftp.sdir(%s),main,login)
      did -a %c 59 Password $+ $chr(9) $+ $readini($xftp.sdir(%s),main,password)
      did -a %c 59 Notes $+ $chr(9) $+ $readini($xftp.sdir(%s),main,notes)
      did -a %c 59 Speed $+ $chr(9) $+ $readini($xftp.sdir(%s),main,speed)
      did -b %c 61
    }
    if ($2 = tdcc.opt) {
      var %s $xtdcc($calc($gettok($did(%c,1,1),5,32) - 1))
      did -r %c 59
      did -a %c 59 Server $+ $chr(9) $+ $iif($readini($xtdcc.sdir(%s),main,status) = 1,On,Off)
      did -a %c 59 Trigger $+ $chr(9) $+ $readini($xtdcc.sdir(%s),main,trigger)
      did -a %c 59 File $+ $chr(9) $+ $chr(32) $+ $readini($xtdcc.sdir(%s),main,file)
      did -a %c 59 Description $+ $chr(9) $+ $readini($xtdcc.sdir(%s),main,desc)
      did -a %c 59 CTCP Trigger? $+ $chr(9) $+ $iif($readini($xtdcc.sdir(%s),main,type) = ctcp,Yes,No)
      ;did -a %c 59 Allow Ops? $+ $chr(9) $+ $iif($readini($xtdcc.sdir(%s),allow,ops) != 0,Yes,No)
      ;did -a %c 59 Allow Half-Ops? $+ $chr(9) $+ $iif($readini($xtdcc.sdir(%s),allow,hops) != 0,Yes,No)
      ;did -a %c 59 Allow Voiced? $+ $chr(9) $+ $iif($readini($xtdcc.sdir(%s),allow,voiced) != 0,Yes,No)
      ;did -a %c 59 Allow Regulars? $+ $chr(9) $+ $iif($readini($xtdcc.sdir(%s),allow,reg) != 0,Yes,No)
      did -b %c 61
    }
    if ($2 = xdcc.opt) {
      did -r %c 89,90
      did -a %c 89 ../ $+ $nopath($gettok($read($xdcc.pdir,$did(%c,83).sel),1,127))
      did -a %c 90 $gettok($read($xdcc.pdir,$did(%c,83).sel),2,127)
    }
    if ($2 = @find) {
      did -r %c 5,10
      var %` 0 | while (%` < $xserv(0)) { inc %` | did -a %c 5 $xserv(%`) | if ($readini($xsdir($xserv(%`)),main,@find) = 1) { did -a %c 10 $xserv(%`) } }
    }
  }
  if ($1 = ihelp) {
    if ($2 = @find) { did -ra _xserv 43 Choose servers from the "Your Servers" list, then use the navigation buttons to move them in to the "Servers Active" list or to remove them. Only the servers in the "Servers Active" list will be shown in @Find, and indexed for @Find. If you enable @Find Indexing it will take a moment to cache all the files in the directories which will speed up @find requests greatly. }
    if ($2 = !list) { did -ra _xserv 55 The !list command responds to any text requests for "!list" and !list only, it will send a custom notice listing; for the file server: the first 5 triggers, For the TDCC: a message for each server active. You can configure the styles in the style editor, and choose a seperate one for each, or disable one, or both options. More information can be found in the  Help section under the !list command index. }
  }
}
dialog _xserv.itemmod {
  title "Item Modification"
  size -1 -1 90 42
  option dbu
  radio "On", 1, 45 14 22 10, group result
  radio "Off", 2, 68 14 22 10, result
  text "This item is :", 3, 2 15 41 8
  button "&Save", 4, 62 31 27 10, ok cancel default
  text "You are editing: Server Directory", 5, 2 0 87 8
  box "", 6, -1 5 92 24
  edit "", 7, 1 14 88 10, autohs
  edit "", 8, 2 14 71 10, autohs
  button "!", 9, 75 15 12 8
}
on *:dialog:_xserv.itemmod:*:*:{
  var %i $devent, %n $did, %c $dname, %s %_xservd.server
  if ($gettok($did(_xserv,1,1),4,32) = 3) var %z $xsdir(%s)
  elseif ($gettok($did(_xserv,1,1),4,32) = 4) var %z $xftp.sdir(%s)
  elseif ($gettok($did(_xserv,1,1),4,32) = 5) var %z $xtdcc.sdir(%s)
  tokenize 44 %_xservd.path
  if (%i = init) {
    did -ra %c 5 You are editing: %_xservd.thing
    if (%_xservd.type = OnOff) {
      did -h %c 7,8,9
      did -c %c $iif($readini(%z,$1,$2) = 1,1,2)
    }
    if (%_xservd.type = YesNo) {
      did -h %c 7,8,9
      did -ra %c 1 Yes
      did -ra %c 2 No
      did -ra %c 3 Enable this item :
      did -c %c $iif($readini(%z,$1,$2) = 1,1,2)
    }
    if (%_xservd.type = TriggerType) {
      did -h %c 7,8,9
      did -ra %c 1 CTCP
      did -ra %c 2 Text
      did -ra %c 3 Choose a type :
      did -c %c $iif($readini(%z,$1,$2) = ctcp,1,2)
    }
    if (%_xservd.type = Edit) {
      did -h %c 1,2,3,8,9
      did -fra %c 7 $readini(%z,$1,$2)
    }
    if (%_xservd.type = File) {
      did -h %c 1,2,3,7
      did -fra %c 8 $readini(%z,$1,$2)
    }
    if (%_xservd.type = Dir) {
      did -h %c 1,2,3,7
      did -fra %c 8 $readini(%z,$1,$2)
    }
  }
  if (%i = sclick) {
    if (%n = 9) did -ra %c 7,8 $iif(%_xservd.type = File,$$sfile(Select a file),$$sdir(Select a directory))
    if (%n = 4) {
      var %n
      if (%_xservd.type = triggertype) %n = $iif($did(1).state = 1,ctcp,text)
      if (%_xservd.type = edit) %n = $did(7)
      if (%_xservd.type = dir) || (%_xservd.type = file) %n = $did(8)
      if (%_xservd.type = yesno) || (%_xservd.type = onoff) %n = $did(1).state
      if ($dialog(_xserv)) {
        if ($gettok($did(_xserv,1,1),4,32) = 3) && ($xserv($calc($gettok($did(_xserv,1,1),5,32) - 1))) {
          writeini $xsdir(%s) $1 $2 %n
          _xserv.dialog lview fserv.opt
        }
        elseif ($gettok($did(_xserv,1,1),4,32) = 4) && ($xftp($calc($gettok($did(_xserv,1,1),5,32) - 1))) {
          writeini $xftp.sdir(%s) $1 $2 %n
          _xserv.dialog lview ftp.opt
        }
        elseif ($gettok($did(_xserv,1,1),4,32) = 5) && ($xtdcc($calc($gettok($did(_xserv,1,1),5,32) - 1))) {
          writeini $xtdcc.sdir(%s) $1 $2 %n
          _xserv.dialog lview tdcc.opt
        }
      }
    }
  }
}
alias _xserv dialog -m _xserv _xserv
dialog xserv.wizard {
  title "[xServ] Setup Wizard"
  size -1 -1 260 166
  option dbu
  button "Next >>", 2, 228 152 30 12
  button "<< Back", 3, 195 152 30 12
  icon 1, 0 -4 262 37, xdb\wiz.jpg, 0
  box "", 5, 0 145 263 4
  text "Welcome to the new File Server creation tool, this will guide you through the process of creating a file server and choose its options, the readme.txt is displayed below. If you are unsure about anything please look over it before contacting support.", 6, 3 40 256 22
  edit "", 7, 3 66 256 78, read multi return hsbar vsbar
  text "Server Name:", 8, 44 50 39 8
  edit "", 9, 95 49 97 10
  text "Directory:", 10, 44 63 39 8
  edit "", 11, 95 62 97 10, read
  button "Change", 12, 195 62 25 10
  text "Description:", 13, 44 76 39 8
  edit "", 14, 95 75 97 25, multi
  text "MOTD File:", 15, 44 104 39 8
  edit "", 16, 95 103 97 10, read
  check "Show MOTD", 17, 150 114 42 10
  check "Show Rules", 18, 150 136 42 10
  edit "", 19, 95 125 97 10, read
  text "Rules File:", 20, 44 126 39 8
  button "Change", 21, 195 103 25 10
  button "Change", 22, 195 125 25 10
  text "Your file server has been setup, you can choose from a few more options below, or click finish. You can edit/change options from the main dialog in the File Servers section.", 23, 6 43 255 27
  text "(these will come later)", 24, 106 100 55 8
  text "Trigger:", 4, 44 38 39 8
  edit "", 25, 95 37 97 10
  check "CTCP", 26, 195 37 24 10
}
on *:dialog:xserv.wizard:*:*:{
  var %i $devent, %n $did, %c $dname, %s %_xservd.server
  if (%i = INIT) {
    did -h %c 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,4,25,26
    did -b %c 3
    loadbuf -ro %c 7 $scriptdirreadme.txt
  }
  if (%i = SCLICK) {
    if (%n = 2) {
      if ($did(6).visible) {
        did -h %c 6,7
        did -v %c 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,4,25,26
        did -e %c 2,3
        did $iif(($did(9)) && ($did(11)) && ($did(14)) && ($did(25)),-e,-b) %c 2
      }
      elseif ($did(8).visible) {
        did -h %c 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,4,25,26
        did -ra %c 2 Finish
        did -v %c 23,24
      }
      elseif ($did(23).visible) {
        var %a $xsdir($did(9))
        writeini %a main status 1
        writeini %a main directory $did(11)
        writeini %a main description $did(14)
        writeini %a main trigger $did(25)
        writeini %a main type $iif($did(26).state = 1,ctcp,text)
        if ($did(16)) writeini %a motd file $ifmatch
        if ($did(19)) writeini %a rules file $ifmatch
        writeini %a motd show $did(17).state
        writeini %a rules show $did(18).state
        writeini %a ad status 0
        writeini %a ad interval 15
        dialog -c %c
        if ($dialog(_xserv)) _xserv.dialog itree
      }
    }
    if (%n = 3) {
      if ($did(8).visible) {
        did -h %c 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,4,25,26
        did -v %c 6,7
        did -b %c 3
        did -e %c 2
      }
      if ($did(23).visible) {
        did -h %c 23,24
        did -v %c 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,4,25,26
        did -e %c 3
        did -ra %c 2 Next >>
        did $iif(($did(9)) && ($did(11)) && ($did(14)) && ($did(25)),-e,-b) %c 2
      }
    }
    if (%n = 12) { did -ra %c 11 $sdir($mircdir,Select a directory) | did $iif(($did(9)) && ($did(11)) && ($did(14)) && ($did(25)),-e,-b) %c 2 }
    if (%n = 21) did -ra %c 16 $sfile($mircdir,Select a file)
    if (%n = 22) did -ra %c 19 $sfile($mircdir,Select a file)
  }
  if (%i = EDIT) {
    if (%n = 9) || (%n = 14) || (%n = 25) did $iif(($did(9)) && ($did(11)) && ($did(14)) && ($did(25)),-e,-b) %c 2
  }
}
alias xserv.update xupd.get