raw 5:*: {
  var %network = $gettok($network,1,46)
  if (SAFELIST isin $2-) && (!$ini(%xdccgets.ini,DCC˙Allow,%network)) Writeini -n $qt(%xdccgets.ini) DCC˙Allow %network %network
}
raw 421:*: {
  var %network = $gettok($network,1,46)
  if (DCCALLOW == $2) && ($ini(%xdccgets.ini,DCC˙Allow,%network)) {
    remini -n $qt(%xdccgets.ini) DCC˙Allow %network
    haltdef
  }
}
raw 481:*: {
  var %network = $gettok($network,1,46)
  if (Permission Denied* IRC operator* iswm $2-) && ($ini(%xdccgets.ini,DCC˙Allow,%network)) {
    remini -n $qt(%xdccgets.ini) DCC˙Allow %network
    haltdef
  }
}
raw 486:*: {
  var %nick = $gettok($1-,-1,32)
  var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
  if ($hget($+(Xdccbhash-,%nick2))) hadd $+(Xdccbhash-,%nick2) Register 1 
  if ($timer($+(XDCCB-,%nick))) $+(.TimerXDCCB-,%nick) off
}
raw 487:*: {
  var %nick = $gettok($1-,-1,32)
  var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
  if ($hget($+(Xdccbhash-,%nick2))) hadd $+(Xdccbhash-,%nick2) Register 1 
  if ($timer($+(XDCCB-,%nick))) $+(.TimerXDCCB-,%nick) off
}
ctcp *:*:*:{
  if (dcc send * !iswm $1-) return
  var %file = $nopath($filename)
  var %a = 1
  var %get-nick,%check
  var %xdccgets.ini = $qt(%xdccgets.ini)
  while ($get(%a)) {
    if ($get(%a).file = %file) && (($get(%a).status = active) || ($get(%a).status = waiting)) var %get-nick = $get(%a)
    inc %a
  }
  var %nick = $replace($nick,[,$chr(60),],$chr(62))
  var %get = $hget($+(Xdccbhash-,%nick),get)
  var %pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
  var %network = $gettok($network,1,46)
  xdccb-removeQueue $nick %network 
  if (%get-nick) {
    var %gets = $hfind($+(Xdccbhash-,%nick),Pack*,0,w)
    if ($calc(%gets - %get +1) > 1) {
      var %Pack-num = $remove($gettok(%Pack,2,9),$Chr(32))
      var %Date = $hget($+(Xdccbhash-,%nick),$+(Date,%pack-num))
      var %Time = $hget($+(Xdccbhash-,%nick),$+(Time,%pack-num))
      var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,1).line
      var %new-line = $calc($readiniwm(%xdccgets.ini,%nick,time*,%gets).line +1)
      write $+(-il,%new-line) %xdccgets.ini $+(Pack,%Pack-num,=,%Pack)
      write $+(-il,$calc(%new-line + 1)) %xdccgets.ini $+(Date,%Pack-num,=,%Date)
      write $+(-il,$calc(%new-line + 2)) %xdccgets.ini $+(Time,%Pack-num,=,%Time)
      write $+(-dl,$calc(%line + 2)) %xdccgets.ini
      write $+(-dl,$calc(%line + 1)) %xdccgets.ini
      write $+(-dl,%line) %xdccgets.ini
      Xdccb-Hashnick %nick
      if ($dialog(xdccb)) {
        var %a = 1
        while ($did(xdccb,308,%a)) {
          var %v1 = $v1
          if ($did-list(6,%v1) = $nick) {
            if ($did-list(5,%v1) = 1st) {
              var %check = $calc(%gets - %get +1)
              did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
            }
            elseif ($remove($did-list(5,%v1),st,nd,rd,th) > 1) {
              var %check = $calc($v1 -1)
              did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
            }
          }
          inc %a
        }
      }
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
    }
    $+(.TimerXDCCB-,$nick) 1 $hget(Xdccboptions,Request-Timer) XDCCb-request-Pack $nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) $cid $gettok($network,1,46) %Pack
    var %sec = $replace(%file,[,$chr(60),],$chr(62))
    if ($istok($readini(%Xdccb-Downloads.ini,%sec,Priority),$nick,32)) {
      remini -n $qt(%Xdccb-Downloads.ini) %sec Priority
      writeini -n $qt(%Xdccb-Downloads.ini) %sec Nick $nick
      writeini -n $qt(%Xdccb-Downloads.ini) %sec Path $nofile($filename)
      var %got = $calc($get(%get-nick).rcvd - $get(%get-nick).resume)
      var %filename = $filename
      close -g* %get-nick
      xdccb-cutfile %got %get-nick %filename
      var %size = $gettok($1-,-1,32)
      var %rcvd = $readini(%Xdccb-Downloads.ini,%sec,Rcvd)
      var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
      if ($dialog(xdccb)) {
        var %a = 2
        while ($did(xdccb,501,%a)) {
          var %v1 = $v1
          if ($did-list(1,%v1) = %file) did -o xdccb 501 %a $gettok(%v1,2,32) 2 %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) $nick $chr(9) $nofile($filename)
          inc %a
        }
      }
      writeini -n $qt(%Xdccb-Downloads.ini) %sec Size %size
    }
    elseif ( [ [ $+($,$0) ] ] = $get(%get-nick).size) {
      var %got = $calc($get(%get-nick).rcvd - $get(%get-nick).resume)
      var %check
      var %a = 1
      while ($isdir($+($getdircps-test,%a,\))) inc %a
      var %dir = $+($getdircps-test,%a,\)
      if (!$isdir(%dir)) .mkdir $qt(%dir)
      dcc get %dir
      $+(.timerPriority,$nick) 1 30 Xdccb-Priority $nick $+(%dir,%file)
    }
    else haltdef
    return
  }
  var %finishdir = $hget(Xdccboptions,Finish)
  if ($isfile($+(%finishdir,%file))) && ($getdir(%file) != %finishdir) {
    var %scid = $cid
    var %comchan = $xdccb-changet(%scid,$nick)
    if ($hget($+(Xdccbhash-,%nick))) { 
      if ($hget(Xdccboptions,Remove) = on) {
        var %packnum = $right($readiniwm(%xdccgets.ini,%nick,pack*,%get).sec,-4)
        xdccb-remove %Nick $+(Pack,%packnum)
        xdccb-remove %Nick $+(Time,%packnum)
        xdccb-remove %Nick $+(Date,%packnum)
        if ($dialog(xdccb)) {
          var %c = 2
          while ($did(xdccb,308,%c)) {
            var %v1 = $v1
            if ($did-list(6,%v1) = $nick) {
              if ($did-list(5,%v1) = 1st) {
                did -d XDCCb 308 %c
                dec %c
              }
              elseif ($remove($did-list(5,%v1),st,nd,rd,th) > 1) {
                var %check = $calc($v1 -1)
                did -o xdccb 308 %c $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
              }
            }
            inc %c
          }
        }
        if ($hfind($+(Xdccbhash-,%nick),Pack*,0,w) = 0) {
          xdccb-remove %Nick
          Xdccb-Shutdown-quit %network %scid $nick
          dec %a
          haltdef
        }
      }
      elseif (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) {
        inc %get
        writeini -n $qt(%xdccgets.ini) %nick get %get
        hadd $+(Xdccbhash-,%nick) get %get
      }
      if (%comchan) && (%pack) && (%scid) scid -t1 %scid $+(/.TimerXdccb-,$nick) 1 $hget(Xdccboptions,Getfail-Timer) XDCCb-request-Pack $nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) %scid $gettok($network,1,46) %pack
    }
    haltdef
    return
  }
  if ($len(%file) >= $calc(255 - $len($nick))) {
    linesep
    Echo -ts $+(,$color(info)) $nick $+(,$color(highlight)) tried to send you an exploit file to crash your mIRC !
    Echo -ts Stoping send connection!
    linesep
    halt
  }
  if ($gettok($1-,-4,32) isnum) && ($gettok($1-,-3,32) = 0) {
    var %lip = $gettok($1-,-4,32) 
    var %port = $gettok($1-,-1,32) 
    var %size = $gettok($1-,-2,32)
  }
  else {
    var %lip = $gettok($1-,-3,32) 
    var %port = $gettok($1-,-2,32) 
    var %size = $gettok($1-,-1,32)
  }
  if (%lip !isnum) return
  if (%port = 0) return
  if ((%lip >= 167772160) && (%lip <= 184549375)) || ((%lip >= 3232235520) && (%lip <= 3232301055)) || ((%lip >= 2886729728) && (%lip <= 2887778303)) {
    var %unable = $hget($+(Xdccbhash-,%nick),Unable)
    writeini -n $qt(%xdccgets.ini) %nick Unable $calc(%unable +1) 
    hadd $+(Xdccbhash-,%nick) Unable $calc(%unable +1)
  }
  var %a = 1
  while ($get(%a)) {
    if ($get(%a).file = %file) && ($get(%a).status = failed) Xdccb-close-get $get(%a).wid
    inc %a
  }
  var %downloads.ini = $qt(%Xdccb-Downloads.ini)
  var %sec = $replace(%file,[,$chr(60),],$chr(62))
  if (!$ini(%downloads.ini,%sec)) {
    writeini -n %downloads.ini %sec File %file
    writeini -n %downloads.ini %sec Size %size
    writeini -n %downloads.ini %sec Rcvd 0
    writeini -n %downloads.ini %sec Nick $nick
    writeini -n %downloads.ini %sec Path $nofile($filename)
    var %cps = $iif(%cps < 1024,%cps b/s,%cps Kb/s)
    if ($dialog(xdccb)) did -a xdccb 501 + 2 0 0 %File $chr(9) 0% $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) 0 $chr(9) $nick $chr(9) $nofile($filename)
  }
  else {
    writeini -n %downloads.ini %sec Nick $nick
    writeini -n %downloads.ini %sec Path $nofile($filename)
    var %rcvd = $readini(%downloads.ini,%sec,Rcvd)
    var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
    if (%size != $readini(%downloads.ini,%sec,size)) && ($dialog(xdccb)) {
      var %a = 2
      while ($did(xdccb,501,%a)) {
        var %v1 = $v1
        if ($did-list(1,%v1) = %file) did -o xdccb 501 %a $gettok(%v1,2,32) 2 %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) $nick $chr(9) $nofile($filename)
        inc %a
      }
    }
    writeini -n %downloads.ini %sec Size %size
  }
}
on *:active:*: if ($dialog(xdccb)) dialog -t xdccb XDCC Browser v4.50 ... Active network: $iif($network,$gettok($network,1,46),None)
on *:appactive: {
  if ($appactive == $true) && ($appstate == tray) && ($hget(Xdccboptions,Stats) == on) && (!$window($+(@XDCCB,$chr(160),Stats))) {
    var %a = 1 
    var %check = 0
    while ($dialog(%a)) {
      if ($dialog(%a).active) var %check = stop
      inc %A
    }
    if (%check != stop) {
      window -w0pdok0 +L $+(@XDCCB,$chr(160),Stats) $window(-1).w $window(-1).h $width(Connected: 12days 12hours 12mins,tahoma,12) $calc($height(1,tahoma,12)*7)
      drawfill -r $+(@XDCCB,$chr(160),Stats) $RGB(186,229,242) $RGB(186,229,242) 1 1
      Xdccb-statswindow
      .timerxdccb-statswindow 0 5 Xdccb-statswindow
    }
  }
  if ($appactive) && ($appstate != tray)  {
    if ($window($+(@XDCCB,$chr(160),Stats))) && ($version < 6.3) {
      close -@ $+(@XDCCB,$chr(160),Stats)
      .timerxdccb-statswindow off
    }
    if ($hget(Xdccboptions,minimize) = on) {
      showmirc -t
      .timer 1 1 showmirc -t
      if (!$dialog(xdccb)) xdccb
      else dialog -v xdccb
    }
  }
}
on *:chat:*: {
  if ($hget(Xdccboptions,Fserv-Browser) != on) return
  tokenize 32 $strip($1-)
  var %dialog = $+(Xdccb-Fserv,=$nick)
  if (($regex($1-,/^\x5B\s*\\\s*\]$/i) != 0) || ($regex($1-,/^\x5B\s*/\s*\]$/i) != 0)) && (!$dialog(%dialog)) {
    dialog -m %dialog Xdccb-Fserv
    dialog -t $+(Xdccb-Fserv,=$nick) $+($nick,'s) File Server (XDCC Browser v4.50)
    .msg =$nick Dir
    set $+(%,=$nick,Start) Start
    did -a %dialog 27 +seb 2 2 [..\]
    did -c %dialog 27 2
  }
  if (!$dialog(%dialog)) return
  if ($1- = ['C' for more, 'S' to stop]) {
    .msg =$nick S
    .msg =$nick dir
    set $+(%,=$nick,Start) Start
  }
  elseif (Closing Idle connection in * seconds iswm $1-) {
    dialog -t %dialog $+($nick,'s) File Server (XDCC Browser v4.50) ... Closing in $5 Seconds
    $+(.timer,%dialog) 1 1 Xdccb-Fservtimer %dialog
    return
  }
  elseif ($regex($1-,/^\W*end of list\W*$/i) != 0) {
    var %window = $+(@Xdccb-fserv-,%dialog)
    if (!$window(%window)) window -hn %window
    filter -arcio $+(2-,$did(%dialog,28).lines) %dialog 28 %dialog 28 Xdccb-filter-Fserv
    unset $+(%,=$nick,Start) 
    hadd xdccboptions Fsort 1 u
    close -@ %window
  }
  elseif ($eval($+(%,=$nick,Start),2) = Start) && ($1) && (.. != $1-) && (0D: .. != $1-) && ([*/*] !iswm $1-) && ([*\*] !iswm $1-) {
    if ($isupper($1-)) {
      if ($regex($1,/^[0-9]*D:/) != 0) var %line = $2-
      else var %line = $1-
      var %loc = $did-tree(%dialog,27).sel
      if (%loc) did -i %dialog 27 1 cb root $v1 
      if (!$find-branch(%dialog,27,$replace(%line,$chr(32),$chr(160)),%loc)) did -a %dialog 27 +e 1 1 $replace($iif(%line isnum,$+(%line,$chr(160)),%line),$chr(32),$chr(160))
    }
    elseif (SysReset 2* !iswm $1-) {
      if ($regex($1,/^[0-9]*F:/S) != 0) {
        var %file = $replace($gettok($2-,$+(1-,$calc($numtok($2-,32) -1)),32),$chr(32),$chr(160))
        var %size = $gettok($1-,-1,32)
      }
      else {
        if ($regex($gettok($1-,-1,32),/^[.0-9]+.b$/iS) != 0) {
          var %file = $replace($gettok($1-,$+(1-,$calc($numtok($1-,32) -1)),32),$chr(32),$chr(160))
          var %size = $remove($gettok($1-,-1,32),$chr(32))
        }
        else {
          var %file = $replace($gettok($1-,$+(1-,$calc($numtok($1-,32) -2)),32),$chr(32),$chr(160))
          var %size = $remove($gettok($1-,-2-,32),$chr(32))
        }
      }
      var %end = $gettok(%file,-1,46)
      var %icon = $Xdccb-fileicon(%end)
      if ($regread($+(HKEY_CLASSES_ROOT\.,%end,\PerceivedType))) var %type = $v1
      else var %type = $regread($+(HKEY_CLASSES_ROOT\.,%end,\)) 
      if ($regread($+(HKEY_CLASSES_ROOT\,%type,\))) var %type = $v1
      did -a %dialog 28 1 + %icon 0 0 %file $chr(9) %size $chr(9) %type
    }
  }
}
On *:close:@: if ($target = $+(@XDCCB,$chr(160),Stats)) .timerxdccb-statswindow off
On *:close:=: {
  if ($hget(xdccfserv)) hdel xdccfserv =$nick
  if ($dialog($+(Xdccb-Fserv,=$nick))) dialog -x $v1
  var %window = $+(@Xdccb-fserv-,$+(Xdccb-Fserv,=$nick))
  if ($window(%window)) close -@ %window
  var %a = 1
  while ($dialog(%a)) {
    var %dialog = $v1
    if (Xdccb-Fserv=* iswm %dialog) return
    inc %a
  }
  if ($hget(Xdccb-FileIcons)) .hfree Xdccb-FileIcons
}
on *:connect: {
  if ($hget(xdccboptions,ssl) = on) { 
    writeini -n XDCCB-SSL.ini Network $gettok($network,1,46) $server
    writeini -n XDCCB-SSL.ini Server $server $port
    if (!$server($server).group) server -a $server -g $gettok($network,1,46)
    if ($timer($+(xdccbserver,$cid))) $+(.timerxdccbserver,$cid)) off
  }
  if ($hget(Xdccboptions,Sessions) = on) $+(.timerXdcc-sessions,$gettok($network,1,46)) 1 43200 Xdccb-Session
  if ($hget(Xdccboptions,Join-channels) = yes) {
    var %a = 1
    while ($ini(%xdccgets.ini,%a)) {
      var %nick = $v1
      var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
      var %chan = $hget($+(Xdccbhash-,%nick),chan)
      if (%network = $gettok($network,1,46)) && ($istok(%chans,%chan,255) = $false) {
        var %chans = $addtok(%chans,%chan,44)
      }
      inc %a
    }
    if (%chans) .join %chans
  }
  if ($dialog(XDCCb)) {
    var %network = $gettok($network,1,46)
    var %root = $Find-branch(xdccb,27,%Network)
    if (!%root) did -a xdccb 27 +eb 1 1 %Network $chr(9) Click on the network for a list of channels.
    else {
      var %branch = $find-branch(xdccb,27,%network)
      if ($did-tree(xdccb,27,%branch).Icon = 4) did -i xdccb 27 1 replaceitem %branch $did-tree(xdccb,27,%root).flag 1 1 %Network $chr(9) Click on the network for a list of channels.
    }
  }
}
on *:ctcpreply:VERSION*: {
  var %net = $gettok($network,1,46)
  if ($hget(Xdccboptions,XDCC-Requestlist) = on) && (!$hfind($+(XDCCb-,%net),$+($nick,*),1,w)) && ((iroffer isin $2-) || (Invision isin $2-)) /.msg $nick XDCC list
}
on *:disconnect: {
  if ($hget(xdccboptions,ssl) = on) server $server $port
  var %network = $gettok($network,1,46)
  if ($dialog(XDCCb)) {
    var %root = $find-branch(xdccb,27,%network)
    var %b = 2
    did -i xdccb 27 1 replaceitem %root $did-tree(xdccb,27,%root).flag 4 4 %Network $chr(9) Click on the network for a list of channels.
    while ($did-tree(xdccb,27,%root %b)) {
      var %chan = $v1
      var %subroot = %b
      var %loc = %root %subroot
      did -i xdccb 27 1 cb root %root
      did -i xdccb 27 1 replaceitem %subroot $did-tree(xdccb,27,%loc).flag 5 5 %chan $chr(9) Click on the channel for a list of nicks.
      var %a = 2
      while ($did-tree(xdccb,27,%loc %a)) {
        var %nick = $v1
        did -i xdccb 27 1 cb root %loc
        did -i xdccb 27 1 replaceitem %a $did-tree(xdccb,27,%loc %a).flag 6 6 %nick $chr(9) Click on the channel for a list of nicks.
        inc %a
      }
      inc %b
    }
  }
  var %file = $qt($+($scriptdir\Xdccb-queues-,%network,.txt))
  if ($exists(%file)) .remove %file
  var %root = $Find-branch(xdccb,27,%Network)
  if (%root) && (!$hget($+(XDCCb-,%network))) did -d xdccb 27 %root
  elseif ($hget(Xdccboptions,XDCCDelete-hash) = on) {
    if ($hget($+(XDCCb-,%network))) {
      if ($dialog(XDCCb)) did -d xdccb 27 %root
      .hfree $+(XDCCb-,%network)
      if ($hget($+(XDCCb-,%network,-data))) .hfree $+(XDCCb-,%network,-data)
    }
  }
  if ($gettok($readini(mirc.ini,options,n7),19,44) = 0) return
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    if ($hget($+(Xdccbhash-,%nick),Network) = %network) .dcc trust -r $+($replace(%nick,$chr(60),[,$chr(62),]),!*@*) 
    inc %a 
  }
}
on *:exit: {
  while ($get(1)) {
    if ($get(1).status = active) {
      var %got = $calc($get(%get-nick).rcvd - $get(%get-nick).resume)
      var %filename = $+($get(1).path,$get(1).file)
      Xdccb-close-get $get(1).wid
      xdccb-cutfile %got 1 %filename
    }
    else Xdccb-close-get $get(1).wid
  }
  Set %xdccb-exit ok
}
on ^*:HOTLINK:*:#:{
  if ($gettok($hotlinepos,1,32) < 4) && ($chr(35) isin $1-2) return
  halt
}
on *:HOTLINK:*:#: {
  if ($chr(35) !isin $1-2) return
  if ($window($active).stamp) && ($replace($timestampfmt,h,*,y,*,m,*,d,*,H,*,t,*,T,*,n,*,o,*,s,*,z,*) iswm $gettok($hotline,1,32)) var %place = 2
  else var %place = 1
  if ($xPack($gettok($hotline,$+($calc(%place + 1),-),32))) {
    var %Pack = $v1
    var %nick = $remove($gettok($hotline,%place,32),@,+,$chr(37),!,$chr(42))
    var %a = 0
    while (%a <= $calc($len(%nick) /2)) {
      if ($left($right($gettok($hotline,%place,32),$+(-,%a)),$+(-,%a)) ison $chan) {
        var %nick = $v1
        break
      }
      inc %a
    }
    if (%nick ison $chan) {
      var %network = $gettok($network,1,46)
      saveinfo %nick %Pack %network
      var %scid = $XDCCb-network(%network)
      var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
      if ($hget($+(Xdccbhash-,%nick2),Get) >= $hfind($+(Xdccbhash-,%nick2),pack*,0,w)) XDCCb-request-Pack %nick $+($chr(35),$remove($gettok(%Pack,2,9),$chr(32))) %scid %network %Pack
    }
  }
}
on *:input:*: {
  if ($chan = #incomplete) && ($1 = !request) {
    var %file = $gettok($2-,1,47)
    var %desc = $gettok($2-,2-,47)
    writeini -n $qt(%XDCCb-corrupt.ini) %file Desc %desc
    if ($dialog(XDCCb-c)) did -a XDCCb-c 11 %file $chr(9) %desc
    return
  }
  if ($hget(xdccfserv,$active)) {
    if ($1 = Get) && ($2) {
      var %pack
      var %a = 1
      var %nick = $remove($active,=)
      while ($hget(%a)) {
        var %if = $v1
        if (Xdccb- isin %if) {
          var %pack = $hget(%if,$+(%nick,$chr(255),$hget(%if,$+(%nick,$chr(255),Fserv-use))))
          if (%pack) break
        }
        inc %a
      }
      var %network = $gettok(%if,2-,45)
      if (%pack) {
        Saveinfo %nick %Pack %network
        var %scid = $XDCCb-network(%network)
        if ($ini(%xdccgets.ini,DCC˙Allow,$gettok(%network,1,46))) scid -t1 %scid /.DCCALLOW $+(+,%user)
        if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust $+(%user,!*@*)
      }
    }
    return
  }
  if (/ !isin $1) || ( ($remove($1,/) != msg) && ($remove($1,/) != ctcp) ) return
  if (!$chan) && (!$xdccb-changet($cid,$2)) return
  var %pack = [ [ $+($,$0) ] ]
  if ($left(%pack,1) != $chr(35) ) || ($right(%pack,-1) !isnum) return
  var %network = $gettok($network,1,46)
  var %line = [ [ $+($,2-,$calc($0 -1)) ] ]
  var %pack = $remove(%pack,$chr(35))
  var %usage = $hget($+(XDCCb-,%network),$+($2,$chr(255),Usage))
  if ($remove($1,/.,/) %line = $remove($gettok(%usage,1,32),/.,/) $gettok(%usage,2-,32) ) || ( (!%usage) && ($3-4 = XDCC Send) ) {
    if ($hget($+(XDCCb-,%network),$+($2,$chr(255),%pack))) var %packname = $gettok($v1,1,9)
    else var %packname = Requesting Pack no. $+($chr(35),%Pack)
    if (!%usage) hadd -m $+(XDCCb-,%network) $+($2,$chr(255),Usage) $replace($1,//,/.,/,/.) %line
    saveinfo $2 %packname $chr(9) %pack $chr(9) n/a %network
    XDCCb-request-Pack $2 $+($chr(35),%Pack) $cid $network Requesting Pack no. %Pack $chr(9) %pack $chr(9) n/a
    halt
  }
}
on *:join:*: {
  var %network = $gettok($network,1,46)
  if ($nick = $me) {
    if ($hget(Xdccboptions,XDCCAutoGet) = on) .Timer 1 5 XDCCb-onme-join $chan %network
    if ($hget(Xdccboptions,XDCC-Requestlist) = on) .Timer 1 5 XDCC-RequestList $chan
    if ($chan = #incomplete) && ($hget(Xdccboptions,Auto-Corrupt) = yes) {
      var %file = $ini(%XDCCb-corrupt.ini,1)
      if (!$Readini(%XDCCb-corrupt.ini,%file,$network)) && (%file) .timer 1 $rand(20,60) msg $chan !request %file / $Readini(%XDCCb-corrupt.ini,%file,desc)
    }
    if ($dialog(xdccb)) {
      var %root = $find-branch(xdccb,27,%network)
      if ($find-branch(xdccb,27,$chan,%root)) {
        var %subroot = $v1
        did -i xdccb 27 1 cb root %root
        if ($did-tree(xdccb,27,%root %subroot).Icon = 5) did -i xdccb 27 1 replaceitem %subroot $did-tree(xdccb,27,%root %subroot).flag 2 2 $chan $chr(9) Click on the channel for a list of nicks.
      }
      else {
        did -i xdccb 27 1 cb root %root
        did -a xdccb 27 + 2 2 $chan $chr(9) Click on the channel for a list of nicks.
      }
    }
    return
  }
  else {
    if ($dialog(xdccb)) {
      var %root = $find-branch(xdccb,27,%network)
      var %root = %root $find-branch(xdccb,27,$chan,%root)
      if ($find-branch(xdccb,27,$nick,%root)) {
        did -i xdccb 27 1 cb root %root
        did -i xdccb 27 1 replaceitem $v1 $did-tree(xdccb,27,%root $v1).flag 3 3 $nick $chr(9) Click on the nick for a list of packs.
      }
    }
    if ($hget(Xdccboptions,XDCCAutoGet) = on) {
      var %nick = $replace($nick,[,$chr(60),],$chr(62))
      if ($ini(%xdccgets.ini,%nick)) {
        var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
        var %chan = $hget($+(Xdccbhash-,%nick),chan)
        var %get = $hget($+(Xdccbhash-,%nick),get)
        var %Pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
        if (%network = $gettok($network,1,46)) && ($chan = %chan) && (%Pack) $+(.TimerXDCCB-,$nick) 1 $calc($rand(20,60)) XDCCb-request-Pack $nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) $cid %network %Pack
      }
    }
  }
}
on *:load: {
  if ($mircdir != $scriptdir) {
    if (!$isfile($scriptdir\xdccgets.ini)) && ($isfile($mircdir\xdccgets.ini)) rename $qt($mircdir\xdccgets.ini) $scriptdir\xdccgets.ini
    if (!$isfile($scriptdir\Xdccb-Autosave.ini)) && ($isfile($mircdir\Xdccb-Autosave.ini)) rename $qt($mircdir\Xdccb-Autosave.ini) $qt($scriptdir\Xdccb-Autosave.ini)
    if (!$isfile($scriptdir\XDCCb-corrupt.ini)) && ($isfile($mircdir\XDCCb-corrupt.ini)) rename $qt($mircdir\XDCCb-corrupt.ini) $qt($scriptdir\XDCCb-corrupt.ini)
    if (!$isfile($scriptdir\Xdccb-Downloads.ini)) && ($isfile($mircdir\Xdccb-Downloads.ini)) rename $qt($mircdir\Xdccb-Downloads.ini) $qt($scriptdir\Xdccb-Downloads.ini)
    if (!$isfile($scriptdir\Xdccb-Search.txt)) && ($isfile($mircdir\Xdccb-Search.txt)) rename $qt($mircdir\Xdccb-Search.txt) $qt($scriptdir\Xdccb-Search.txt)
  }
  :error
  if ($error) {
    reseterror
    set %xdccgets.ini $mircdir\xdccgets.ini
    set %Xdccb-Autosave.ini $mircdir\Xdccb-Autosave.ini
    set %XDCCb-corrupt.ini $mircdir\XDCCb-corrupt.ini
    set %Xdccb-Downloads.ini $mircdir\Xdccb-Downloads.ini
    set %Xdccb-Search.txt $mircdir\Xdccb-Search.txt
  }
  else {
    set %xdccgets.ini $scriptdir\xdccgets.ini
    set %Xdccb-Autosave.ini $scriptdir\Xdccb-Autosave.ini
    set %XDCCb-corrupt.ini $scriptdir\XDCCb-corrupt.ini
    set %Xdccb-Downloads.ini $scriptdir\Xdccb-Downloads.ini
    set %Xdccb-Search.txt $scriptdir\Xdccb-Search.txt
  }
  var %xdccgets.ini = $qt(%xdccgets.ini)
  XDCCB-Setup
  if ($readini(%xdccgets.ini,DCC˙Allow,Networks)) { 
    var %networks = $readini(%xdccgets.ini,DCC˙Allow,Networks)
    var %a = 1
    while ($gettok(%networks,%a,255)) {
      writeini -n $qt(%xdccgets.ini) DCC˙Allow $v1 $v1
      inc %a
    }
    remini -n $qt(%xdccgets.ini) DCC˙Allow Networks
  }
  var %setup = $input(Welcome to XDCC Browser. $crlf The script will now install itself. $crlf Click yes if you want the script to optimize mIRC.,nvq,XDCC Browser)
  if (%setup != $cancel) {
    if ($gettok($readini(mirc.ini,options,n6),28,44) != 2) || ($sreq != auto) {
      if (%setup == $no) var %check = $input(Do you want XDCC Browser to set your mIRC client to automaticaly accept all files except for these types ? $crlf $replace($readini(mirc.ini,text,ignore),$chr(44),$chr(32)) $crlf From trusted users ?,yq,XDCC Browser)
      if (%check = $true || %setup == $yes) {
        .dcc ignore ignore 
        .sreq +m auto
      }
    }
    if ($gettok($readini(mirc.ini,options,n7),19,44) = 0) {
      if (%setup == $no) var %check = $input(Do you want XDCC Browser to set your mIRC client to receive files only from a list of "Trusted" users ?,yq,XDCC Browser)
      if (%check = $true || %setup == $yes) {
        .sreq +m auto
        .dcc trust on
      }
    }
  }
  remini -n %xdccgets.ini $+($chr(38),Options,$chr(38)) Sock-net
  remini -n %xdccgets.ini $+($chr(38),Options,$chr(38)) Line
  remini -n %xdccgets.ini $+($chr(38),Options,$chr(38)) Sock-start
  remini -n %xdccgets.ini $+($chr(38),Options,$chr(38)) Sock-serv
  remini -n %xdccgets.ini $+($chr(38),Options,$chr(38)) Sock-nick
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    if (%nick != DCC˙Allow) && (%nick != $+($chr(38),Options,$chr(38))) {
      if ($hget($+(Xdccbhash-,%nick),Pack)) {
        var %Packs = $v1
        var %Dates = $hget($+(Xdccbhash-,%nick),Date)
        var %Times = $hget($+(Xdccbhash-,%nick),Time)
        var %b = 1
        while ($gettok(%Packs,%b,255)) {
          var %Pack = $v1
          var %num = $gettok(%Pack,1,46)
          writeini -n %xdccgets.ini %nick $+(Pack,%num) %Pack
          writeini -n %xdccgets.ini %nick $+(Date,%num) $gettok(%Dates,%b,255)
          writeini -n %xdccgets.ini %nick $+(Time,%num) $gettok(%Times,%b,255)
          inc %b
        }
        remini -n %xdccgets.ini %nick Pack
        remini -n %xdccgets.ini %nick Date
        remini -n %xdccgets.ini %nick Time
      }
      if ($hget($+(Xdccbhash-,%nick),Network)) {
        writeini -n %xdccgets.ini %nick Network $gettok($hget($+(Xdccbhash-,%nick),Network),1,46)
        if ($hget($+(Xdccbhash-,%nick),Server))  .server -a $hget($+(Xdccbhash-,%nick),Server) $iif($hget($+(Xdccbhash-,%nick),Port),-p $v1) -g $hget($+(Xdccbhash-,%nick),Network)
      }
    }
    inc %a
  }
  var %a = 1
  while ($hget(%a)) {
    var %if = $v1
    if (Xdccb- isin %if) {
      .hfree %if
      continue
    }
    inc %a
  }
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    if (%nick != DCC˙Allow) && (%nick != $+($chr(38),Options,$chr(38))) {
      var %b = 1
      while ($hfind($+(Xdccbhash-,%nick),Pack*,%b,w)) {
        var %section = $v1
        var %pack = $hget($+(Xdccbhash-,%nick),%section)
        if ($chr(9) isin %pack) return
        writeini -n %xdccgets.ini %nick %section $gettok(%pack,$+(2-,$calc($numtok(%pack,32) -1)),32) $chr(9) $calc($remove($gettok(%pack,1,32),.)) $chr(9) $remove($gettok(%pack,2,171),$chr(187))
        inc %b
      }
    }
    inc %a
  }
  var %a = 1
  while ($findfile($mircdir,Xdccb-queues-*.txt,%a)) {
    var %file = $v1
    if ($numtok($nopath(%file),46) > 2) .rename $qt(%file) $+(",$nofile(%file),$gettok($nopath(%file),1,46),.txt")
    inc %a
  }
  Xdccb-HashUsers
  if (%setup != $cancel) && ($hget(xdccboptions,Links) != on) && (!$portable) {
    if (%setup == $no || %setup == $yes) var %check = $?!="Do you want the XDCC Browser to control IRC:\\ Links from the web ?"
    if (%check = $true) {
      xdccb-addoption Links on
      Xdccb-Make-reg
      run regedit /s /c XdccB.reg
    }
  }
  linesep
  Echo -ats $+(,$color(info)) Finished loading XDCC Browser v4.50
  Echo -ats $+(,$color(action)) Right click, and choose XDCC Browser to use the script.
  linesep
  xdccb
}
on *:mode:*: {
  if (+*k * iswm $1-) {
    var %a = 1
    while ($hget(%a)) {
      var %hash = $v1
      if (Xdccbhash-* iswm %hash) {
        var %network = $hget(%hash,network)
        var %chan = $hget(%hash,chan)
        if (%chan = $chan) && (%network = $gettok($network,1,46)) {
          writeini -n $qt(%xdccgets.ini) %nick Key $eval($+($,$0),2)
          Xdccb-Hashnick $gettok(%hash,2-,45)
        }
      } 
      inc %a      
    }
  }
}
on *:unload: {
  write -c XdccB.reg
  if (9* iswm $os) || ($os = ME) write XdccB.reg REGEDIT4
  else write XdccB.reg Windows Registry Editor Version 5.00
  write XdccB.reg $crlf
  write XdccB.reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec]
  write XdccB.reg @=" $+ $chr(37) $+ 1"
  write XdccB.reg $crlf 
  write XdccB.reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\ifexec]
  write XdccB.reg @=" $+ $chr(37) $+ 1"
  write XdccB.reg $crlf
  write XdccB.reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\Topic]
  write XdccB.reg @="Connect"
  write XdccB.reg $crlf
  write XdccB.reg [-HKEY_CLASSES_ROOT\XDCC]
  write XdccB.reg $crlf
  write XdccB.reg [-HKEY_CLASSES_ROOT\.xcb]
  xdccb-addoption Links off
  if (!$portable) run regedit /s /c XdccB.reg
  .timer 1 1 .remove XdccB.reg
}
on ^*:notice:*:*: {
  if (!$network) return
  if ($1-2 = DCC Fserve) {
    hadd -m Xdccfserv =$nick 1
    return
  }
  var %listing = $hget(Xdccboptions,Listing)
  if ($gettok(%listing,1,32) = 1) { 
    if ($chr(35) isin $1-2) {
      if ($xPack($1-)) {
        var %Pack = $puttok($v1,$replace($gettok($v1,1,9),$chr(32),$chr(160)),1,9)
        if ($chr(43) = $left($gettok(%pack,1,32),1)) var %pack = $replace($gettok(%pack,1,32),$chr(43),$chr(45)) $gettok(%pack,2-,32)
        if ($comchan($nick,1)) addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %Pack
        if ($hget(Xdccboptions,Hide-Packs) = on) haltdef
        return
      }
    }
    if ($Xdccdata($1-)) return
  }
  if ($gettok(%listing,2,32) = 1) && (Trigger isin $1-) {
    if ($fpack($1-)) {
      if ($hget(Xdccboptions,Hide-Fserv) = on) haltdef
      else return
    }
  }
  if ($gettok(%listing,3,32) = 1) && (FTP isin $1-) && ($ftppack($1-)) return
  if ((/ctcp isin $1-) || (/msg isin $1-)) {
    if (Position type isin $1-) && (been listed isin $1-) && (queue isin $1-) $iif(/msg isin $1-,/.msg,/.ctcp) $nick xdcc queues
    if ($XUsage($nick,$1-) && ($hget(Xdccboptions,Hide-Packs) = on)) haltdef
  }
  if ($3 = $null) return
  var %nick = $replace($nick,[,$chr(60),],$chr(62))
  if ($ini(%xdccgets.ini,%nick)) {
    var %file = $qt($+($scriptdir\Xdccb-queues-,$gettok($network,1,46),.txt))
    if (!$exists(%file)) write -l0 %file 0
    var %lines = $lines(%file)
    var %nicks = $calc($read(%file,0))
    if (!$read(%file,w,$nick,$calc(%lines - %nicks))) {
      write %file $nick
      write -l1 %file $calc($read(%file,0) +1)
    }
    write -il2 %file $nick $strip($1-) $cTime
    if (Currently full isin $1-) || ((All Slots Full isin $1-) && ( ((Try Again Later isin $1-) && (Denied !isin $1-)) || (To remove type isin $1-) ) )  || ((There are too many send isin $1- ) && ( all queue slots are used isin $1- )) $&
      || (*There are too many send* all* queue slots* iswm $1-) {
      var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
      var %chan = $hget($+(Xdccbhash-,%nick),chan)
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %Pack = $readiniwm(%xdccgets.ini,%nick,pack*,%get)
      if (%network = $gettok($network,1,46)) && ($nick ison %chan) && (%Pack) $+(.TimerXDCCB-,$nick) 1 $hget(Xdccboptions,Request-Timer) XDCCb-request-Pack $nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) $cid $network %Pack
    }
    elseif ($xdccb-Queues($nick,$gettok($network,1,46))) && ($Timer($+(XDCCB-,$nick))) $+(.TimerXDCCB-,$nick) off
  }
}
on ^*:open:?:*: if ($1- = You Don't Appear To Be In A Queue) haltdef
on *:part:*: {
  var %network = $gettok($network,1,46)
  if ($dialog(XDCCb)) {
    var %root = $find-branch(xdccb,27,%network)
    var %subroot = $find-branch(xdccb,27,$chan,%root)
    var %loc = %root %subroot
    if (%loc) {
      if ($nick = $me) {
        if ($did-tree(xdccb,27,%loc).lines = 0) {
          did -i xdccb 27 1 cb root %root
          did -d xdccb 27 $find-branch(xdccb,27,$chan,%root)
        }
        else {
          did -i xdccb 27 1 cb root %root
          did -i xdccb 27 1 replaceitem %subroot $did-tree(xdccb,27,%loc).flag 5 5 $chan $chr(9) Click on the channel for a list of nicks.
          var %a = 2
          while ($did-tree(xdccb,27,%loc %a)) {
            var %nick = $v1
            did -i xdccb 27 1 cb root %loc
            did -i xdccb 27 1 replaceitem %a $did-tree(xdccb,27,%loc %a).flag 6 6 %nick $chr(9) Click on the channel for a list of nicks.
            inc %a
          }
        }
      }
      elseif ($find-branch(xdccb,27,$nick,%loc)) {
        did -i xdccb 27 1 cb root %loc
        did -i xdccb 27 1 replaceitem $v1 $did-tree(xdccb,27,%loc $v1).flag 6 6 $nick $chr(9) Click on the nick for a list of packs.
      }
    }
  }
  if ($hget(Xdccboptions,Delete) != on) return
  if ($nick = $me) {
    var %a = 1
    while ($hget(%hash,%a).item) {
      var %item = $v1
      if (*˙Chan iswm %item) {
        if ($hget($+(XDCCb-,%network,-data),%item) = $chan) {
          hdel -w $+(XDCCb-,%network) $+($gettok(%item,1,255),˙*)
          hdel -w $+(XDCCb-,%network,-data) $+($gettok(%item,1,255),˙*)
          continue
        }
      }
      inc %a
    }
  }
  elseif ($hmatch($+(XDCCb-,%network),$+($nick,$chr(255),*),1)) {
    if ($comchan($nick,0) = 0) { 
      hdel -w $+(XDCCb-,%network) $+($nick,$chr(255),*)
      hdel -w $+(XDCCb-,%network,-data) $+($nick,$chr(255),*)
      if ($dialog(XDCCb)) uPackno  
    }
  }
}
on *:quit: {
  var %network = $gettok($network,1,46)
  if ($hget(Xdccboptions,Delete) = on) && ($hmatch($+(XDCCb-,%network),$+($nick,$chr(255),*),1)) {
    if ($dialog(XDCCb)) {
      var %loc = $find-branch(xdccb,27,%network)
      var %loc = %loc $find-branch(xdccb,27,$hget($+(XDCCb-,%network,-data),$+($nick,$chr(255),chan)),%loc)
      if (!%loc) return
      did -i xdccb 27 1 cb root %loc
      if ($Find-branch(XDCCb,27,$nick,%loc)) did -d XDCCb 27 $v1 
      if ($did-tree(xdccb,27,%loc).lines = 0) did -d xdccb 27 %loc
      uPackno
    }
    hdel -w $+(XDCCb-,%network) $+($nick,$chr(255),*)
    hdel -w $+(XDCCb-,%network,-data) $+($nick,$chr(255),*) 
    if ($Timer($+(XDCCB-,$nick))) $+(.TimerXDCCB-,$nick) off
  }
  elseif ($dialog(XDCCb)) {
    var %loc = $find-branch(xdccb,27,%network)
    var %a = 1
    while ($comchan($nick,%a)) {
      var %chan = $v1
      var %loc = %loc $find-branch(xdccb,27,%chan,%loc)
      if ($find-branch(xdccb,27,$nick,%loc)) {
        did -i xdccb 27 1 cb root %loc
        did -i xdccb 27 1 replaceitem $v1 $did-tree(xdccb,27,%loc $v1).flag 6 6 $nick $chr(9) Click on the nick for a list of packs.
      }
      inc %a
    }
  }
}
on *:signal:UserInput: {
  if ($dialog(xdccb).active) {
    var %keys = $dll($scriptdir\UserInput.dll,getKeyStates,)
    if ($2 = 256) && ($3 = 32851) {
      if (%xdccb-list = 27) || (%xdccb-list = 28) .signal $+(Mpopup.XDCCB,%xdccb-list) 2 
      elseif (%xdccb-list = 308) .signal $+(Mpopup.XDCCB,%xdccb-list) 373
      elseif (%xdccb-list = 501) {
        if ($gettok(%keys,161,32) > 100) || ($gettok(%keys,162,32) > 100) .signal $+(Mpopup.XDCCB,%xdccb-list) 384
        .signal $+(Mpopup.XDCCB,%xdccb-list) 382
      }
    }
    if ($2 = 256) && ($3 = 31) && ($dialog(xdccb).tab = 100) && (($gettok(%keys,163,32) > 100) || ($gettok(%keys,164,32) > 100)) xdccb-SaveALL
    if ($2 = 256) && ($3 = 30) && (%xdccb-list != 27) && (($gettok(%keys,163,32) > 100) || ($gettok(%keys,164,32) > 100)) {
      var %lines = $did(xdccb,%xdccb-list).lines
      while (%lines > 1) {
        did -kc xdccb %xdccb-list
        dec %lines
      }
    }
  }
}
On *:Signal:Mpopup.XDCCB*: {
  ;Join
  if ($1 = 1) {
    var %chan
    if ($signal = Mpopup.XDCCB207) {
      var %line = $did(XDCCb,207).seltext
      var %line = $did-list(1-,%line)
      var %network = $remove($gettok(%line,9,9),$chr(32))
      var %chan = $gettok(%line,8,9)
      var %server = $gettok($gettok(%line,10,9),1,4)
    }
    elseif ($signal = Mpopup.XDCCB308) {
      var %nick = $replace($did-list(6,$did(xdccb,308).seltext),[,$chr(60),],$chr(62))
      var %network = $did-list(8,$did(xdccb,308).seltext)
      var %server = $hget($+(Xdccbhash-,%nick),server)
      var %chan = $hget($+(Xdccbhash-,%nick),chan)
      var %key = $hget($+(Xdccbhash-,%nick),key)
    }
    else {
      var %network = $did-tree(xdccb,27,$did-tree(xdccb,27).root)
      var %server = $hget($+(xdccb-,%network,-data),$hfind($+(xdccb-,%network,-data),*˙Server,1,w))
      if ($did-tree(xdccb,27,$gettok($did-tree(xdccb,27).sel,1-2,32)) != %network) var %chan = $v1
    }
    Xdccb-Join 1 %network %server %chan %key
  }
  ;Remove
  if ($1 = 2) {
    if ($did-tree(xdccb,27).root) var %network = $did-tree(xdccb,27,$v1)
    if ($signal = Mpopup.XDCCB28) {
      while ($did(xdccb,28,1).sel) {
        if (!$did-tree(xdccb,27)) {
          var %nick = $gettok($hfind($+(%name,$gettok($network,1,46)),$did(XDCCb,28,1).seltext,1,w).DATA,1,255)
          var %Pack = $+($gettok($hfind($+(%name,$gettok($network,1,46)),$did(XDCCb,28,1).seltext,1,w).DATA,2,255),.) $did(xdccb,28).seltext
        }
        else {
          if ($numtok($did-tree(xdccb,27).sel,32) = 2) var %nick = $did-list(7,$gettok($did(xdccb,28).seltext,1,4))
          else var %nick = $did-tree(xdccb,27)
          var %Pack = $did(xdccb,28,1).seltext
        }
        var %Pack = $did-list(2,%Pack)
        if (List* !iswm %Pack) var %Pack = $calc(%Pack)
        hdel -w $+(xdccb-,%network) $+(%nick,$chr(255),%Pack)
        did -d XDCCb 28 $did(xdccb,28,1).sel
        var %loc = $did-tree(xdccb,27).sel
        if ($did(xdccb,28).lines < 2) did -d XDCCb 27 $gettok(%loc,3,32)
        if ($hfind($+(XDCCb-,%network,-data),*˙Chan,0,w) = 0) {
          .hfree $+(xdccb-,$did-tree(xdccb,27))
          if ($hget($+(XDCCb-,%network,-data))) .hfree $+(XDCCb-,%network,-data)
          goto end2
        }
      }
    }
    elseif ($signal = Mpopup.XDCCB27) {
      var %loc = $did-tree(xdccb,27).sel
      var %depth = $numtok(%loc,32)
      if (%depth = 1) {
        if ($hget($+(xdccb-,%network))) .hfree $+(xdccb-,%network)
        if ($hget($+(XDCCb-,%network,-data))) .hfree $+(XDCCb-,%network,-data)
        var %scid = $XDCCb-network(%network)
        if (!%scid) {
          did -i xdccb 27 1 cb root
          did -d xdccb 27 %loc
          goto end2
        }
        did -i xdccb 27 1 cb root %loc
        var %a = 2
        while ($did-tree(xdccb,27,%loc %a)) {
          var %chan = $v1
          did -d xdccb 27 %a
          if ($XDCCb-onchan(%scid,%chan)) did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
          inc %a
        }
      }
      elseif (%depth = 2) {
        var %a = 1
        while ($hfind($+(xdccb-,%network,-data),*˙Chan,%a,w)) {
          var %item = $v1
          if ($hget($+(xdccb-,%network,-data),%item) = $did-tree(xdccb,27)) {
            hdel -w $+(xdccb-,%network) $+($gettok(%item,1,255),˙*)
            hdel -w $+(xdccb-,%network,-data) $+($gettok(%item,1,255),˙*)
            continue
          }
          inc %a
        }
        did -i xdccb 27 1 cb root $did-tree(xdccb,27).root
        var %chan = $did-tree(xdccb,27)
        var %scid = $XDCCb-network(%network)
        did -d xdccb 27 $gettok(%loc,2,32)
        if ($XDCCb-onchan(%scid,%chan)) {
          did -i xdccb 27 1 cb root $gettok(%loc,1,32)
          did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
        }
        if ($hfind($+(XDCCb-,%network,-data),*˙Chan,0,w) = 0) {
          if ($hget($+(xdccb-,%network))) .hfree $+(xdccb-,%network)
          if ($hget($+(xdccb-,%network,-data))) .hfree $+(xdccb-,%network,-data)
          if (!%scid) {
            did -i xdccb 27 1 cb root
            did -d xdccb 27 %loc
          }
          goto end2
        }
      }
      elseif (%depth = 3) {
        hdel -w $+(xdccb-,%network) $+($did-tree(xdccb,27),$chr(255),*)
        hdel -w $+(xdccb-,%network,-data) $+($did-tree(xdccb,27),$chr(255),*)
        did -i xdccb 27 1 cb root $gettok(%loc,1-2,32)
        did -d XDCCb 27 $gettok(%loc,3,32) 
        did -r xdccb 28
        var %chan = $did-tree(xdccb,27)
        var %scid = $XDCCb-network(%network)
        if ($did-tree(xdccb,27,$gettok(%loc,1-2,32)).lines < 1) && (!$XDCCb-onchan(%scid,%chan)) {
          did -d xdccb 27 $gettok(%loc,2,32)
          did -i xdccb 27 1 cb root $gettok(%loc,1,32)
          did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
        }
        if ($hfind($+(XDCCb-,%network,-data),*˙Chan,0,w) = 0) {
          if ($hget($+(xdccb-,%network))) .hfree $+(xdccb-,%network)
          if ($hget($+(xdccb-,%network,-data))) .hfree $+(xdccb-,%network,-data)
          if (!%scid) {
            did -i xdccb 27 1 cb root
            did -d xdccb 27 %loc
          }
        }
      }
    }
    :end2
    var %loc = $did-tree(xdccb,27).sel
    var %depth = $numtok(%loc,32)
    if (%depth = 3) XDCCb28
    filter -criw $+(2-,$did(xdccb,28).lines) xdccb 28 @tmpXdccb28 *
    filter -cot 1 9 @tmpXdccb28 xdccb 28 * 
    uPackno
  }
  ;Request
  if ($1 = 3) {
    if ($signal = Mpopup.XDCCB308) var %id = 308
    elseif ($signal = Mpopup.XDCCB207) var %id = 207
    else var %id = 28
    var %b = 1
    while ($did(xdccb,%id,%b).sel) {
      if (%id = 207)  {
        var %match
        var %line-num = $did(XDCCb,207,%b).sel
        var %line = $did(XDCCb,207,%line-num).text
        var %line = $did-list(1-,%line)
        var %Pack = $gettok(%line,1-4,9)
        var %nick = $remove($gettok(%line,7,9),$chr(32))
        var %num = $+($chr(35),$remove($gettok(%line,2,9),$chr(32)))
        var %net = $gettok($remove($gettok(%line,9,9),$chr(32)),1,46)
        var %scid = $XDCCb-network(%net)
        var %Pack-num = $remove($gettok(%line,2,9),$chr(32))
        if (!$hget($+(Xdccb-,%net),$+(%nick,$chr(255),%Pack-num))) {
          var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
          var %Server = $remove($gettok($gettok(%line,10,9),1,4),$chr(32))
          var %port = 6667
          var %chan = $+($remove($gettok(%line,8,9),$chr(32)))
          var %Pack = $gettok(%line,1-4,9)
          var %a = 1
          while ($hget($+(Xdccbhash-,%nick2),$hfind($+(Xdccbhash-,%nick2),Pack*,%a,w))) {
            var %temp-Pack = $v1 
            if (%temp-Pack = %Pack) var %match = %Pack
            inc %a
          }
          if (!%match) {
            var %xdccgets.ini = $qt(%xdccgets.ini)
            writeini -n %xdccgets.ini %nick2 $+(Pack,%Pack-num) %Pack
            writeini -n %xdccgets.ini %nick2 $+(Date,%Pack-num) $Date
            writeini -n %xdccgets.ini %nick2 $+(Time,%Pack-num) $Time
            writeini -n %xdccgets.ini %nick2 Chan %chan
            var %usage = $gettok(%line,2,4)
            writeini -n %xdccgets.ini %nick2 Usage $gettok(%usage,$+(1-,$calc($numtok(%usage,35) -1)),35)
            Xdccb-RandomServer %net %nick2 %server %port
            writeini -n %xdccgets.ini %nick2 Network %net
            writeini -n %xdccgets.ini %nick2 Port %port
            if (!$hget($+(Xdccbhash-,%nick2),get)) writeini -n %xdccgets.ini %nick2 Get 1
            Xdccb-Hashnick %nick2
            if ($dialog(XDCCb)) {
              if ( $didwm(xdccb,308,$+(*,$replace(%pack,$chr(9),$+(*,$chr(9),*)),*,%nick,*),1) = 0 ) {
                var %get = $hget($+(Xdccbhash-,%nick2),get)
                var %packs = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)
                var %order = $iif($calc(%packs - %get +1) > 0,$v1,Finished)
                var %stat = $Xdccb-stats(%nick,%net,%chan,%order)
                if ($numtok(%pack,9) = 2) var %pack = %pack $chr(9) n/a
                did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 $gettok(%pack,1-3,9) $chr(9) $gettok(%stat,1,9) $chr(9) $ord(%order) $chr(9) %nick $chr(9) %chan $chr(9) %net $chr(9) %server
              } 
            }
            if (%scid) && ($hget($+(Xdccbhash-,%nick2),Get) >= $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)) $+(.TimerXDCCB-,%nick) 1 2 XDCCb-request-Pack %nick $+($chr(35),$remove($gettok(%Pack,2,9),$chr(32))) %scid %net %Pack
            else Xdccb-joinuser %nick %net
            inc %b 
            continue
          }
        }
        elseif (File server !isin %pack) {
          Saveinfo %nick %Pack %net
          var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
          if (%scid) && ($hget($+(Xdccbhash-,%nick2),Get) >= $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)) $+(.TimerXDCCB-,%nick) 1 2 XDCCb-request-Pack %nick $+($chr(35),$remove($gettok(%Pack,2,9),$chr(32))) %scid %net %Pack
          else Xdccb-joinuser %nick %net
          inc %b
          continue
        }
      }
      elseif (%id = 308) {
        if (!$did(xdccb,308).seltext) return
        var %line = $did(XDCCb,308,%b).sel
        var %nick = $did-list(6,$did(xdccb,308,%line).text)
        var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
        var %net = $gettok($hget($+(Xdccbhash-,%nick2),network),1,46)
        var %scid = $XDCCb-network(%net)
        var %chan = $hget($+(Xdccbhash-,%nick2),chan)
        var %pack = $gettok($did(xdccb,308,%line).text,1-3,9)
        if ($did-list(4,$did(xdccb,308,%line).text) = Paused) xdccb-remove %nick2 Pause
      }
      else {
        var %line = $did(XDCCb,28,%b).sel
        var %net = $Xdccb-getscid
        var %scid = $gettok(%net,1,32)
        var %net = $gettok(%net,2,32)
        var %loc = $did-tree(xdccb,27).sel
        if ($numtok(%loc,32) = 3) {
          var %nick = $did-tree(xdccb,27)
          var %Pack = $gettok($did(xdccb,28,%line).text,1,4)
        }
        else {
          var %nick = $gettok($did-list(7,$did(xdccb,28,%line).text),1,4)
          var %Pack = $gettok($did(xdccb,28,%line).text,1-4,9)
        }
      }
      if (list* iswm $gettok(%Pack,1,46)) {
        scid -t1 %scid $+(/.,$gettok(%Pack,2-,46))
        return 
      }
      if (*File server*:* iswm $gettok(%pack,6,32)) {
        var %pack = $did-list(1-,%pack)
        hadd $+(XDCCb-,%net) $+(%nick,$chr(255),Fserv-use) $+(File server,$calc($gettok(%pack,2,9)))
        Xdccb-request-fserv %nick %net %scid $gettok(%pack,1,9)
      }
      elseif (FTP Site: = $gettok(%pack,6,32)) {
        run $+(FTP://,$gettok(%pack,7,32))
        return
      }
      elseif ($signal = Mpopup.XDCCB28) Saveinfo %nick %Pack %net
      var %pack = $did-list(1-,%pack)
      var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
      if (%scid) {
        var %chan = $hget($+(xdccb-,%net,-data),$+(%nick,$chr(255),chan))
        if (!$XDCCb-onchan(%scid,%chan)) Xdccb-joinuser %nick %net
        else {
          var %get = $hget($+(Xdccbhash-,%nick2),Get)
          var %pack = $readiniwm(%xdccgets.ini,%nick2,pack*,%get)
          if ($hget($+(Xdccbhash-,%nick2),Get) >= $hfind($+(Xdccbhash-,%nick2),pack*,0,w)) $+(.TimerXDCCB-,%nick) 1 2 XDCCb-request-Pack %nick $+($chr(35),$remove($gettok(%Pack,2,9),$chr(32))) %scid %net %Pack
        }
      }
      else Xdccb-joinuser %nick %net
      inc %b
    }
  }
  ;Add
  if ($1 = 4) {
    if ($signal != Mpopup.XDCCB207) && ((!$did(xdccb,28).sel) || (FTP: = $gettok($did(xdccb,28).seltext,1,32)) || (List* iswm $gettok($did(xdccb,28).seltext,1,32))) return
    if ($signal = Mpopup.XDCCB207) && (!$did(xdccb,207).sel) return
    var %net = $Xdccb-getscid
    var %scid = $gettok(%net,1,32)
    var %net = $gettok(%net,2,32)
    var %match
    var %a = 1
    var %xdccgets.ini = $qt(%xdccgets.ini)
    if ($signal = Mpopup.XDCCB207) var %id = 207
    else var %id = 28
    while (%a <= $did(xdccb,%id,0).sel) {
      if ($signal = Mpopup.XDCCB207) {
        var %line-num = $did(XDCCb,207,%a).sel
        var %line = $did(XDCCb,207,%line-num).text
        var %line = $did-list(1-,%line)
        var %Pack = $gettok($did(XDCCb,207,%line-num).text,1-4,9)
        var %nick = $remove($gettok(%line,7,9),$chr(32))
        var %num = $+($chr(35),$remove($gettok(%line,2,9),$chr(32)))
        var %net = $gettok($remove($gettok(%line,9,9),$chr(32)),1,46)
        var %scid = $XDCCb-network(%net)
        var %Pack-num = $remove($gettok(%line,2,9),$chr(32))
        if (!$hget($+(Xdccb-,%net),$+(%nick,$chr(255),%Pack-num))) {
          var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
          var %Server = $remove($gettok($gettok(%line,10,9),1,4),$chr(32))
          var %port = 6667
          var %chan = $+($remove($gettok(%line,8,9),$chr(32)))
          var %Pack = $gettok(%line,1-3,9)
          var %b = 1
          while ($hget($+(Xdccbhash-,%nick2),$hfind($+(Xdccbhash-,%nick2),Pack*,%b,w))) {
            var %temp-Pack = $v1 
            if (%temp-Pack = %Pack) var %match = %Pack
            inc %b
          }
          if (!%match) {
            writeini -n %xdccgets.ini %nick2 $+(Pack,%Pack-num) %Pack
            writeini -n %xdccgets.ini %nick2 $+(Date,%Pack-num) $Date
            writeini -n %xdccgets.ini %nick2 $+(Time,%Pack-num) $Time
            writeini -n %xdccgets.ini %nick2 Chan %chan
            if (!$readini(%xdccgets.ini,%nick2,Get)) {
              writeini -n %xdccgets.ini %nick2 Get 1
              writeini -n %xdccgets.ini %nick2 Pause 1
            }
            var %usage = $gettok(%line,2,4)
            writeini -n %xdccgets.ini %nick2 Usage $gettok(%usage,$+(1-,$calc($numtok(%usage,35) -1)),35)
            Xdccb-RandomServer %net %nick2 %server %port
            writeini -n %xdccgets.ini %nick2 Network %net
            writeini -n %xdccgets.ini %nick2 Port %port
            if (!$hget($+(Xdccbhash-,%nick2),get)) writeini -n %xdccgets.ini %nick2 Get 1
            Xdccb-Hashnick %nick2
            if ($dialog(XDCCb)) {
              if ( $didwm(xdccb,308,$+(*,$replace(%pack,$chr(9),$+(*,$chr(9),*)),*,$1,*),1) = 0 ) {
                var %get = $hget($+(Xdccbhash-,%nick2),get)
                var %c = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)
                var %order = $iif($calc(%c - %get +1) > 0,$v1,Finished)
                var %stat = $Xdccb-stats(%nick,%net,%chan,%order)
                did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 %pack $chr(9) $gettok(%stat,1,9) $chr(9) $ord(%order) $chr(9) %nick $chr(9) %chan $chr(9) %net $chr(9) %server
              } 
            }
          }
        }
        elseif (File server !isin %pack) Saveinfo %nick %Pack %net
      }
      else {
        var %line = $did(XDCCb,28,%a).sel
        if (!$did-tree(xdccb,27).sel) {
          var %nick = $gettok($hfind($+(XDCCb-,%net),$did(xdccb,28,%line).text,1,w).DATA,1,255)
          var %Pack = $+($gettok($hfind($+(XDCCb-,%net),$did(xdccb,28,%line).text,1,w).DATA,2,255),.) $did(xdccb,28,%line).text
        }
        else {
          if ($numtok($did-tree(xdccb,27).sel,32) = 3) var %nick = $did-tree(xdccb,27)
          else var %nick = $gettok($did-list(7,$did(xdccb,28,%line)),1,4)
          var %Pack = $gettok($did(xdccb,28,%line).text,1-4,9) $gettok($did(xdccb,28,%line).text,2,4)
        }
      }
      if ($signal = Mpopup.XDCCB28) Saveinfo %nick %Pack %net
      inc %a
    }
  }
  ;Network Channel List
  if ($1 = 10) {
    if ($signal = Mpopup.XDCCB207) {
      var %line = $did(XDCCb,207).seltext
      var %line = $did-list(1-,%line)
      var %network = $remove($gettok(%line,9,9),$chr(32))
    }
    else var %network = $did-tree(xdccb,27,$did-tree(xdccb,27).root)
    var %scid = $XDCCb-network(%network)
    scid -t1 %scid /list -min 10
  }
  ;Remove Offline packs
  if ($1 = 11) {
    var %a = 1
    var %blah
    while ($hget(%a)) {
      var %hash = $v1
      if (Xdccb- isin %hash) && (-data !isin %hash) {
        var %net = $gettok(%hash,2-,45))
        if (!$XDCCb-network(%net)) && (%net) {
          .hfree %hash
          if ($hget($+(XDCCb-,%network,-data))) .hfree $+(%hash,-data)
          var %blah = $Find-branch(xdccb,27,%net)
          if (%blah) did -d xdccb 27 %blah
          continue
        }
      }
      inc %a
    }
    var %a = 2
    while ($did-tree(xdccb,27,%a)) {
      var %net = $v1
      var %scid = $XDCCb-network(%net)
      var %b = 2
      while ($did-tree(xdccb,27,%a %b)) {
        var %chan = $v1
        if (!$XDCCb-onchan(%scid,%chan)) var %match = yeap
        else var %match = no
        var %c = $calc($did-tree(xdccb,27,%a %b).lines +1)
        while ($did-tree(xdccb,27,%a %b %c) ) {
          var %nick = $v1
          if (%match = yeap) || (!$XDCCb-onchan(%scid,%chan,%nick)) {
            hdel -w $+(xdccb-,%net) $+(%nick,$chr(255),*)
            hdel -w $+(xdccb-,%net,-data) $+(%nick,$chr(255),*)
            did -i xdccb 27 1 cb root %a %b
            did -d xdccb 27 %c
          }
          dec %c
        }
        if ($did-tree(xdccb,27,%a %b).lines < 1) {
          did -i xdccb 27 1 cb root %a
          did -d xdccb 27 %b
          if ($XDCCb-onchan(%scid,%chan)) {
            did -i xdccb 27 1 cb root %a
            did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
          }
          else dec %b
        }
        inc %b
      }
      inc %a
    }
    upackno
  }
  ;Quit / Part
  if ($1 = 12) {
    var %loc = $did-tree(xdccb,27).sel
    var %depth = $numtok(%loc,32)
    var %network = $did-tree(xdccb,27,$gettok(%loc,1,32))
    var %scid = $XDCCb-network(%network)
    if (%scid) {
      var %message = $iif($read($scriptdir\XDCCb-quit-messages.txt,$rand(1,$lines($scriptdir\XDCCb-quit-messages.txt))),$v1,XDCC Browser v4.50 ... The Easy Way ...)
      if (%depth = 2) {
        scid -t1 %scid /part $did-tree(xdccb,27) %message
      }
      else {
        scid -t1 %scid /quit %message
        scid %scid /window -c "Status Window" 
      }
    }
    if (!$hget($+(XDCCb-,%network))) did -d xdccb 27 %loc
  }
  ;Save selected
  if ($1 = 13) {
    var %ontop
    if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
      dialog -n xdccb
      var %ontop = yeap
    }
    var %text = $did-tree(xdccb,27)
    var %file = $sfile($+(",$scriptdir,%text,.xcb"),Save as..,Save)
    if (%ontop) dialog -o xdccb
    if (!%file) return
    if ($gettok(%file,-1,46) != xcb) var %file = $+(%file,.xcb)
    var %loc = $did-tree(xdccb,27).sel
    var %depth = $numtok(%loc,32)
    var %network = $did-tree(xdccb,27,$gettok(%loc,1,32))
    var %hash = $+(Xdccb-,%network)
    var %num = $iif(%depth = 1,$hget(%hash,0).item,$iif(%depth = 2,$hfind(%hash,%text,0).data,$hfind(%hash,$+(%text,$chr(255),*),0,w)) )
    if (%depth = 2) {
      var %a = 1
      while (($hfind(%hash,%text,%a).data) && (%num < 700) ) {
        inc %num $hfind(%hash,$+($gettok($hfind(%hash,%text,%a).data,1,255),$chr(255),*),0,w)
        inc %a 
      }
    }
    .remove $qt(%file)
    if ($appactive) {
      if (!$dialog(Xdccb-Processbar)) dialog -m xdccb-processbar Xdccb-Processbar
      dialog -t Xdccb-Processbar Saving list - %text ...
      did -a Xdccb-Processbar 1 0 0 %num
    }
    window -h @Xdccb-save
    if (%depth = 1) {
      xdccb-savenetwork %hash
      xdccb-savenetwork $+(%hash,-data)
    }
    elseif (%depth = 2) {
      xdccb-savechannel %hash %text
      xdccb-savechannel $+(%hash,-data) %text
    }
    else {
      xdccb-savebot %hash %text
      xdccb-savebot $+(%hash,-data) %text
    }
    if ($dialog(Xdccb-Processbar)) dialog -k Xdccb-Processbar 
    savebuf @Xdccb-save $qt(%file)
    window -c @Xdccb-save
  }
  ;Autosave 
  if ($1 = 14) {
    var %ontop
    if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
      dialog -n xdccb
      var %ontop = yeap
    }
    var %check = $sfile($+(",$scriptdir,%text,$+($did-tree(xdccb,27),.xcb)"),Save to:,Save)
    if (%ontop) dialog -o xdccb
    if (!%check) return
    var %loc = $did-tree(xdccb,27).sel
    var %depth = $numtok(%loc,32)
    var %net = $did-tree(xdccb,27,$gettok(%loc,1,32))
    if (%depth = 1) {
      var %a = 1
      while ($ini(%Xdccb-Autosave.ini,%net,%a)) {
        var %item = $v1
        if ($readini(%Xdccb-Autosave.ini,%net,%item) = %check) {
          remini -n $qt(%Xdccb-Autosave.ini) %net %item
          continue
        }
        inc %a
      }
      writeini -n $qt(%Xdccb-Autosave.ini) %net File %check
    }
    else writeini -n $qt(%Xdccb-Autosave.ini) %net $did-tree(xdccb,27) %check
    if ($dialog(xdccb-lists)) XDCCb-autosave-load
  }
  ;Join All
  if ($1 = 371) {
    set %xdccb-Join-All .
    var %a = 2
    if ($signal = Mpopup.XDCCB27) {
      while ($did-tree(xdccb,27,%a)) {
        var %network = $v1
        var %b = 2
        while ($did-tree(xdccb,27,%a %b)) {
          var %chan = $v1
          var %nick = $did-tree(xdccb,27,%a %b 2)
          var %server = $hget($+(xdccb-,%network,-data),$+(%nick,$chr(255),Server))
          Xdccb-join Joinall %network %server %chan
          inc %b
        }
        inc %a
      }
    }
    elseif ($signal = Mpopup.XDCCB207) {
      while ($did(xdccb,207,%a)) {
        var %line = $v1
        var %network = $did-list(9,%line)
        var %server = $gettok($did-list(10,%line),1,4)
        var %chan = $+($did-list(8,%line))
        Xdccb-join Joinall %network %server %chan
        inc %a
      }
    }   
    else {
      while ($did-list(6,$did(xdccb,308,%a))) {
        var %nick = $v1
        var %network = $did-list(8,$did(xdccb,308,%a))
        var %scid = $XDCCb-network(%network)
        var %chan = $did-list(7,$did(xdccb,308,%a))
        if (!$XDCCb-onchan(%scid,%chan)) Xdccb-joinuser %nick Joinall
        inc %a
      }
    }
    unset %xdccb-Join-All
  }
  ;Request All
  if ($1 = 372) {
    var %a = 2
    var %sends = 0
    While ($did(xdccb,308,%a)) {
      var %line = $v1
      if ($did-list(5,%line) = 1st) {
        var %nick = $did-list(6,%line)
        var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
        var %get = $hget($+(Xdccbhash-,%nick2),get)
        var %Pack = $readiniwm(%xdccgets.ini,%nick2,Pack*,%get)
        var %network = $gettok($hget($+(Xdccbhash-,%nick2),network),1,46)
        var %scid = $XDCCb-network(%network)
        var %comchan = $xdccb-changet(%scid,%nick)
        var %active-gets = 0
        if (%comchan) && (%Pack) {
          var %b = 1
          while ($get(%nick,0) >= %b) {
            if ($Get(%nick,%b).status = active) var %gets = active
            inc %b
            inc %active-gets
          }
          if (%gets != active) {
            if (%scid) $+(.TimerXDCCB-,%nick) 1 %a XDCCb-request-Pack %nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick2,Pack*,%get).sec,-4)) %scid %network %Pack
            inc %sends
          }
          var %gets = not active
        }
      }
      inc %a
    }
    if (%sends = 0) return
  }
  ;Remove Requests
  if ($1 = 373) {
    if (!$did(Xdccb,308).sel) return
    var %num = $did(xdccb,308,0).sel
    var %a = %num
    while (%a > 0) {
      var %comchan,%server
      var %line = $did(xdccb,308,$did(xdccb,308,%a).sel)
      var %stats = $did-list(5,%line)
      var %user = $did-list(6,%line)
      var %nick = $replace(%user,[,$chr(60),],$chr(62))
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %network = $did-list(8,%line)
      var %scid = $XDCCb-network(%network)
      var %file = $qt($+($scriptdir\Xdccb-queues-,%network,.txt))
      var %lines = $lines(%file)
      var %nicks = $calc($read(%file,0) -1)
      if (%scid) {
        var %comchan = $xdccb-changet(%scid,%user)
        var %server = $Xdccb-getserver(%scid)
      }
      if ($hfind($+(Xdccbhash-,%nick),Pack*,0,w) > 1) {
        var %pack = $remove($did-list(5,%line),st,nd,rd,th)   
        if (%Pack < %get) {
          dec %get 
          writeini -n $qt(%xdccgets.ini) %nick get %get
          hadd $+(Xdccbhash-,%nick) get %get
        }
        var %pack-num = $did-list(2,%line)
        xdccb-remove %nick $+(Pack,%Pack-num)
        xdccb-remove %nick $+(Date,%Pack-num)
        xdccb-remove %nick $+(Time,%Pack-num)
        if (%stats = 1st) && (%scid) scid %scid close -g* %user
        did -d XDCCb 308 $did(xdccb,308,%a).sel
        var %b = 2
        var %new-pos
        while ($did(xdccb,308,%b)) {
          var %v1 = $v1
          if ($did-list(6,%v1) = %user) {
            if ($remove($did-list(5,%v1),st,nd,rd,th) > %pack) {
              var %new-pos = $ord($calc($v1 -1))
              did -o xdccb 308 %b $puttok($did-list(1-,%v1),$+($Chr(32),%new-pos,$chr(32)),5,9)
              if (s isin $gettok(%v1,2,32)) did -kc XDCCb 308 %b 
            }
            if (%new-pos = 1st) && (%pack = 1) {
              if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
              if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) $+(.timerxdccb-remove-,%User) 1 1 scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
              $+(.timerxdccb-,%User) 1 2 XDCCb-request-Pack %user $did-list(2,%v1) %scid %network $did-list(1,%v1)
            }
          }
          var %new-pos
          inc %b
        }
      }
      else {
        if (%server) && (%comchan) && ($ini(%xdccgets.ini,DCC˙Allow,%network)) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) scid -t1 %scid /.DCCALLOW $+(-,%user)
        if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust -r $+(%user,!*@*)
        if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
        if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
        xdccb-remove %nick
        if (%stats != Finished) && (%scid) scid %scid close -g* %user
        did -d XDCCb 308 $did(xdccb,308,%a).sel
      }
      dec %a
    }
    if ($read(%file,s,%user)) {
      while ($read(%file,s,%user )) {
        write $+(-dl,$calc($readn +1)) %file
        dec %lines    
      }
      var %line = $read(%file,w,%user)
      write $+(-dl,$calc($readn +1)) %file
      write -l0 %file $calc($read(%file,0) - 1)
      if ($lines(%file) < 2) .remove $qt(%file)
    }
    elseif ($lines(%file) < 2) .remove $qt(%file)
  }
  ;Quit irrelevant 
  if ($1 = 374) {
    var %a = $scon(0)
    while ($scon(%a)) {
      var %scid = $v1
      if (%a = 0) return  
      var %network = $gettok($scid(%scid).network,1,46)
      var %b = 1
      var %loc
      while ($did(xdccb,308,%b)) {
        if ($did-list(8,$v1) = %network) var %loc = $v1 
        inc %b 
      }
      if (!%loc) && (!$XDCCb-onchan($scon(%a),#incomplete)) {
        var %message = $iif($read($scriptdir\XDCCb-quit-messages.txt,$rand(1,$lines($scriptdir\XDCCb-quit-messages.txt))),$v1,XDCC Browser v4.50 ... The Easy Way ...)
        scon -t1 %a /quit %message
        scon %a /window -c "Status Window" 
      }
      else {
        var %b = 1
        while ($XDCCb-ChangetMe(%scid,%b)) {
          var %chan = $v1
          if (%chan = #incomplete) goto end374
          var %c = 1
          while ($did(xdccb,308,%c)) {
            var %nick = $replace($did-list(6,$v1),[,$chr(60),],$chr(62))
            if ($hget($+(Xdccbhash-,%nick),Chan) = %chan) goto end374
            inc %c
          }
          var %message = $iif($read($scriptdir\XDCCb-quit-messages.txt,$rand(1,$lines($scriptdir\XDCCb-quit-messages.txt))),$v1,XDCC Browser v4.50 ... The Easy Way ...)
          scon %a /Part %chan %message
          :end374
          inc %b
        }
      }
      dec %a
    }
  }
  ;Move UP
  if ($1 = 375) {
    if ($did(xdccb,308).sel) && ($did(xdccb,308,0).sel = 1) && ($did(xdccb,308).sel != 1) {
      var %xdccgets.ini = $qt(%xdccgets.ini)
      var %line = $did(xdccb,308).seltext
      var %user = $did-list(6,%line)
      var %nick = $replace(%user,[,$chr(60),],$chr(62))
      var %pos = $remove($did-list(5,%line),st,nd,rd,th)
      if (%pos = 1) || (%pos == Finished) return
      var %Pack = $did-list(1-,%line)
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %network = $did-list(8,%line)
      var %scid = $XDCCb-network(%network)
      if (File server isin %pack) || (%pos = 1) return
      var %Pack-num = $remove($gettok(%Pack,2,9),$Chr(32))
      var %Date = $hget($+(Xdccbhash-,%nick),$+(Date,%pack-num))
      var %Time = $hget($+(Xdccbhash-,%nick),$+(Time,%pack-num))
      var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,%pos).line
      var %new-line = $readiniwm(%xdccgets.ini,%nick,Pack*,$calc(%pos -1)).line
      write $+(-dl,$calc(%line + 2)) %xdccgets.ini
      write $+(-dl,$calc(%line + 1)) %xdccgets.ini
      write $+(-dl,%line) %xdccgets.ini
      write $+(-il,%new-line) %xdccgets.ini $+(Pack,%Pack-num,=,$gettok(%Pack,5-,32))
      write $+(-il,$calc(%new-line + 1)) %xdccgets.ini $+(Date,%Pack-num,=,%Date)
      write $+(-il,$calc(%new-line + 2)) %xdccgets.ini $+(Time,%Pack-num,=,%Time)
      Xdccb-Hashnick %nick
      var %a = 2
      while ($did(xdccb,308,%a)) {
        var %v1 = $v1
        if ($did-list(6,%v1) = %user) {
          if ($did-list(5,%v1) = $ord(%pos)) did -oc xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord($calc(%pos -1)),$chr(32)),5,9)
          elseif ($did-list(5,%v1) = $ord($calc(%pos -1))) did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%pos),$chr(32)),5,9)
          var %new-pos = $ord($calc($remove($did-list(5,%v1),st,nd,rd,th) -1))
          if (%new-pos = 1st) && (%pos = 2) {
            xdccb-removeQueue %user %network 
            var %network = $did-list(8,%v1)
            var %scid = $XDCCb-network(%network)
            if (%scid) {
              var %comchan = $xdccb-changet(%scid,%user)
              var %server = $Xdccb-getserver(%scid)
              scid %scid close -g* %user
            }
            if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
            if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) $+(.timerxdccb-remove-,%User) 1 1 scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
            $+(.timerxdccb-,%User) 1 2 XDCCb-request-Pack %user $did-list(2,%v1) %scid %network $did-list(1,%v1)
          }
        }
        inc %a
      }
    }
  }
  ;Move Down
  if ($1 = 376) {
    var %xdccgets.ini = $qt(%xdccgets.ini)
    if ($did(xdccb,308).sel) && ($did(xdccb,308).lines > 2) && ($did(xdccb,308).sel != $did(xdccb,308).lines) {
      var %line = $did(xdccb,308).seltext
      var %user = $did-list(6,%line)
      var %nick = $replace(%user,[,$chr(60),],$chr(62))
      var %pos = $remove($did-list(5,%line),st,nd,rd,th)
      if (%pos == Finished) return
      var %Pack = $did-list(1-,%line)
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %network = $did-list(8,%line)
      var %scid = $XDCCb-network(%network)
      if (File server isin %pack) || (%pos = $hfind($+(Xdccbhash-,%nick),pack*,0,w)) return
      var %Pack-num = $remove($gettok(%Pack,2,9),$Chr(32))
      var %Date = $hget($+(Xdccbhash-,%nick),$+(Date,%pack-num))
      var %Time = $hget($+(Xdccbhash-,%nick),$+(Time,%pack-num))
      var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,%pos).line
      var %new-line = $calc($readiniwm(%xdccgets.ini,%nick,time*,$calc(%pos +1)).line +1)
      write $+(-il,%new-line) %xdccgets.ini $+(Pack,%Pack-num,=,$gettok(%Pack,5-,32))
      write $+(-il,$calc(%new-line + 1)) %xdccgets.ini $+(Date,%Pack-num,=,%Date)
      write $+(-il,$calc(%new-line + 2)) %xdccgets.ini $+(Time,%Pack-num,=,%Time)
      write $+(-dl,$calc(%line + 2)) %xdccgets.ini
      write $+(-dl,$calc(%line + 1)) %xdccgets.ini
      write $+(-dl,%line) %xdccgets.ini
      Xdccb-Hashnick %nick
      var %a = 2
      while ($did(xdccb,308,%a)) {
        var %v1 = $v1
        if ($did-list(6,%v1) = %user) {
          if ($did-list(5,%v1) = $ord(%pos)) did -oc xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord($calc(%pos +1)),$chr(32)),5,9)
          elseif ($did-list(5,%v1) = $ord($calc(%pos +1))) did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%pos),$chr(32)),5,9)
          var %new-pos = $ord($calc($remove($did-list(5,%v1),st,nd,rd,th) -1)) 
          if (%new-pos = 1st) && (%pos = 1) {
            xdccb-removeQueue %user %network 
            var %network = $did-list(8,%v1)
            var %scid = $XDCCb-network(%network)
            if (%scid) {
              var %comchan = $xdccb-changet(%scid,%user)
              var %server = $Xdccb-getserver(%scid)
              scid %scid close -g* %user
            }
            if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
            if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) $+(.timerxdccb-remove-,%User) 1 1 scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
            $+(.timerxdccb-,%User) 1 2 XDCCb-request-Pack %user $did-list(2,%v1) %scid %network $did-list(1,%v1)
          }
        }
        inc %a
      }
    }
  }
  ;Set 1st priority
  if ($1 = 377) {
    var %xdccgets.ini = $qt(%xdccgets.ini)
    if (!$did(xdccb,308).sel) return 
    var %pos = $remove($did-list(5,$did(xdccb,308).seltext),st,nd,rd,th)
    if (%pos = 1) return
    var %user = $did-list(6,$did(xdccb,308).seltext)
    var %nick = $replace(%user,[,$chr(60),],$chr(62))
    var %network = $hget($+(Xdccbhash-,%nick),Network)
    var %scid = $XDCCb-network(%network)
    var %get = $hget($+(Xdccbhash-,%nick),get)
    var %Pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
    if (File server isin %pack) return
    var %Pack-num = $remove($gettok(%Pack,2,9),$Chr(32))
    var %Pack = $did-list(1-,$did(xdccb,308).seltext)
    var %Date = $hget($+(Xdccbhash-,%nick),$+(Date,%pack-num))
    var %Time = $hget($+(Xdccbhash-,%nick),$+(Time,%pack-num))
    var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,%pos).line
    var %new-line = $readiniwm(%xdccgets.ini,%nick,Pack*,%get).line
    write $+(-dl,$calc(%line + 2)) %xdccgets.ini
    write $+(-dl,$calc(%line + 1)) %xdccgets.ini
    write $+(-dl,%line) %xdccgets.ini
    write $+(-il,%new-line) %xdccgets.ini $+(Pack,%Pack-num,=,$gettok(%Pack,5-,32))
    write $+(-il,$calc(%new-line + 1)) %xdccgets.ini $+(Date,%Pack-num,=,%Date)
    write $+(-il,$calc(%new-line + 2)) %xdccgets.ini $+(Time,%Pack-num,=,%Time)
    Xdccb-Hashnick %nick
    var %a = 2
    while ($did(xdccb,308,%a)) {
      var %v1 = $v1
      if ($did-list(6,%v1) = %user) {
        var %new-pos = $remove($did-list(5,%v1),st,nd,rd,th)
        if (%new-pos = %pos) did -oc xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),1st,$chr(32)),5,9)
        elseif (%new-pos < %pos) did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord($calc(%new-pos +1)),$chr(32)),5,9)
        if (%new-pos = %pos) {
          xdccb-removeQueue %user %network
          var %network = $did-list(8,%v1)
          var %scid = $XDCCb-network(%network)
          if (%scid) {
            var %comchan = $xdccb-changet(%scid,%user)
            var %server = $Xdccb-getserver(%scid)
            scid %scid close -g* %user
          }
          if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
          if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) $+(.timerxdccb-remove-,%User) 1 1 scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
          $+(.timerxdccb-,%User) 1 2 XDCCb-request-Pack %user $did-list(2,%v1) %scid %network $did-list(1,%v1)
        }
      }
      inc %a
    }
  }
  ;Clear unable to conenct status
  if ($1 = 378) {
    var %user = $did-list(6,$did(xdccb,308).seltext)
    var %nick = $replace(%user,[,$chr(60),],$chr(62))
    xdccb-remove %nick Unable
    var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
    var %chan = $hget($+(Xdccbhash-,%nick),chan)
    var %get = $hget($+(Xdccbhash-,%nick),get)
    var %Pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
    var %scid = $XDCCb-network(%network)
    if (%Pack) $+(.TimerXDCCB-,%user) 1 $calc(%a + $rand(20,60)) XDCCb-request-Pack %user $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) %scid %network %Pack
  }
  ;Clear Register stat
  if ($1 = 379) {
    var %network = $did-list(8,$did(xdccb,308).seltext)
    var %a = 1 
    while ( $hget(%a) ) {
      var %hash = $v1
      if (Xdccbhash-* iswm %hash) && ( $hget(%hash,register) ) && ( $hget(%hash,network) = %network ) {
        var %nick = $replace($remove(%hash,Xdccbhash-),$chr(60),[,$chr(62),])
        var %chan = $hget(%hash,chan)
        var %get = $hget(%hash,get)
        var %Pack = $readiniwm(%xdccgets.ini,$remove(%hash,Xdccbhash-),Pack*,%get)
        var %scid = $XDCCb-network(%network)
        hdel %hash register
        if (%Pack) $+(.TimerXDCCB-,%user) 1 $calc(%a + $rand(20,60)) XDCCb-request-Pack %user $+($chr(35),$right($readiniwm(%xdccgets.ini,$remove(%hash,Xdccbhash-),Pack*,%get).sec,-4)) %scid %network %Pack
      }
      inc %a
    }
  }
  ;Open Download
  if ($1 = 380) {
    var %line = $did(xdccb,501).seltext
    run $+(",$did-list(8,%line),$did-list(1,%line),")
  }
  ;Stop Download
  if ($1 = 381) {
    var %line = $did(xdccb,501).seltext
    var %file = $did-list(1,%line)
    var %a = 1
    while ($get(%a)) {
      if ($get(%a).file = %file) {
        Xdccb-close-get $get(%a).wid
        continue
      }
      inc %a
    }
  }
  ;Remove From List
  if ($1 = 382) {
    var %a = $did(xdccb,501,0).sel
    while (%a > 0) {
      var %line = $did(xdccb,501,%a).sel
      var %v1 = $did(xdccb,501,%line)
      var %file = $did-list(1,%v1)
      var %sec = $replace(%file,[,$chr(60),],$chr(62))
      var %icon = $gettok(%v1,3,32)
      if (%icon != 2) {
        .remini -n $qt(%Xdccb-Downloads.ini) %sec
        var %b = 1
        while ($get(%b)) {
          if ($get(%b).file = %file) {
            Xdccb-close-get $get(%b).wid
            continue
          }
          inc %b
        }
        did -d xdccb 501 %line
      }
      dec %a
    }
  }
  ;Clear Finished
  if ($1 = 383) {
    var %a = 2
    while ($did(xdccb,501,%a)) {
      var %v1 = $v1
      var %icon = $gettok(%v1,3,32)
      if (%icon = 1) {
        var %file = $did-list(1,%v1)
        var %b = 1
        while ($get(%b)) {
          if ($get(%b).file = %file) {
            Xdccb-close-get $get(%b).wid
            continue
          }
          inc %b
        }
        did -d xdccb 501 %a
        var %sec = $replace(%file,[,$chr(60),],$chr(62))
        .remini -n $qt(%Xdccb-Downloads.ini) %sec
        continue
      }
      inc %a
    }
  }
  ;Delete Download
  if ($1 = 384) {
    var %a = $did(xdccb,501,0).sel
    while (%a > 0) {
      var %line = $did(xdccb,501,%a).sel
      var %v1 = $did(xdccb,501,%line)
      var %file = $did-list(1,%v1)
      var %path = $did-list(8,%v1) 
      var %sec = $replace(%file,[,$chr(60),],$chr(62))
      var %icon = $gettok(%v1,3,32)
      var %b = 1
      while ($get(%b)) {
        if ($get(%b).file = %file) {
          Xdccb-close-get $get(%b).wid
          continue
        }
        inc %b
      }
      .remini -n $qt(%Xdccb-Downloads.ini) %sec
      did -d xdccb 501 %line
      var %file = $+(%path,%file)
      if ($isfile(%file)) .remove %file
      dec %a
    }
  }
  ;Pause request
  if ($1 = 385) {
    var %a = $did(xdccb,308,0).sel
    while (%a > 0) {
      var %line = $did(xdccb,308,$did(xdccb,308,%a).sel)
      var %stat = $did-list(4,%line)
      if ($did-list(5,%line) = 1st) && (%stat != Paused) {
        var %user = $did-list(6,%line)
        var %nick = $replace(%user,[,$chr(60),],$chr(62))
        writeini -n $qt(%xdccgets.ini) %nick Pause 1
        Xdccb-Hashnick %nick
      }
      dec %a
    }
  }
  ;Edit data
  if ($1 = 386) {
    dialog -mo Xdccb-edit Xdccb-edit
    var %line = $did(xdccb,308,1).seltext
    var %nick = $did-list(6,%line)
    var %network = $did-list(8,%line)
    did -a Xdccb-edit 21 %nick
    did -a Xdccb-edit 30 %nick $did-list(2,%line) $did-list(3,%line)
    did -a Xdccb-edit 22 $did-list(7,%line)
    did -a Xdccb-edit 23 $did-list(2,%line)
    did -a Xdccb-edit 24 $did-list(1,%line)
    did -a Xdccb-edit 25 $did-list(8,%line)
    did -a Xdccb-edit 26 $did-list(9,%line)
    var %usage = $hget($+(Xdccbhash-,$replace(%nick,[,$chr(60),],$chr(62))),Usage)
    if (!%usage) var %usage = $remove($hget(Xdccboptions,Request),$chr(44)) %nick xdcc send
    var %usage = $puttok(%usage,$remove($gettok(%usage,1,32),$chr(46)),1,32)
    did -a Xdccb-edit 27 %usage
  }
}
on *:start: {
  if ($mircdir != $scriptdir) {
    if (!$isfile($scriptdir\xdccgets.ini)) && ($isfile($mircdir\xdccgets.ini)) rename $qt($mircdir\xdccgets.ini) $qt($scriptdir\xdccgets.ini))
    if (!$isfile($scriptdir\Xdccb-Autosave.ini)) && ($isfile($mircdir\Xdccb-Autosave.ini)) rename $qt($mircdir\Xdccb-Autosave.ini) $qt($scriptdir\Xdccb-Autosave.ini)
    if (!$isfile($scriptdir\XDCCb-corrupt.ini)) && ($isfile($mircdir\XDCCb-corrupt.ini)) rename $qt($mircdir\XDCCb-corrupt.ini) $qt($scriptdir\XDCCb-corrupt.ini)
    if (!$isfile($scriptdir\Xdccb-Downloads.ini)) && ($isfile($mircdir\Xdccb-Downloads.ini)) rename $qt($mircdir\Xdccb-Downloads.ini) $qt($scriptdir\Xdccb-Downloads.ini)
    if (!$isfile($scriptdir\Xdccb-Search.txt)) && ($isfile($mircdir\Xdccb-Search.txt)) rename $qt($mircdir\Xdccb-Search.txt) $qt($scriptdir\Xdccb-Search.txt)
  }
  :error
  if ($error) {
    reseterror
    set %xdccgets.ini $mircdir\xdccgets.ini
    set %Xdccb-Autosave.ini $mircdir\Xdccb-Autosave.ini
    set %XDCCb-corrupt.ini $mircdir\XDCCb-corrupt.ini
    set %Xdccb-Downloads.ini $mircdir\Xdccb-Downloads.ini
    set %Xdccb-Search.txt $mircdir\Xdccb-Search.txt
  }
  else {
    set %xdccgets.ini $scriptdir\xdccgets.ini
    set %Xdccb-Autosave.ini $scriptdir\Xdccb-Autosave.ini
    set %XDCCb-corrupt.ini $scriptdir\XDCCb-corrupt.ini
    set %Xdccb-Downloads.ini $scriptdir\Xdccb-Downloads.ini
    set %Xdccb-Search.txt $scriptdir\Xdccb-Search.txt
  }
  if (%xdccb-exit != ok) {
    var %a  = 1
    while ($ini(%Xdccb-Downloads.ini,%a)) {
      var %sec = $v1
      var %file = $+($ini(%Xdccb-Downloads.ini,%sec,Path),$ini(%Xdccb-Downloads.ini,%sec,File))
      if ($isfile(%file)) xdccb-cutfile 100000 0 %file
      inc %a
    }
  }
  unset %xdccb-exit
  XDCCB-Setup
  Xdccb-HashUsers
  xdccb-addoption Finish-Shutdown off
  if ($hget(Xdccboptions,Auto-connect) = on) {
    var %a = 1
    while ($ini(%xdccgets.ini,%a)) {
      var %nick = $replace($v1,[,$chr(60),],$chr(62))
      var %chan = $hget($+(Xdccbhash-,%nick),chan)
      var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
      if (%network) && (!$XDCCb-network(%network)) && (!$istok(%open,%network,255)) {
        var %connect = $hget($+(Xdccbhash-,%nick),server) $hget($+(Xdccbhash-,%nick),port) -j %chan
        var %open = $addtok(%open,%network,255)
        server -m %connect
      }
      inc %a
    }
  }
  var %a = 1
  while ($findfile($mircdir,Xdccb-queues-*,%a)) {
    .remove $qt($v1)
    inc %a
  }
  if ($hget(Xdccboptions,Links) = on) && (!$portable) {
    Xdccb-Make-reg
    run regedit /s /c XdccB.reg
  }
  if ($hget(Xdccboptions,Autosave) = on) .timerXDCCb-autosave -i 0 $calc($hget(Xdccboptions,Autosave-time) * 3600) XDCCb-autosave
  if ($hget(Xdccboptions,Load-lists) = on) {
    if ($readini(%Xdccb-Autosave.ini,@All,Mode) = on) && ($readini(%Xdccb-Autosave.ini,@All,File)) .timerxdccb-autoload 1 10 xdccb-loadlist $readini(%Xdccb-Autosave.ini,@All,File)
    else {
      window -h @xdccb-autoload
      var %a = 1
      var %num = 0
      while ($ini(%Xdccb-Autosave.ini,%a)) {
        var %topic = $v1
        var %b = 1
        while ($ini(%Xdccb-Autosave.ini,%a,%b)) {
          var %file = $+(",$readini(%Xdccb-Autosave.ini,%topic,$v1),")
          if (!$fline(@xdccb-autoload,%file,1)) {
            aline -n @xdccb-autoload %file
            $+(.timerxdccb-autoload,%num) 1 $calc(%num * 10) xdccb-loadlist %file
            inc %num
          }
          inc %b
        }
        inc %a
      }
      close -@ @xdccb-autoload
    }
  }
  if ($hget(Xdccboptions,startup) = on) xdccb
  while ($finddir($getdir,cps-test*,1)) {
    var %dir = $v1
    var %b = $findfile(%dir,*.*,0,.remove $qt($1-))
    .rmdir $qt(%dir)
  }
  if ($gettok($readini(mirc.ini,options,n7),19,44) = 0) return
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    .dcc trust -r $+($replace(%nick,$chr(60),[,$chr(62),]),!*@*) 
    inc %a 
  }
  var %a = 1
  while ($ini(%Xdccb-Downloads.ini,%a)) {
    var %sec = $v1
    var %file = $+($readini(%Xdccb-Downloads.ini,%sec,Path),$readini(%Xdccb-Downloads.ini,%sec,File))
    if ($isfile(%file)) && ($readini(%Xdccb-Downloads.ini,%sec,Rcvd) < $readini(%Xdccb-Downloads.ini,%sec,Size)) writeini -n $qt(%Xdccb-Downloads.ini) %sec Rcvd $file(%file).size
    inc %a
  }
  if ($hget(Xdccboptions,minimize) = on) showmirc -t
}
on *:sockclose:xdccb: {
  if (!$dialog(xdccb)) return
  var %site = $hget(Xdccboptions,site)
  if (xdccreport isin %site) {
    parsexdccreport
    did -a xdccb 710 delta 1
  }
  elseif (xdccing isin %site) {
    parsexdccing
    did -a xdccb 710 delta 1
  }
  elseif (xdccfinder isin %site) {
    parsexdccfinder
    did -a xdccb 710 delta 25
  }
  elseif (searchxdcc isin %site) {
    parsesearchxdcc
    did -a xdccb 710 delta 50
  }
  var %place = $gettok($did(xdccb,710),1,32)
  var %num = $gettok($did(xdccb,710),3,32)
  if (%place < %num) {
    did -e xdccb 209
  }
  else did -b xdccb 209
  did -ra xdccb 211,711 Done
  var %num = $calc($did(xdccb,207).lines -1)
  did -ra xdccb 205 $iif(%num = 1,%num Result,%num Results)
  bunset &xdccbparse
}
on *:sockopen:xdccb: {
  if ($sockerr > 0) {
    if ($sock($sockname).wserr = 10060) {
      did -ra xdccb 211,711 Timed Out
    }
    else did -ra xdccb 211,711 Can't Connect
    did -ra xdccb 710 0 0 1
    return
  }
  if ($dialog(xdccb)) did -ra xdccb 211,711 Connecting...
  else {
    sockclose xdccb
    return
  } 
  sockwrite -n $sockname GET $hget(Xdccboptions,search) HTTP/1.1 
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n
  sockwrite -n $sockname User-Agent: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6 (.NET CLR 3.5.30729)\r\n
  sockwrite -n $sockname Host: $hget(Xdccboptions,site)
  sockwrite -n $sockname $crlf
  remini -n $qt(%xdccgets.ini) $+($chr(38),Options,$chr(38)) sock-line
  .remove $qt($scriptdir\search.tmp)
}
on *:sockread:xdccb:{
  if ($sockerr > 0) return 
  var %file = $qt($scriptdir\search.tmp)
  :sockread
  sockread &read
  if (!$sockbr) { return }
  bwrite %file -1 &read
  goto sockread
  :error
  reseterror
}
on ^*:text:*:#,?: {
  if (!$network) return
  var %listing = $hget(Xdccboptions,Listing)
  if ($gettok(%listing,1,32) = 1) { 
    if ($chr(35) isin $1-2) {
      if ($xPack($1-)) {
        var %Pack = $puttok($v1,$replace($gettok($v1,1,9),$chr(32),$chr(160)),1,9)
        if ($chr(43) = $left($gettok(%pack,1,32),1)) var %pack = $replace($gettok(%pack,1,32),$chr(43),$chr(45)) $gettok(%pack,2-,32)
        if ($comchan($nick,1)) addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %Pack
        if ($hget(Xdccboptions,Hide-Packs) = on) haltdef
        return
      }
    }  
    if ($Xdccdata($1-)) return  
    if ((/msg isin $1-) || (/ctcp isin $1-)) && ($XUsage($nick,$1-) && ($hget(Xdccboptions,Hide-Packs) = on)) haltdef
  }
  if ($gettok(%listing,2,32) = 1) && (Trigger isin $1-) {
    if ($fpack($1-)) {
      if ($hget(Xdccboptions,Hide-Fserv) = on) haltdef
      else return
    }
  }
  if ($gettok(%listing,3,32) = 1) && (FTP isin $1-) && ($ftppack($1-)) return
  if ($chan = #incomplete) {
    var %line = $strip($1-)
    if (Request (*) added by $+([,$me,]) + * iswm %line) {
      var %file = $right($gettok($gettok(%line,2,43),1,47),-2)
      var %num = $gettok($gettok(%line,1,41),2,40)
      if (!$Readini(%XDCCb-corrupt.ini,%file,$network)) writeini -n $qt(%XDCCb-corrupt.ini) %file $gettok($network,1,46) %num
    }
    elseif ([request added.] $me * iswm %line) {
      var %file = $gettok(%line,3,176)
      var %num = $gettok(%line,2,176)
      if (!$Readini(%XDCCb-corrupt.ini,%file,$network)) writeini -n $qt(%XDCCb-corrupt.ini) %file $gettok($network,1,46) %num
    }
    elseif (!close * iswm %line) && ($gettok(%line,2,32) isnum) {
      var %num = $gettok(%line,2,32)
      var %a = 1
      while ($ini(%XDCCb-corrupt.ini,%a)) {
        var %file = $v1
        if ($readini(%XDCCb-corrupt.ini,%file,$gettok($network,1,46)) = %num) {
          remini -n $qt(%XDCCb-corrupt.ini) %file $gettok($network,1,46)
          return
        }
        inc %a
      }
    }
  }
}
on *:getfail:*: {
  var %nick = $replace($nick,[,$chr(60),],$chr(62))
  var %get = $hget($+(Xdccbhash-,%nick),get)
  var %Pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
  var %got = $calc($get(-1).rcvd - $get(-1).resume)
  var %unable = $hget($+(Xdccbhash-,%nick),Unable)
  var %file = $filename
  var %check
  if (%got > 0) {
    if (%unable) xdccb-remove %nick Unable
    xdccb-cutfile %got -1 %file
  }
  else {
    .timer 1 1 Xdccb-close-get $get(-1).wid
    if ($hget($+(Xdccbhash-,%nick))) {
      writeini -n $qt(%xdccgets.ini) %nick Unable $calc(%unable +1) 
      hadd $+(Xdccbhash-,%nick) Unable $calc(%unable +1)
    } 
  }
  var %sec = $replace($nopath(%file),[,$chr(60),],$chr(62))
  if ($ini(%Xdccb-Downloads.ini,%sec)) && ($get(-1).path = $readini(%Xdccb-Downloads.ini,%sec,path)) writeini -n $qt(%Xdccb-Downloads.ini) %sec Rcvd $iif($file(%file).size,$v1,Delete)
  if ($hget(Xdccboptions,XDCCResume) = on) {
    if (%unable >= 3) {
      if ($timer($+(XDCCB-,$nick))) $+(.TimerXDCCB-,$nick) off 
      return
    }
    if ($ini(%xdccgets.ini,%nick) > 0) && ($comchan($nick,0) > 0) && (%Pack) {
      var %a = 1
      while ($get(%a)) {
        if ($get(%a).status = Active) && ($get(%a).file = %file) {
          $+(.TimerXDCCB-,$nick) 1 $hget(Xdccboptions,Getfail-Timer) XDCCb-request-Pack $nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) $cid $gettok($network,1,46) %Pack
          return
        }
        inc %a
      }
      $+(.TimerXDCCB-,$nick) 1 $hget(Xdccboptions,Getfail-Timer) XDCCb-request-Pack $nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) $cid $gettok($network,1,46) %Pack
    }
  }
}
on *:filercvd:*: {
  var %nickname = $nick
  if (!%nickname) return
  if ($ini(%XDCCb-corrupt.ini,$nopath($filename))) {
    remini -n $qt(%XDCCb-corrupt.ini) $nopath($filename)
    var %file = $ini(%XDCCb-corrupt.ini,1)
    if (%file) && (!$Readini(%XDCCb-corrupt.ini,%file,$network)) .timer 1 $calc($rand(20,60)) msg #incomplete !request %file / $Readini(%XDCCb-corrupt.ini,%file,desc)
    goto move
  }
  var %sec = $replace($nopath($filename),[,$chr(60),],$chr(62))
  if ($ini(%Xdccb-Downloads.ini,%sec)) && ($file($filename).size) writeini -n $qt(%Xdccb-Downloads.ini) %sec Rcvd $file($filename).size
  var %nickname2 = $replace(%nickname,[,$chr(60),],$chr(62))
  var %get = $hget($+(Xdccbhash-,%nickname2),get)
  var %pack = $readiniwm(%xdccgets.ini,%nickname2,Pack*,%get)
  var %pack-noext = $replace($gettok(%pack,1,9),.,$chr(32),$chr(160),$chr(32)) $chr(9) $Xdccb-Calcsize($remove($gettok(%pack,3,9),b,$chr(32)))
  var %ext = $gettok($gettok(%pack-noext,1,9),-1,32)
  if (%ext = rar) || (%ext = tar) || (%ext = zip) || (%ext = mp3) || (%ext = avi) || (%ext = mpg) || (%ext = mpeg) var %pack-noext = $deltok($gettok(%pack-noext,1,9),-1,32) $chr(9) $gettok(%pack-noext,2,9)
  var %pack-noext = $remove(%pack-noext,$chr(32))
  var %pack2 = $gettok(%pack,1,9) $chr(9) $remove($gettok(%pack,3,9),b,$chr(32))
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    if (%nick != $+($chr(38),Options,$chr(38))) && (%nick != DCC˙Allow) {
      var %user = $replace(%nick,$chr(60),[,$chr(62),])
      var %get = $hget($+(Xdccbhash-,%nick),get)
      if (%nick = %nickname2) {
        var %new-pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
        var %new-pack = $gettok(%new-pack,1,9) $chr(9) $remove($gettok(%new-pack,3,9),b,$chr(32))
        if (%new-pack = %pack2) {
          var %network = $hget($+(Xdccbhash-,%nick),network)
          var %scid = $XDCCb-network(%network)
          if ($timer($+(Xdccb-,%user))) $+(.timerXdccb-,%user) off
          if (%scid) {
            var %comchan = $xdccb-changet(%scid,%user)
            if (%comchan) && ($ini(%xdccgets.ini,DCC˙Allow,%network)) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) scid -t1 %scid /.DCCALLOW $+(-,%user)
            if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust -r $+(%user,!*@*)
            var %usage = $iif($ini(%xdccgets.ini,%nick,usage),$gettok($hget($+(Xdccbhash-,%nick),usage),1,32),$hget(Xdccboptions,Request))
          }
          if ($hget(Xdccboptions,Remove) = on) {
            var %packnum = $right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)
            xdccb-remove %Nick $+(Pack,%packnum)
            xdccb-remove %Nick $+(Time,%packnum)
            xdccb-remove %Nick $+(Date,%packnum)
            if ($dialog(xdccb)) {
              var %c = 2
              while ($did(xdccb,308,%c)) {
                var %v1 = $v1
                if ($did-list(6,%v1) = %user) {
                  if ($did-list(5,%v1) = 1st) {
                    did -d XDCCb 308 %c
                    dec %c
                  }
                  elseif ($remove($did-list(5,%v1),st,nd,rd,th) > 1) {
                    var %check = $calc($v1 -1)
                    did -o xdccb 308 %c $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
                  }
                }
                inc %c
              }
            }
            if ($hfind($+(Xdccbhash-,%nick),Pack*,0,w) = 0) {
              xdccb-remove %nick
              Xdccb-Shutdown-quit %network %scid %user
              dec %a
              goto end
            }
          }
          elseif (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) {
            inc %get
            writeini -n $qt(%xdccgets.ini) %nick get %get
            hadd $+(Xdccbhash-,%nick) get %get
          }
          var %new-pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
          if (%comchan) && (%new-pack) && (%scid) scid -t1 %scid $+(/.TimerXdccb-,%user) 1 $hget(Xdccboptions,Getfail-Timer) XDCCb-request-Pack %user $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) %scid %network %new-pack
          goto end
        }
      }
      elseif ($gettok(%pack,1-2,32) != Requesting pack) {
        var %b = %get 
        while ($hget($+(Xdccbhash-,%nick),$hfind($+(Xdccbhash-,%nick),Pack*,%b,w))) {
          var %new-pack = $v1
          var %new-pack = $replace($gettok(%new-pack,1,9),.,$chr(32),$chr(160),$chr(32)) $chr(9) $Xdccb-Calcsize($remove($gettok(%new-pack,3,9),b,$chr(32)))
          var %ext = $gettok($gettok(%new-pack,1,9),-1,32)
          if (%ext = rar) || (%ext = tar) || (%ext = zip) || (%ext = mp3) || (%ext = avi) || (%ext = mpg) || (%ext = mpeg) var %new-pack = $deltok($gettok(%new-pack,1,9),-1,32) $chr(9) $gettok(%new-pack,2,9)
          var %new-pack = $remove(%new-pack,$chr(32))
          if (%new-pack = %pack-noext) {
            var %pos = %get
            var %Pack-num = $remove($gettok(%Pack,2,9),$Chr(32))
            var %Date = $hget($+(Xdccbhash-,%nick),$+(Date,%pack-num))
            var %Time = $hget($+(Xdccbhash-,%nick),$+(Time,%pack-num))
            var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,%b).line
            var %new-line = $readiniwm(%xdccgets.ini,%nick,Pack*,1).line
            if ($hget(Xdccboptions,Remove) = off) {
              write $+(-il,%new-line) $qt(%xdccgets.ini) $+(Pack,%Pack-num,=,%Pack)
              write $+(-il,$calc(%new-line + 1)) $qt(%xdccgets.ini) $+(Date,%Pack-num,=,%Date)
              write $+(-il,$calc(%new-line + 2)) $qt(%xdccgets.ini) $+(Time,%Pack-num,=,%Time)
              Xdccb-Hashnick %nick
              inc %get
              writeini -n $qt(%xdccgets.ini) %nick get %get
              hadd $+(Xdccbhash-,%nick) get %get
            }
            else {
              if ($dialog(XDCCb)) {
                var %c = 2
                while ($did(xdccb,308,%c)) {
                  var %v1 = $v1
                  if ($did-list(6,%v1) = %user) {
                    if ($did-list(5,%v1) = 1st) {
                      did -d XDCCb 308 %c
                      dec %c
                    }
                    elseif ($remove($did-list(5,%v1),st,nd,rd,th) > 1) {
                      var %check = $calc($v1 -1)
                      did -o xdccb 308 %c $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
                    }
                  }
                  inc %c
                }
              }
              xdccb-remove %Nick $+(Pack,%packnum)
              xdccb-remove %Nick $+(Time,%packnum)
              xdccb-remove %Nick $+(Date,%packnum)
              Xdccb-Hashnick %nick
              if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
              if ($hfind($+(Xdccbhash-,%nick),Pack*,0,w) = 0) {
                var %network = $hget($+(Xdccbhash-,%nick),network)   
                var %scid = $XDCCb-network(%network)
                xdccb-remove %Nick
                Xdccb-Shutdown-quit %network %scid
                dec %a
                goto end
              }
              else {
                var %user = $replace(%nick,$chr(60),[,$chr(62),])
                var %network = $hget($+(Xdccbhash-,%nick),network)
                var %scid = $XDCCb-network(%network)
                if (%scid) {
                  var %comchan = $xdccb-changet(%scid,%user)
                  if (%comchan) && ($ini(%xdccgets.ini,DCC˙Allow,%network)) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) scid -t1 %scid /.DCCALLOW $+(-,%user)
                  if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust -r $+(%user,!*@*)
                  var %usage = $iif($ini(%xdccgets.ini,%nick,usage),$gettok($hget($+(Xdccbhash-,%nick),usage),1,32),$hget(Xdccboptions,Request))
                }
                var %new-pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
                if (%comchan) && (%new-pack) && (%scid) scid -t1 %scid $+(/.TimerXdccb-,%user) 1 $hget(Xdccboptions,Getfail-Timer) XDCCb-request-Pack %user $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) %scid %network %new-pack
              } 
              break
            }
          }
          inc %b
        }
      }
    }
    :end
    var %server,%comchan,%scid,%new-pack
    inc %a
  }
  : move
  if ($hget(Xdccboptions,Move) = on) {
    var %finishdir = $hget(Xdccboptions,Finish)
    if (!$isdir(%finishdir)) .mkdir $qt(%finishdir)
    if (!$isfile($+(%finishdir,$nopath($filename)))) && ($isfile($filename)) {
      .rename $qt($filename) $+(",%finishdir,$nopath($filename),")
      if (%sec) writeini -n $qt(%Xdccb-Downloads.ini) %sec Path %finishdir
    }
  }
}

;Dialogs

;Browser Dialog

dialog XDCCb {
  Title "XDCC Browser v4.50"
  Size -1 -1 380 200
  Option dbu

  Icon $scriptdirxdccb-icons.icl,48

  Tab "&Browser", 100, -20 -14 0 0
  Tab "&Search", 200
  Tab "&Requests", 300
  Tab "&Downloads", 500
  Tab "&Options", 600


  List 4, 7 5 218 10
  text "Text label", 700, 266 6 105 10
  text "Done" , 701, 210 7 50 10, right
  text "Text label", 710, 266 6 105 10
  text "Done" , 711, 210 7 50 10, right
  text "Text label", 720, 266 6 105 10
  text "Done" , 721, 210 7 50 10, right
  text "Text label", 730, 266 6 105 10
  text "Done" , 731, 210 7 50 10, right

  Button "Close", 1, 335 180 42 13, ok, default
  Button "Cancel", 2, -1 -1 0 0, cancel
  Button "Minimizer", 3, 1 1 1 1,  hide

  ;Browser 

  Button "Remove selected Item", 31, 138 140 70 12, Tab 100
  Button "Add Pack/s without requesting", 32, 290 140 80 12, Tab 100
  Button "Get Network's Channel List", 33, 255 160 80 12, Tab 100
  Button "Remove irrelevant packs", 34, 214 140 70 12, Tab 100

  List 27, 10 32 120 160, size sort , Tab 100
  List 28, 137 25 229 110, size extsel , Tab 100

  Box "Nick List", 35, 7 22 126 173, Tab 100

  Text "Total No. of Serving Nicks:",41,137 158 80 8, Tab 100
  Edit "", 42,207 157 30 11, read center , Tab 100
  Text "Total No. of Packets:", 43,137 175 55 8, Tab 100
  Edit "", 44,207 174 30 11, read center , Tab 100

  ;Search 

  Button ,222,-1 -1 -1 -1, Tab 200
  Button ,233,6 34 3 4, Tab 200
  List 202, 149 31 35 11, Tab 200
  Combo 206, 13 31 134 11, vsbar edit drop sort autohs, Tab 200
  List 207, 11 53 360 125, size sort extsel , Tab 200

  Combo 213, 185 31 35 90, drop, Tab 200
  Edit "",214, 223 31 15 10, autohs limit 3 , Tab 200
  Combo 215, 240 31 25 90, drop, Tab 200

  Box "Search", 204, 9 20 360 6, Tab 200
  Box "Results", 205, 9 45 360 6, Tab 200

  Text "Search in:", 208,275 33 25 8, Tab 200
  Combo 203, 305 31 65 90, size, Tab 200

  ;icon 209, 180 180 100 18, $scriptdirxdccb-icons.icl, 21, Tab 200
  List 209, 150 180 60 18, Tab 200


  Edit "Done", 211, 120 180 50 11, read , Tab 200
  Text "Listing status:", 212,80 181 35 8, Tab 200

  ;Request

  Button "Remove selected Item", 303, 170 180 60 13, Tab 300
  Button "Join selected", 304, 13 180 40 13 , Tab 300
  Button "Request all", 407, 60 180 40 13, Tab 300
  Button "Join all", 408, 107 180 40 13, Tab 300

  List 308, 11 25 360 110, size extsel , Tab 300

  ;Downloads

  List 501, 11 25 360 110, size extsel , Tab 500

  ;Adds
  list 901, 11 150 360 38


  ; Options 

  Check "Move finished requests to:", 397, 20 20 73 8, Tab 600
  Edit "", 398, 93 19 213 10, read, Tab 600
  Button "Change..", 399, 307 19 33 10, Tab 600

  Box "Packet Options:", 370, 20 33 100 143, Tab 600
  Box "Default Browser Options:", 371, 140 33 100 143, Tab 600
  Box "Other Options:", 372, 250 33 100 143, Tab 600

  Check "Auto get on join", 350, 25 45 60 9 , Tab 600
  Check "Auto Pack Resume", 351, 25 57 60 9 , Tab 600
  Check "Auto delete Packs on disconnect", 352, 25 81 87 9 , Tab 600
  Check "Auto delete Packs on part/quit", 383, 25 69 85 9 , Tab 600
  Check "Auto Request list from bots", 353, 25 93 85 9 , Tab 600
  Check "Show channel's pack list", 386, 25 105 85 9 , Tab 600
  Check "Get only from 'Trusted' users", 387,25 117 85 9 , Tab 600
  Check "On finish remove from Requests", 392,25 129 90 9 , Tab 600
  Check "Quit Network/Channel on finish", 394,25 141 85 9 , Tab 600
  Check "Shutdown PC when finished", 395,25 153 85 9 , Tab 600
  Check "Connect via SSL", 403,25 165 85 9 , Tab 600

  Check "Put on Taskbar", 355, 150 45 60 9 , Tab 600
  Check "Always On Top", 354, 150 57 60 9 , Tab 600
  Check "Show Request in Status window", 360, 150 69 85 9 , Tab 600

  Box "Default Request type:", 373, 145 80 65 30, Tab 600
  Radio "/msg", 358, 155 87 40 9 , group, Tab 600
  Radio "/ctcp", 359, 155 99 40 9 , Tab 600

  Box "Listing type:", 374, 145 110 65 40, Tab 600
  Check "XDCC Packs", 388, 155 120 40 9 , Tab 600
  Check "File Servers", 389,155 130 40 9 , Tab 600
  Check "FTP Sites", 390,155 140 40 9 , Tab 600

  Text "'Request again' Timer:", 361, 145 153 100 8, Tab 600
  Edit "", 362, 198 152 20 10, center , Tab 600
  Text "Secs",363, 220 153 15 8, tab 600
  Text "'Get fail' Timer:", 364, 145 166 100 8, Tab 600
  Edit "", 365, 198 165 20 10, center , Tab 600
  Text "Secs",366, 220 166 15 8, Tab 600

  Check "On start connect to all networks", 380, 260 45 87 9 , Tab 600 
  Check "Auto join channels on connect", 369, 260 57 85 9 , Tab 600
  Check "Hide Packs in channel window", 382, 260 69 85 9 , Tab 600
  Check "Hide File Server triggers", 391,260 81 85 9 , Tab 600
  Check "Avoid long network sessions", 384,260 93 85 9 , Tab 600
  Check "Script controls IRC:// Links", 385,260 105 85 9 , Tab 600
  Check "Autosave packet lists", 393,260 117 85 9 , Tab 600
  Check "Enable File Server Browser", 396,260 129 85 9 , Tab 600
  Check "Enable status window", 402,260 141 85 9 , Tab 600
  Check "Load XDCCb on startup", 400,260 153 85 9 , Tab 600
  Check "mIRC always minimized", 401,260 164 85 9 , Tab 600

  Button "Reset", 5, 155 180 42 13, Tab 600

  ;Menu 

  Menu "&Xdcc List", 810
  Item "&Save", 16, 810
  Item "&Load", 17, 810
  Item "&Remove List File", 18, 810
  Item Break, 19, 810
  Item "List C&ontrol", 21, 810
  Item Break, 22, 810
  Item "&Clear list", 20, 810

  Menu "&Help", 820
  Item "Help", 11, 820
  Item Break, 15, 820
  Item "&About...", 12, 820
  Item Break, 14, 820
  Item "&Donate",13, 820
}
on *:dialog:XDCCb:close:*: {
  Xdccb-Stopsocket
  window -c @tmpXdccb28
  window -c @tmpXdccb202
  .timerXdccb-update off
  if ($dialog(Xdccb-edit)) dialog -x Xdccb-edit
  unset %xdccb-list
  dll -u $qt($scriptdir\UserInput.dll) 
  if ($version >= 6.3) && ($appstate == tray) && ($hget(Xdccboptions,Stats) == on) && (!$window($+(@XDCCB,$chr(160),Stats))) {
    var %a = 1 
    var %check = 0
    while ($dialog(%a)) {
      if ($dialog(%a).active) var %check = stop
      inc %a
    }
    if (%check != stop) {
      window -w0pdok0 +L $+(@XDCCB,$chr(160),Stats) $window(-1).w $window(-1).h $width(Connected: 12days 12hours 12mins,tahoma,12) $calc($height(1,tahoma,12)*7)
      drawfill -r $+(@XDCCB,$chr(160),Stats) $RGB(186,229,242) $RGB(186,229,242) 1 1
      Xdccb-statswindow
      .timerxdccb-statswindow 0 5 Xdccb-statswindow
    }
  }
}
on *:dialog:XDCCb:init:*: {
  mdx SetMircVersion $version
  mdx MarkDialog XDCCb
  var %iconfile = $findfile($scriptdir,Xdccb-Icons.icl,1)

  mdx SetDialog Processbar style title
  ctl_gen SetControlMDX 700,710,720,730 ProgressBar 
  did -a xdccb 700,710,720,730 0 0 1
  did -a xdccb 710,720,730 1
  did -h xdccb 710,711,720,721,730,731,901

  mdx SetColor $dname textbg $rgb(16,252,252)

  dialogs SetControlMDX 3 positioner size minbox maxbox
  ; dialogs SetControlMDX 901 window
  ;  window -p @test
  ; did -a xdccb 901 grab $window(@test).hwnd @test
  ;  var %Adds = $dll(C:\Program Files\mIRC\nHTMLn_2.95.dll,find,ThisIsMyLameBox) 
  ;  dll $qt(C:\Program Files\mIRC\nHTMLn_2.95.dll) attach $dll(C:\Program Files\mIRC\nHTMLn_2.95.dll,item,$dialog($dname).hwnd id:901) 
  ;  noop $dll(C:\Program Files\mIRC\nHTMLn_2.95.dll,navigate,www.mirc.com)
  ; noop $dllcall(C:\Program Files\mIRC\nHTMLn_2.95.dll,xdccb-handler,handler,xdccb-handler)


  Mdx SetDialog XDCCb coords * * $hget(Xdccboptions,XDCCDialog-Size)
  dialog -r XDCCb
  Xdccb-resize $dialog(xdccb).cw $dialog(xdccb).ch
  views SetControlMDX XDCCb 27 TreeView autosort haslines linesatroot hasbuttons showsel infotip itemdroptarget insertdroptarget
  Xdccb-Seticon xdccb 27

  mdx SetBorderStyle xdccb 4,202
  bars SetControlMDX $dname 4 ToolBar flat nodivider list
  did -i xdccb 4 1 bmpsize 16 16
  did -i $dname 4 1 setimage +nh icon small 18, $+ %iconfile
  did -i $dname 4 1 setimage +nh icon small 5, $+ %iconfile
  did -i $dname 4 1 setimage +nh icon small 30, $+ %iconfile
  did -i $dname 4 1 setimage +nh icon small 20, $+ %iconfile
  did -i $dname 4 1 setimage +nh icon small 29, $+ %iconfile
  didtok -a $dname 4 59 +cgxW 80 1 Browser;+cgW 80 2 Search;+cgW 80 3 Requests;+cgW 80 5 Downloads;+cgW 80 4 Options

  views SetControlMDX XDCCb 28 ListView report grid showsel infotip
  did -i XDCCb 28 1 headerdims $hget(Xdccboptions,Dims28) 
  did -i XDCCb 28 1 headertext Pack $chr(9) $chr(35) $chr(9) Size $chr(9) Gets $chr(9) Queue $chr(9) Rec. CPS

  views SetControlMDX XDCCb 207 ListView report grid showsel infotip
  did -i XDCCb 207 1 headerdims $hget(Xdccboptions,Dims207)
  did -i XDCCb 207 1 headertext Pack $chr(9) $chr(35) $chr(9) Size $chr(9) Gets $chr(9) Queue $chr(9) Rec. CPS $chr(9) Nick $chr(9) Channel $chr(9) Network $chr(9) Server

  views SetControlMDX XDCCb 308 ListView showsel report grid infotip
  did -i XDCCb 308 1 headerdims $hget(Xdccboptions,Dims308)
  did -i XDCCb 308 1 headertext Pack $chr(9) $chr(35) $chr(9) Size $chr(9) Status $chr(9) Order $chr(9) Nick $chr(9) Channel $chr(9) Network $chr(9) Server 
  did -i XDCCb 308 1 seticon normal 0 31, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 32, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 37, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 38, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 39, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 40, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 26, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 42, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 43, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 44, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 34, $+ %iconfile
  did -i XDCCb 308 1 seticon normal 0 45, $+ %iconfile

  views SetControlMDX XDCCb 501 ListView showsel report grid infotip
  did -i XDCCb 501 1 headerdims $hget(Xdccboptions,Dims501) 
  did -i XDCCb 501 1 headertext File Name $chr(9) Status $chr(9) Time Left $chr(9) Speed $chr(9) Size $chr(9) received $chr(9) Nick $chr(9) Path
  did -i XDCCb 501 1 seticon normal 0 31, $+ %iconfile
  did -i XDCCb 501 1 seticon normal 0 32, $+ %iconfile
  did -i XDCCb 501 1 seticon normal 0 33, $+ %iconfile
  did -i XDCCb 501 1 seticon normal 0 34, $+ %iconfile

  views SetControlMDX XDCCb 203 ComboBoxEx drop
  did -i XDCCb 203 1 iconsize small
  did -i XDCCb 203 1 seticon 0 0, $+ %iconfile
  did -i XDCCb 203 1 seticon 0 2, $+ %iconfile

  did -a xdccb 203 1 1 0 0 XDCC Finder
  did -a xdccb 203 1 1 0 0 XDCC Report 
  did -a xdccb 203 1 1 0 0 XDCCing
  did -a xdccb 203 1 1 0 0 SearchXDCC
  did -a xdccb 203 2 2 0 0 Local List
  did -a xdccb 203 2 2 0 0 Search Results

  var %Browser2 = $regread(HKLM\SOFTWARE\Clients\StartMenuInternet\)
  var %file = $regread($+(HKLM\SOFTWARE\Clients\StartMenuInternet\,%browser2,\DefaultIcon\))
  var %Browser = $regread($+(HKLM\SOFTWARE\Clients\StartMenuInternet\,%browser2,\))
  var %a = 1
  while (!%Browser) {
    if (%a = 5) {
      var %browser = $regread(HKCR\htmlfile\shell\)
      var %file = $+($gettok($regread($+(HKCR\htmlfile\shell\,%browser,\command\)),1,34),$chr(44),0)
      if ($regread($+(HKCR\htmlfile\shell\,%browser2,\))) var %browser = $v1
      break
    }
    var %browser2 = $regread($+(HKLM\SOFTWARE\Clients\StartMenuInternet\,%browser2,\LocalizedString))
    var %file =  $regread($+(HKLM\SOFTWARE\Clients\StartMenuInternet\,%browser2,\DefaultIcon\))
    var %browser = $regread($+(HKLM\SOFTWARE\Clients\StartMenuInternet\,%browser2,\))
    inc %a
  }   
  if ($+(%,*,%) iswm $gettok(%file,1,92) ) var %file = $+($GetEnvStr($gettok($v2,1,37)),\,$gettok(%file,2-,92))
  if (%browser) did -i xdccb 203 1 seticon $+($gettok(%file,2,44),$chr(44),$shortfn($gettok(%file,1,44)))

  mdx SetBorderStyle 1,2,31,32,33,34,209,303,304,407,408

  if ($numtok($hget(Xdccboptions,sort),32) != 6) xdccb-addoption sort 1 u 1 u 1 u
  .timer -m 1 1 XDCCb27
  window -h @tmpXdccb28
  window -h @tmpXdccb202
  xdccr8 

  did -f XDCCb 27
  xdccb-Loadoptions

  if (%browser) did -a xdccb 203 3 3 0 0 %browser
  did -c xdccb 203 $hget(Xdccboptions,Searchselect)

  did -a xdccb 213 Min Size
  did -a xdccb 213 Max Size
  did -a xdccb 215 Kb
  did -a xdccb 215 Mb
  did -a xdccb 215 Gb
  did -c xdccb 213 $gettok($hget(Xdccboptions,Search-Size),1,44)
  did -a xdccb 214 $gettok($hget(Xdccboptions,Search-Size),2,44)
  did -c xdccb 215 $gettok($hget(Xdccboptions,Search-Size),3,44)

  bars SetControlMDX $dname 202  ToolBar nodivider list
  did -i xdccb 202 1 bmpsize 16 16
  did -i $dname 202 1 setimage +nh icon small 19, $+ %iconfile
  did -a $dname 202 +gW 70 1 Search
  bars SetControlMDX $dname 209  ToolBar nodivider list
  did -i xdccb 209 1 bmpsize 26 26
  did -i $dname 209 1 setimage +nh icon large 21, $+ %iconfile
  did -a $dname 209 +gW 110 1 More Results
  did -b $dname 209

  xdccb-downloads-load
  .timerXdccb-update -i 0 5 Xdccb-update
  Xdccb-update
  upackno
  dialog -t xdccb XDCC Browser v4.50 ... Active network: $iif($network,$gettok($network,1,46),None)
  if ($isfile(%xdccb-search.txt)) loadbuf 10 -o xdccb 206 $qt(%Xdccb-Search.txt)
  .timer -m 1 1 xdccb-Userinput
}
on *:dialog:XDCCb:mouse:*: {
  if ($did = 27) || ($did = 28) || ($did = 207) || ($did = 308) || ($did = 501) set %xdccb-list $did 
}

;Browser Tab

on *:dialog:XDCCb:sclick:1: {
  if ($did(362).edited = $true) && ($did(362) isnum) xdccb-addoption Request-Timer $did(362)
  if ($did(365).edited = $true) && ($did(365) isnum) xdccb-addoption Getfail-Timer $did(365)
  xdccb-addoption XDCCDialog-size $dialog(xdccb).cw $dialog(xdccb).ch 
  Xdccb-Savedims
}
on *:dialog:XDCCb:sclick:3: {
  var %action = $did(3)
  if ($gettok(%action,1,32) = maximize) || ($gettok(%action,1,32) = restore) Xdccb-resize $dialog(xdccb).cw $dialog(xdccb).ch 
  if ($gettok(%action,1,32) = Sizing) { 
    var %new-width = $gettok(%action,9,32)
    var %new-hight = $gettok(%action,10,32)
    if (%new-hight < 400) || (%new-width < 760) {
      var %new-width = $iif(%new-width < 760,$v2,$v1)
      var %new-hight = $iif(%new-hight < 400,$v2,$v1)
      did -a xdccb 3 setSize c %new-width %new-hight
    }
  }
  if ($gettok(%action,1,32) = exitSizeMove) Xdccb-resize $dialog(xdccb).cw $dialog(xdccb).ch
}
on *:dialog:XDCCb:sclick:4: {
  var %sel = $did(4).sel
  unset %xdccb-list
  if (%sel = 2) {
    did -c xdccb 100
    did -t XDCCb 1
    did -f XDCCb 27
    did -h xdccb 710,711,720,721,730,731,901
    did -v xdccb 700,701
  }
  if (%sel = 3) {
    did -c xdccb 200
    did -f XDCCb 206 
    did -t XDCCb 222
    did -h xdccb 700,701,720,721,730,731,901
    did -v xdccb 710,711
  }
  if (%sel = 4) {
    did -c xdccb 300
    did -t XDCCb 1
    did -f XDCCb 308
    did -h xdccb 700,701,710,711,730,731
    did -v xdccb 720,721,901
  }
  if (%sel = 5) {
    did -c xdccb 500
    did -t XDCCb 1
    did -f XDCCb 501
    did -h xdccb 700,701,710,711,720,721
    did -v xdccb 730,731,901
  }
  if (%sel = 6) {
    did -c xdccb 600
    did -t XDCCb 1
    did -f XDCCb 398
    did -h xdccb 700,701,710,711,720,721,730,731,901
  }
}
on *:dialog:XDCCb:sclick:5: {
  remini -n $qt(%xdccgets.ini) $+($chr(38),Options,$chr(38))
  XDCCB-Setup Reset
  if ($gettok($readini(mirc.ini,options,n6),28,44) != 2) || ($sreq != auto) {
    var %check = $xdccb-check(Do you want XDCC Browser to set your mIRC client to automaticaly accept all files except for these types ? , $replace($readini(mirc.ini,text,ignore),$chr(44),$chr(32)) , From trusted users ?,yq,XDCC Browser)
    if (%check = $true) {
      .dcc ignore ignore 
      .sreq +m auto
    }
  }
  if ($gettok($readini(mirc.ini,options,n7),19,44) = 0) {
    var %check = $xdccb-check(Do you want XDCC Browser to set your mIRC client to receive files only from a list of "Trusted" users ?)
    if (%check = $true) {
      .sreq +m auto
      .dcc trust on
      did -c xdccb 387
    }
  }
  did -u xdccb 350,351,352,353,354,355,358,359,360,369,380,382,383,384,385,386,388,389,390,391,392,393,394,395
  xdccb-Loadoptions
}
on *:dialog:XDCCb:menu:11: url www.XDCCBrowser.com
on *:dialog:XDCCb:menu:12: {
  return $input(XDCC Browser v4.50 for mIRC 6.35 $crlf $+ by Yochai Timmer <Yochai@XDCCBrowser.com> $&
    $crlf $+ www.XDCCBrowser.com $+ $crlf $+ $crlf Thanks to: $crlf All the people who send $crlf bug reports and suggestions.,124, XDCC Browser)
}
on *:dialog:XDCCb:menu:13: url -n https://www.paypal.com/xclick/business=Yochai%40Dorot.org.il&item_name=XDCC+Browser+Script&no_shipping=1&cn=Well%2C+what+do+you+think+%3F&tax=0&currency_code=USD
on *:dialog:XDCCb:menu:16: xdccb-SaveAll
on *:dialog:XDCCb:menu:17: {
  var %ontop
  if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
    dialog -n xdccb
    var %ontop = yeap
  }
  var %file = $sfile($+(",$scriptdir*.xcb"),Load XDCC List:,Load)
  if (%ontop) dialog -o xdccb 
  if (!$isfile(%file)) return
  xdccb-loadlist %file
}
on *:dialog:XDCCb:menu:18: {
  var %ontop
  if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
    dialog -n xdccb
    var %ontop = yeap
  }
  var %file = $sfile($+(",$scriptdir*.xcb"),Delete XDCC List:,Delete)
  if (%ontop) dialog -o xdccb 
  if ($isfile(%file)) .remove $qt(%file)
}
on *:dialog:XDCCb:menu:20: {
  var %a = 1
  while ($hget(%a)) {
    var %if = $v1
    if (Xdccb- isin %if) {
      .hfree %if
      continue
    }
    inc %a
  }
  did -r xdccb 28
  xdccb27
  var %num = $calc($did(xdccb,28).lines -1) 
  did -i XDCCb 28 1 headertext $iif(%num = 1,$+(%num,$chr(160),Pack),$iif(%num = 0,Packs,$+(%num,$chr(160),Packs))) $chr(9) $chr(35) $chr(9) Size $chr(9) Gets $chr(9) Queue $chr(9) Rec. CPS $chr(9) Nick
}
on *:dialog:XDCCb:menu:21: {
  if (!$dialog(XDCCb-lists)) dialog $hget(Xdccboptions,Mode) XDCCb-lists XDCCb-lists
}
on *:dialog:XDCCb:sclick:27: {
  tokenize 32 $did($dname,27,1)
  if ($1 = dragover) {
    did -i XDCCb 27 1 dropeffect copy
  }
  elseif ($1 = drop) && ($2 = dragDrop)  {
    did -i XDCCb 27 1 page dropinfo 
    var %file = $gettok($did(XDCCb,27,1),3-,32)
    if ($gettok(%file,-1,46) != xcb) || (!$isfile(%file)) return
    xdccb-loadlist %file
  }
  var %sel = $did-tree(xdccb,27).sel
  var %text = $did-tree(xdccb,27)
  if (!%sel) || (!%text) return
  if ($1 = rclick) {
    var %a = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPCreateMenu,XDCCB27),2,32)
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 3
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 4
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 46
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 6
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 23
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 24
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 25
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 16
    MPopup MPAddIcon XDCCB27 > $shortfn($scriptdir\Xdccb-Icons.icl) > 12
    var %net = $did-tree(xdccb,27,$did-tree(xdccb,27).root)
    var %scid = $XDCCb-network(%net)
    var %chan
    if ($did-tree(xdccb,27,$gettok(%sel,1-2,32)) != %net) var %chan = $v1
    var %loc = $numtok(%sel,32)
    if ((%loc = 1) && ($XDCCb-network(%text)) ) || ((%loc = 2) && ($XDCCb-onchan($XDCCb-network($did-tree(xdccb,27,$gettok(%sel,1,32))),%text)))   mpopup MPAddItem %a > 12 5 0 $iif(%loc = 2,Part:,Quit:) %text > -
    if ((%chan) && (!$XDCCb-onchan(%scid,%chan))) || (!%scid) mpopup MPAddItem %a > 1 1 0 Join > -
    if (%scid)  mpopup MPAddItem %a > 10 3 0 Get Network's Channel List > -
    mpopup MPAddItem %a > 13 6 0 Save: %text $+ 's list > -
    if (%loc < 3) mpopup MPAddItem %a > 14 7 0 AutoSave: %text $+ 's list > -
    mpopup MPAddItem %a > 0 0 0 - > -
    mpopup MPAddItem %a > 2 2 0 Remove: %text > -
    mpopup MPAddItem %a > 11 4 0 Remove offline packs > -
    mpopup MPAddItem %a > 371 9 0 Join All > -
    mpopup MPAddItem %a > 374 8 0 Quit Irrelevant Channels/Networks > -
    mpopup MPopup XDCCB27 > $mouse.dx $mouse.dy
    return 
  }
  if ($numtok($did-tree(xdccb,27).sel,32) != 2) xdccb-addoption dSelect27 $did-tree(xdccb,27)
  xdccb-addoption Select27 $did-tree(xdccb,27)
  remini -n $qt(%xdccgets.ini) $+($chr(38),Options,$chr(38)) dSelect27
  did -r XDCCb 28
  xdccb-noclose
  XDCCb28
  xdccb-sort-28
  xdccb-okclose
}
on *:dialog:XDCCb:dclick:27: {
  if ($hget(Xdccboptions,Select27) != $did-tree(xdccb,27)) || ($hget(Xdccboptions,dSelect27) = $did-tree(xdccb,27)) $&
    || ($hget(Xdccboptions,Channel-pack) != Yes) return
  xdccb-addoption dSelect27 $did-tree(xdccb,27)
  var %check = $hget(Xdccboptions,Listing)
  var %network = $did-tree(xdccb,27,$did-tree(xdccb,27).root)
  did -i xdccb 28 1 page headerdims
  xdccb-addoption Dims28 $gettok($did(xdccb,28,1),3-,32)
  did -i XDCCb 28 1 headerdims $hget(Xdccboptions,Dims28) 140:7
  did -i XDCCb 28 1 headertext Pack $chr(9) $chr(35) $chr(9) Size $chr(9) Gets $chr(9) Queue $chr(9) Rec. CPS $chr(9) Nick
  did -a xdccb 700 0 0 $did-tree(xdccb,27,$did-tree(xdccb,27).sel).lines
  window -h @tmpXdccb28 
  var %loc = $did-tree(xdccb,27).sel
  did -ra xdccb 701 $did-tree(xdccb,27,%loc) ...
  xdccb-noclose
  var %a = 2
  var %counter = 1
  while ($did-tree(xdccb,27,%loc %a)) {
    var %nick = $v1
    var %b = 1
    while ($hfind($+(XDCCb-,%network),$+(%nick,$chr(255),*),%b,w)) {
      var %ifmatch = $v1
      var %num = $gettok(%ifmatch,$numtok(%ifmatch,255),255)
      if ((%num isnum) && ($gettok(%check,1,32) = 1)) || ((File Server isin %num) && ($gettok(%check,2,32) = 1)) || ((FTP = %num) && ($gettok(%check,3,32) = 1)) {
        if ($didwm(xdccb,28,$hget($+(XDCCb-,%network),%ifmatch),1) = 0) {
          var %pack = $hget($+(XDCCb-,%network),%ifmatch)
          var %nick = $gettok(%ifmatch,1,255)
          if (File Server isin %num) aline @tmpXdccb28 %pack $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) %nick $chr(4) $hget($+(XDCCb-,%network,-data),$+(%nick,$chr(255),File ServT)))
          elseif (FTP isin %num) aline @tmpXdccb28 %pack $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) %nick $chr(4) $hget($+(XDCCb-,%network,-data),$+(%nick,$chr(255),FTPm)))
          else aline @tmpXdccb28 %pack $chr(9) $iif($hget($+(XDCCb-,%network,-data),$+(%nick,$chr(255),Queue)),$v1,n/a) $chr(9) $iif($hget($+(XDCCb-,%network,-data),$+(%nick,$chr(255),MaxCps)),$v1,n/a) $chr(9) %nick $chr(4) Double click on a pack to request it.
        }
      }
      inc %b
    }
    inc %counter
    did -a Xdccb 700 %counter
    inc %a
  }
  filter -o @tmpXdccb28 XDCCB 28
  did -ra xdccb 701 Done
  did -a Xdccb 700 1 0 1
  xdccb-okclose
  uPackno
  xdccb-sort-28
}
on *:dialog:XDCCb:sclick:28: {
  tokenize 32 $did($dname,28,1)
  if ($1 = rclick) {
    if (!$did(xdccb,28).sel) return
    var %a = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPCreateMenu,XDCCB28),2,32)
    MPopup MPAddIcon XDCCB28 > $shortfn($scriptdir\Xdccb-Icons.icl) > 3
    MPopup MPAddIcon XDCCB28 > $shortfn($scriptdir\Xdccb-Icons.icl) > 4
    MPopup MPAddIcon XDCCB28 > $shortfn($scriptdir\Xdccb-Icons.icl) > 5
    MPopup MPAddIcon XDCCB28 > $shortfn($scriptdir\Xdccb-Icons.icl) > 7
    MPopup MPAddIcon XDCCB28 > $shortfn($scriptdir\Xdccb-Icons.icl) > 8
    mpopup MPAddItem %a > 3 5 0 Request > -
    mpopup MPAddItem %a > 4 4 0 Add without requesting > -
    var %net = $did-tree(xdccb,27,$did-tree(xdccb,27).root)
    var %scid = $XDCCb-network(%net)
    var %chan
    if ($did-tree(xdccb,27,$gettok($did-tree(xdccb,27).sel,1-2,32)) != %net) var %chan = $v1
    if ((%chan) && (!$XDCCb-onchan(%scid,%chan))) || (!%scid) mpopup MPAddItem %a > 1 1 0 Join > -
    mpopup MPAddItem %a > 0 0 0 - > -
    mpopup MPAddItem %a > 2 2 0 Remove Pack > -
    mpopup MPopup XDCCB28 > $mouse.dx $mouse.dy
    return 
  }
  if ($1-2 == headerclick headerEvent) {
    var %size = $hget(xdccboptions,sort)
    if ($gettok(%size,1,32) != $3) xdccb-addoption sort $3 u $gettok(%size,3-,32)
    else xdccb-addoption sort $puttok(%size,$iif($gettok(%size,2,32) = u,d,u),2,32)
    xdccb-sort-28
  }
}
on *:dialog:XDCCb:dclick:28: {
  tokenize 32 $Xdccb-getscid
  var %scid = $1
  var %network = $2
  var %loc = $did-tree(xdccb,27).sel
  if ($numtok(%loc,32) = 3) {
    var %nick = $did-tree(xdccb,27)
    var %Pack = $gettok($did(28).seltext,1,4)
  }
  else {
    var %nick = $gettok($did-list(7,$did(28).seltext),1,4)
    var %Pack = $gettok($did(28).seltext,1-4,9)
  }
  if (list* iswm $gettok(%Pack,1,46)) {
    scid -t1 %scid $+(/.,$gettok(%Pack,2-,46))
    return 
  }
  if (*File server*:* iswm $gettok(%pack,6,32)) {
    var %pack = $did-list(1-,%pack)
    hadd $+(XDCCb-,%network) $+(%nick,$chr(255),Fserv-use) $+(File server,$calc($gettok(%pack,2,9)))
  }
  elseif (FTP Site: = $gettok(%pack,6,32)) {
    run $+(FTP://,$gettok(%pack,7,32))
    return
  }
  else Saveinfo %nick %Pack %network
  if (*File server*:* !iswm $gettok(%pack,1-2,32)) var %pack = $did-list(1-,%pack)
  var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
  if (%scid != no) {
    var %chan = $hget($+(xdccb-,%network,-data),$+(%nick,$chr(255),chan))
    if (!$XDCCb-onchan(%scid,%chan)) Xdccb-joinuser %nick %network
    elseif (!$XDCCb-onchan(%scid,%chan,%nick)) return
    elseif (*File server*:* iswm $gettok(%pack,1-2,32)) Xdccb-request-fserv %nick %network %scid $gettok(%pack,1,9)
    elseif ($hget($+(Xdccbhash-,%nick2),Get) >= $hfind($+(Xdccbhash-,%nick2),pack*,0,w)) XDCCb-request-Pack %nick $+($chr(35),$remove($gettok(%Pack,2,9),$chr(32))) %scid %network %Pack
  }
  else Xdccb-joinuser %nick %network
}
on *:dialog:XDCCb:sclick:31: {
  if ($did-tree(xdccb,27).root) var %network = $did-tree(xdccb,27,$v1)
  if ($did(28).sel) {
    while ($did(xdccb,28,1).sel) {
      if (!$did-tree(xdccb,27)) {
        var %nick = $gettok($hfind($+(%name,$gettok($network,1,46)),$did(XDCCb,28,1).seltext,1,w).DATA,1,255)
        var %Pack = $+($gettok($hfind($+(%name,$gettok($network,1,46)),$did(XDCCb,28,1).seltext,1,w).DATA,2,255),.) $did(xdccb,28).seltext
      }
      else {
        if ($numtok($did-tree(xdccb,27).sel,32) = 2) var %nick = $did-list(7,$gettok($did(xdccb,28).seltext,1,4))
        else var %nick = $did-tree(xdccb,27)
        var %Pack = $did(xdccb,28,1).seltext
      }
      var %Pack = $did-list(2,%Pack)
      if (List* !iswm %Pack) var %Pack = $calc(%Pack)
      hdel -w $+(xdccb-,%network) $+(%nick,$chr(255),%Pack)
      did -d XDCCb 28 $did(xdccb,28,1).sel
      var %loc = $did-tree(xdccb,27).sel
      if ($did(xdccb,28).lines < 2) did -d XDCCb 27 $gettok(%loc,3,32)
      if ($hfind($+(XDCCb-,%network,-data),*˙Chan,0,w) = 0) {
        .hfree $+(xdccb-,$did-tree(xdccb,27),-data)
        if ($hget($+(XDCCb-,$did-tree(xdccb,27),-data))) .hfree $+(xdccb-,$did-tree(xdccb,27))
        goto end2
      }
    }
  }
  elseif ($did-tree(xdccb,27).sel) {
    var %loc = $did-tree(xdccb,27).sel
    var %depth = $numtok(%loc,32)
    if (%depth = 1) {
      if ($hget($+(xdccb-,%network))) .hfree $+(xdccb-,%network)
      if ($hget($+(xdccb-,%network,-data))) .hfree $+(xdccb-,%network,-data)
      var %scid = $XDCCb-network(%network)
      if (!%scid) {
        did -i xdccb 27 1 cb root
        did -d xdccb 27 %loc
        goto end2
      }
      did -i xdccb 27 1 cb root %loc
      var %a = 2
      while ($did-tree(xdccb,27,%loc %a)) {
        var %chan = $v1
        did -d xdccb 27 %a
        if  ($XDCCb-onchan(%scid,%chan)) did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
        inc %a
      }
    }
    elseif (%depth = 2) {
      var %a = 1
      while ($hfind($+(xdccb-,%network,-data),*˙Chan,%a,w)) {
        var %item = $v1
        if ($hget($+(xdccb-,%network,-data),%item) = $did-tree(xdccb,27)) {
          hdel -w $+(xdccb-,%network) $+($gettok(%item,1,255),˙*)
          hdel -w $+(xdccb-,%network,-data) $+($gettok(%item,1,255),˙*)
          continue
        }
        inc %a
      }
      did -i xdccb 27 1 cb root $did-tree(xdccb,27).root
      var %chan = $did-tree(xdccb,27)
      var %scid = $XDCCb-network(%network)
      did -d xdccb 27 $gettok(%loc,2,32)
      if  ($XDCCb-onchan(%scid,%chan)) {
        did -i xdccb 27 1 cb root $gettok(%loc,1,32)
        did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
      }
      if ($hfind($+(XDCCb-,%network),*˙Chan,0,w) = 0) {
        .hfree $+(xdccb-,%network)
        if ($hget($+(xdccb-,%network,-data))) .hfree $+(xdccb-,%network,-data)
        goto end2
      }
    }
    elseif (%depth = 3) {
      hdel -w $+(xdccb-,%network) $+($did-tree(xdccb,27),$chr(255),*)
      hdel -w $+(xdccb-,%network,-data) $+($did-tree(xdccb,27),$chr(255),*)
      did -i xdccb 27 1 cb root $gettok(%loc,1-2,32)
      did -d XDCCb 27 $gettok(%loc,3,32) 
      did -r xdccb 28
      var %chan = $did-tree(xdccb,27)
      var %scid = $XDCCb-network(%network)
      if ($did-tree(xdccb,27,$gettok(%loc,1-2,32)).lines < 1) && (!$XDCCb-onchan(%scid,%chan)) {
        did -d xdccb 27 $gettok(%loc,2,32)
        did -i xdccb 27 1 cb root $gettok(%loc,1,32)
        did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
      }
      if ($hfind($+(XDCCb-,%network,-data),*˙Chan,0,w) = 0) {
        .hfree $+(xdccb-,%network)
        .hfree $+(xdccb-,%network,-data)
      }
    }
  }
  :end2
  var %loc = $did-tree(xdccb,27).sel
  var %depth = $numtok(%loc,32)
  if (%depth = 3) XDCCb28
  filter -criw $+(2-,$did(xdccb,28).lines) xdccb 28 @tmpXdccb28 *
  filter -cot 1 9 @tmpXdccb28 xdccb 28 * 
  uPackno
}
on *:dialog:XDCCb:sclick:32: {
  if (!$did(28).sel) return
  if (List* iswm $gettok($did(28).seltext,1,32)) return
  tokenize 32 $Xdccb-getscid
  var %scid = $1
  var %network = $2
  var %a = 1
  while (%a <= $did(28,0).sel) {
    var %line = $did(XDCCb,28,%a).sel
    if (!$did-tree(xdccb,27).sel) {
      var %nick = $gettok($hfind($+(XDCCb-,%network),$did(28,%line).text,1,w).DATA,1,255)
      var %Pack = $+($gettok($hfind($+(XDCCb-,%network),$did(28,%line).text,1,w).DATA,2,255),.) $did(28,%line).text
    }
    else {
      var %nick = $did-tree(xdccb,27)
      var %Pack = $did(28,%line).text
    }
    Saveinfo %nick %Pack %network
    inc %a
  }
}
on *:dialog:XDCCb:sclick:33: {
  if ($did-tree(xdccb,27,$did-tree(xdccb,27).root)) var %net = $v1
  else var %net = $gettok($network,1,46)
  var %scid = $XDCCb-network(%net)
  if (!%scid) return 
  var %check $?="What kind of channel are you searching for ?"
  scid -t1 %scid /list %check
}
on *:dialog:XDCCb:sclick:34: {
  var %a = 1
  var %blah
  while ($hget(%a)) {
    var %hash = $v1
    if (Xdccb- isin %hash) && (-data !isin %hash) {
      var %net = $gettok(%hash,2-,45))
      if (!$XDCCb-network(%net)) && (%net) {
        .hfree %hash
        if ($hget($+(%hash,-data))) .hfree $+(%hash,-data)
        var %blah = $Find-branch(xdccb,27,%net)
        if (%blah) did -d xdccb 27 %blah
        continue
      }
    }
    inc %a
  }
  var %a = 2
  while ($did-tree(xdccb,27,%a)) {
    var %net = $v1
    var %scid = $XDCCb-network(%net)
    var %b = 2
    while ($did-tree(xdccb,27,%a %b)) {
      var %chan = $v1
      if (!$XDCCb-onchan(%scid,%chan)) var %match = yeap
      else var %match = no
      var %c = $calc($did-tree(xdccb,27,%a %b).lines +1)
      while ($did-tree(xdccb,27,%a %b %c) ) {
        var %nick = $v1
        if (%match = yeap) || (!$XDCCb-onchan(%scid,%chan,%nick)) {
          hdel -w $+(xdccb-,%net) $+(%nick,$chr(255),*)
          hdel -w $+(xdccb-,%net,-data) $+(%nick,$chr(255),*)
          did -i xdccb 27 1 cb root %a %b
          did -d xdccb 27 %c
        }
        dec %c
      }
      if ($did-tree(xdccb,27,%a %b).lines < 1) {
        did -i xdccb 27 1 cb root %a
        did -d xdccb 27 %b      
        if ($XDCCb-onchan(%scid,%chan)) {
          did -i xdccb 27 1 cb root %a
          did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
        }
        else dec %b
      }
      inc %b
    }
    inc %a
  }
  upackno
}

;Search Tab

on *:dialog:XDCCb:sclick:202,222: {
  unset %Xdccb-searchstop
  if ($sock(xdccb)) .sockclose xdccb
  if ($timer(Xdccb-socket)) .timerXdccb-socket off 
  if (!$read(%Xdccb-Search.txt, w,$did(206))) write $qt(%Xdccb-Search.txt) $did(206)
  did -ra xdccb 211,711 Searching...
  did -ra xdccb 710 0 0 1
  did -b xdccb 209
  if ($did(xdccb,203).sel != 8) xdccb-addoption sort $gettok($hget(xdccboptions,sort),1-2,32) 1 u $gettok($hget(xdccboptions,sort),5-,32)
  if ($did(xdccb,203).sel < 6) {
    var %search = $replace($did(206),$chr(32),+)
    if ($len(%search) <= 2) {
      did -ra xdccb 211 String to short
      did -ra xdccb 711 Done
      did -a xdccb 710 1 0 1
    }
    else {
      if ($did(xdccb,203).sel = 2) {
        set %Xdccb-searchstop on
        did -r XDCCb 207
        .timerXdccb-socket 1 1 sockopen xdccb www.xdccfinder.com  80 
        xdccb-addoption search /results.php?search= $+ %search
        xdccb-addoption site www.xdccfinder.com
        xdccb-addoption Next 0
      }
      else if ($did(xdccb,203).sel = 3) {
        set %Xdccb-searchstop on
        did -r XDCCb 207
        .timerXdccb-socket 1 1 sockopen xdccb www.xdccreport.com 80 
        xdccb-addoption search /search.php?&kw= $+ %search $+ &page=1
        xdccb-addoption site www.xdccreport.com
        xdccb-addoption Next 0
      }
      elseif ($did(xdccb,203).sel = 4) {
        set %Xdccb-searchstop on
        did -r XDCCb 207
        .timerXdccb-socket 1 1 sockopen xdccb www.xdccing.com 80 
        xdccb-addoption search / $+ %search
        xdccb-addoption site www.xdccing.com
        xdccb-addoption Next 0
      }
      elseif ($did(xdccb,203).sel = 5) {
        set %Xdccb-searchstop on
        did -r XDCCb 207
        .timerXdccb-socket 1 1 sockopen xdccb www.searchxdcc.com  80 
        xdccb-addoption search /xdccsearch.php?Description= $+ %search
        xdccb-addoption site www.searchxdcc.com
        xdccb-addoption Next 0
      }
    }
  }
  if ($did(xdccb,203).sel = 6) {
    did -r XDCCb 207
    var %a = 1
    var %num = 0
    while ($hget(%a)) {
      var %get = $v1
      if ($+(XDCCb-,*) iswm %get) && (*-data !iswm %get) inc %num $hget(%get,0).item
      inc %a
    }
    did -ra Xdccb 711 Searching...
    did -a Xdccb 710 0 0 %num
    xdccb-noclose
    var %a = 1
    if ($window(@tmpXdccb202)) clear @tmpXdccb202
    while ($hget(%a)) {
      var %get = $v1
      if ($+(XDCCb-,*) iswm %get) && (*-data !iswm %get) {
        XDCCb202 $remove(%get,XDCCb-) 
      }
      inc %a
    }
    filter -o @tmpXdccb202 XDCCB 207
    did -ra xdccb 711,211 Done
    did -a xdccb 710 1 0 1
    xdccb-okclose
  }
  elseif ($did(xdccb,203).sel = 7) {
    var %a = 2
    var %search = $+(*,$replace($did(206),$chr(32),*),*)
    var %size = $hget(Xdccboptions,Search-Size)
    var %compare = $iif($gettok(%size,1,44) = 1,<,>)
    var %size = $calc($gettok(%size,2,44) * (1024 ^ $gettok(%size,3,44)))
    did -ra Xdccb 711 Searching results...
    did -a Xdccb 710 0 0 $did(207).lines
    xdccb-noclose
    var %count = 0
    while ($did(207,%a)) {
      dll $qt($scriptdir\WhileFix.dll) WhileFix
      if (%Xdccb-searchstop) {
        did -ra xdccb 211,711 Done
        did -ra xdccb 710 1 0 1
        xdccb-okclose
        return
      }
      inc %count
      did -a Xdccb 710 %count
      var %value = $did-list(1,$did(207,%a))
      var %file-size = $Xdccb-Calcsize($did-list(3,$did(207,%a)))
      if (%file-size %compare %size) || ($+(*,$replace($did(206),$chr(32),*),*) !iswm %value) {
        did -d xdccb 207 %a
        continue
      }
      inc %a
    }
    did -ra xdccb 211,711 Done
    did -ra xdccb 710 1 0 1
    xdccb-okclose
  }
  elseif ($did(xdccb,203).sel = 8) {
    var %search = $did(206) 
    var %search = $replace(%search,$chr(32),$chr(43))
    url -n www.xdccreport.com/search.php?&kw= $+ %search $+ &page=1
    .timer 1 2 url http://www.xdccing.com/ $+ %search
    .timer 1 2 url http://www.xdccfinder.com/results.php?search= $+ %search
    .timer 1 3 url http://www.searchxdcc.com/xdccsearch.php?Description= $+ %search $+ &x=0&y=0
  }
  var %num = $calc($did(xdccb,207).lines -1)
  did -ra xdccb 205 $iif(%num = 1,%num Result,%num Results)
  filter -criw $+(2-,$did(xdccb,207).lines) xdccb 207 @tmpXdccb202 *
  filter -cot 1 9 @tmpxdccb202 xdccb 207 * 
  if ($appactive) dialog -v xdccb
}
on *:dialog:xdccb:sclick:203: xdccb-addoption Searchselect $did(203).sel
on *:dialog:XDCCb:edit:206: {
  var %file = $qt(%Xdccb-Search.txt)
  while ($did(206,1)) did -d xdccb 206 1
  var %a = 1
  if (!$did(206)) {
    loadbuf 10 -o xdccb 206 %file
    return
  }
  while ($read(%file,w,$+($did(206),*),%a)) {
    did -a xdccb 206 $v1
    %a = $calc($readn +1)
  }
} 
on *:dialog:XDCCb:sclick:207: {
  tokenize 32 $did($dname,207,1)
  if ($1 = rclick) {
    if (!$did(xdccb,207).sel) return
    var %line = $did(XDCCb,207).seltext
    var %line = $did-list(1-,%line)
    var %a = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPCreateMenu,XDCCB207),2,32)
    MPopup MPAddIcon XDCCB207 > $shortfn($scriptdir\Xdccb-Icons.icl) > 3
    MPopup MPAddIcon XDCCB207 > $shortfn($scriptdir\Xdccb-Icons.icl) > 4
    MPopup MPAddIcon XDCCB207 > $shortfn($scriptdir\Xdccb-Icons.icl) > 5
    MPopup MPAddIcon XDCCB207 > $shortfn($scriptdir\Xdccb-Icons.icl) > 7
    MPopup MPAddIcon XDCCB207 > $shortfn($scriptdir\Xdccb-Icons.icl) > 8
    MPopup MPAddIcon XDCCB207 > $shortfn($scriptdir\Xdccb-Icons.icl) > 12
    mpopup MPAddItem %a > 3 5 0 Request > -
    mpopup MPAddItem %a > 4 4 0 Add without requesting > -
    mpopup MPAddItem %a > 0 0 0 - > -
    var %net = $remove($gettok(%line,9,9),$chr(32))
    var %scid = $XDCCb-network(%net)
    var %chan = $remove($+($gettok(%line,8,9)),$chr(32))
    if ((%chan) && (!$XDCCb-onchan(%scid,%chan))) || (!%scid) mpopup MPAddItem %a > 1 1 0 Join > -
    mpopup MPAddItem %a > 371 6 0 Join All > -
    if (%scid) mpopup MPAddItem %a > 10 3 0 Get Network's Channel List > -
    mpopup MPopup XDCCB207 > $mouse.dx $mouse.dy
    return 
  }
  if ($1-2 == headerclick headerEvent) {
    var %size = $hget(xdccboptions,sort)
    if ($gettok(%size,3,32) != $3) xdccb-addoption sort $gettok(%size,1-2,32) $3 u $gettok(%size,5-,32)
    else xdccb-addoption sort $puttok(%size,$iif($gettok(%size,4,32) = u,d,u),4,32)
    Xdccb-sort-207
  }
}
on *:dialog:XDCCb:dclick:207: {
  var %xdccget.ini = $qt(%xdccgets.ini)
  var %chan,%match
  var %line = $did(XDCCb,207).seltext
  var %line = $did-list(1-,%line)
  var %Pack = $gettok($did(XDCCb,207).seltext,1-4,9)
  var %nick = $remove($gettok($gettok(%line,7,9),1,4),$chr(32))
  var %num = $+($chr(35),$remove($gettok(%line,2,9),$chr(32)))
  var %net = $gettok($remove($gettok(%line,9,9),$chr(32)),1,46)
  var %scid = $XDCCb-network(%net)
  var %chan = $+($remove($gettok(%line,8,9),$chr(32)))
  var %Pack-num = $remove($gettok(%line,2,9),$chr(32))
  if (!$hget($+(Xdccb-,%net),$+(%nick,$chr(255),%Pack-num))) {
    var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
    var %Server = $remove($gettok($gettok(%line,10,9),1,4),$chr(32))
    var %port = 6667
    var %Pack = $gettok(%line,1-4,9)
    var %a = 1
    while ($hget($+(Xdccbhash-,%nick2),$hfind($+(Xdccbhash-,%nick2),Pack*,%a,w))) {
      var %temp-Pack = $v1 
      if (%temp-Pack = %Pack) var %match = %Pack
      inc %a
    }
    if (!%match) {
      var %Pack-num = $remove($gettok(%Pack,2,9),$chr(32))
      writeini -n %xdccget.ini %nick2 $+(Pack,%Pack-num) %Pack
      writeini -n %xdccget.ini %nick2 $+(Date,%Pack-num) $Date
      writeini -n %xdccget.ini %nick2 $+(Time,%Pack-num) $Time
      writeini -n %xdccget.ini %nick2 Chan %chan
      var %usage = $gettok(%line,2,4)
      writeini -n %xdccget.ini %nick2 Usage $gettok(%usage,$+(1-,$calc($numtok(%usage,35) -1)),35)
      Xdccb-RandomServer %net %nick2 %server %port
      writeini -n %xdccget.ini %nick2 Network %net
      writeini -n %xdccget.ini %nick2 Port %port
      if (!$hget($+(Xdccbhash-,%nick2),get)) writeini -n %xdccget.ini %nick2 Get 1
      Xdccb-Hashnick %nick2
      if ($dialog(XDCCb)) {
        if ( $didwm(xdccb,308,$+(*,$replace(%pack,$chr(9),$+(*,$chr(9),*)),*,%nick,*),1) = 0 ) {
          var %get = $hget($+(Xdccbhash-,%nick2),get)
          var %a = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)
          var %order = $iif($calc(%a - %get +1) > 0,$v1,Finished)
          var %stat = $Xdccb-stats(%nick,%net,%chan,%order)
          if ($numtok(%pack,9) = 2) var %pack = %pack $chr(9) n/a
          did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 $gettok(%pack,1-3,9) $chr(9) $gettok(%stat,1,9) $chr(9) $ord(%order) $chr(9) %nick $chr(9) %chan $chr(9) %net $chr(9) %server
        } 
      }
    }
  }
  elseif (*File server*:* iswm $gettok(%pack,6,32)) {
    var %pack = $did-list(1-4,%pack)
    hadd $+(XDCCb-,%net) $+(%nick,$chr(255),Fserv-use) $+(File server,$calc($gettok(%pack,2,9)))
  }
  elseif (FTP Site: = $gettok(%pack,6,32)) {
    run $+(FTP://,$gettok(%pack,7,32))
    return
  }
  else {
    saveinfo %nick %pack %net
    var %pack = $did-list(1-,%pack)
  }
  if (%scid) {
    var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
    if (!$XDCCb-onchan(%scid,%chan)) Xdccb-joinuser %nick %net
    elseif (!$XDCCb-onchan(%scid,%chan,%nick)) return
    elseif (*File server*:* iswm %pack) Xdccb-request-fserv %nick %net %scid $gettok(%pack,1,9)
    elseif ($hget($+(Xdccbhash-,%nick2),Get) >= $hfind($+(Xdccbhash-,%nick2),pack*,0,w)) XDCCb-request-Pack %nick $+($chr(35),$remove($gettok(%Pack,2,9),$chr(32))) %scid %net %Pack
  }
  else Xdccb-joinuser %nick %net
}
on *:dialog:XDCCb:sclick:209: {
  var %site = $hget(Xdccboptions,site)
  var %num = $calc($did(xdccb,207).lines -1)
  did -ra xdccb 205 $iif(%num = 1,%num Result,%num Results)
  did -b xdccb 209
  var %place = $gettok($did(xdccb,710),1,32)
  var %num = $gettok($did(xdccb,710),3,32)
  if (%place < %num) {
    xdccb-addoption Next 1
    if (xdccreport isin %site) {
      xdccb-addoption search $+($gettok($hget(xdccboptions,search),1-2,61),=,$calc(%place +1))
      Xdccb-Sockcontinue
    }
    elseif (xdccing isin %site) {
      xdccb-addoption search $+(/,$gettok($gettok($hget(xdccboptions,search),1,46),1-2,47),/,$calc(%place +1))
      Xdccb-Sockcontinue
    }
    elseif (xdccfinder isin %site) {
      xdccb-addoption search $+($gettok($hget(xdccboptions,search),1,38),&s=,%place,&np=,%num)
      Xdccb-Sockcontinue  
    }
    elseif (searchxdcc isin %site) {
      xdccb-addoption search $+($gettok($hget(xdccboptions,search),1,38),&Show=,%place)
      Xdccb-Sockcontinue  
    }
  }
  else Xdccb-Stopsocket
  set %Xdccb-searchstop on
}
on *:dialog:XDCCb:sclick:213: if ($did(xdccb,213).sel) xdccb-addoption Search-Size $puttok($hget(Xdccboptions,Search-Size),$v1,1,44)
on *:dialog:XDCCb:edit:214: if ($replace($did(xdccb,214),$chr(44),$chr(46)) isnum) xdccb-addoption Search-Size $puttok($hget(Xdccboptions,Search-Size),$v1,2,44)
on *:dialog:XDCCb:sclick:215: if ($did(xdccb,215).sel) xdccb-addoption Search-Size $puttok($hget(Xdccboptions,Search-Size),$v1,3,44)
on *:dialog:XDCCb:sclick:233: {
  while ($did(206,1)) did -d xdccb 206 1
  .remove $qt(%Xdccb-Search.txt)
}
;Request Tab

on *:dialog:XDCCb:sclick:303: {
  if (!$did(Xdccb,308).sel) return
  var %num = $did(xdccb,308,0).sel
  var %a = %num
  while (%a > 0) {
    var %line = $did(xdccb,308,$did(xdccb,308,%a).sel)
    var %stats = $did-list(5,%line)
    var %user = $did-list(6,%line)
    var %nick = $replace(%user,[,$chr(60),],$chr(62))
    var %get = $hget($+(Xdccbhash-,%nick),get)
    var %network = $did-list(8,%line)
    var %scid = $XDCCb-network(%network)
    var %file = $qt($+($scriptdir\Xdccb-queues-,%network,.txt))
    var %lines = $lines(%file)
    var %nicks = $calc($read(%file,0) -1)
    if (%scid) {
      var %comchan = $xdccb-changet(%scid,%user)
      var %server = $Xdccb-getserver(%scid)
    }
    if ($hfind($+(Xdccbhash-,%nick),Pack*,0,w) > 1) {
      var %pack = $remove($did-list(5,%line),st,nd,rd,th)   
      if (%Pack < %get) {
        dec %get 
        writeini -n $qt(%xdccgets.ini) %nick get %get
        hadd $+(Xdccbhash-,%nick) get %get
      }
      var %pack-num = $did-list(2,%line)
      xdccb-remove %nick $+(Pack,%Pack-num)
      xdccb-remove %nick $+(Date,%Pack-num)
      xdccb-remove %nick $+(Time,%Pack-num)
      if (%stats = 1st) && (%scid) scid %scid close -g* %user
      did -d XDCCb 308 $did(xdccb,308,%a).sel
      var %b = 2
      var %new-pos
      while ($did(xdccb,308,%b)) {
        var %v1 = $v1
        if ($did-list(6,%v1) = %user) {
          if ($remove($did-list(5,%v1),st,nd,rd,th) > %pack) {
            var %new-pos = $ord($calc($v1 -1))
            did -o xdccb 308 %b $puttok($did-list(1-,%v1),$+($Chr(32),%new-pos,$chr(32)),5,9)
            if (s isin $gettok(%v1,2,32)) did -kc XDCCb 308 %b 
          }
          if (%new-pos = 1st) && (%pack = 1) {
            if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
            if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) $+(.timerxdccb-remove-,%User) 1 1 scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
            $+(.timerxdccb-,%User) 1 2 XDCCb-request-Pack %user $did-list(2,%v1) %scid %network $did-list(1,%v1)
          }
        }
        var %new-pos
        inc %b
      }
    }
    else {
      if (%server) && (%comchan) && ($ini(%xdccgets.ini,DCC˙Allow,%network)) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) scid -t1 %scid /.DCCALLOW $+(-,%user)
      if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust -r $+(%user,!*@*)
      if ($Timer($+(XDCCB-,%user))) $+(.TimerXDCCB-,%user) off
      if (%comchan) && (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) && ($hget(Xdccboptions,XDCCAutoGet) = on) && (%server) scid -t1 %scid $hget(Xdccboptions,Request) %user XDCC remove
      xdccb-remove %nick
      if (%stats != Finished) && (%scid) scid %scid close -g* %user
      did -d XDCCb 308 $did(xdccb,308,%a).sel
    }
    dec %a
  }
  if ($read(%file,s,%user )) {
    while ($read(%file,s,%user )) {
      write $+(-dl,$calc($readn +1)) %file
      dec %lines    
    }
    var %line = $read(%file,w,%user)
    write $+(-dl,$calc($readn +1)) %file
    write -l0 %file $calc($read(%file,0) - 1)
    if ($lines(%file) < 2) .remove $qt(%file)
  }
  elseif ($lines(%file) < 2) .remove $qt(%file)
}
on *:dialog:XDCCb:sclick:304: {
  if (!$did(xdccb,308).sel) return
  Xdccb-joinuser $did-list(6,$did(xdccb,308).seltext)
}
on *:dialog:XDCCb:sclick:308: {
  tokenize 32 $did($dname,308,1)
  if ($did-tree(xdccb,308).event = rclick) {
    if (!$did(xdccb,308).sel) return
    var %a = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPCreateMenu,XDCCB308),2,32)
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 3
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 4
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 8
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 14
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 15
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 16
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 12
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 13
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 46
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 28
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 27
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 10
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 45
    MPopup MPAddIcon XDCCB308 > $shortfn($scriptdir\Xdccb-Icons.icl) > 47
    var %net = $did-list(8,$did(xdccb,308).seltext)
    var %scid = $XDCCb-network(%net)
    var %chan = $did-list(7,$did(xdccb,308).seltext)
    var %stat = $did-list(4,$did(xdccb,308).seltext)
    var %num = 2
    var %nick = $did-list(6,$did(xdccb,308,$did(xdccb,308,1).sel))
    while ($did(xdccb,308,%num).sel) {
      if ($did-list(6,$did(xdccb,308,$v1)) != %nick) {
        var %num = more
        break
      }
      inc %num
    }
    mpopup MPAddItem %a > 385 13 0 Pause request > -
    if (%stat = Register) mpopup MPAddItem %a > 379 12 0 I've registered on %net > -
    elseif ($did(xdccb,308,0).sel = 1) && (unable isin $did-list(4,$did(xdccb,308,$did(xdccb,308,1).sel))) mpopup MPAddItem %a > 378 12 0 Clear unable to connect status > -
    else mpopup MPAddItem %a > 3 3 0 $iif(%num = more,Request from users,Request from %nick) > -
    if ($did(xdccb,308,0).sel = 1) {
      if ((%chan) && (!$XDCCb-onchan(%scid,%chan))) || (!%scid) mpopup MPAddItem %a > 1 1 0 Join > -
      var %sub = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPAddSubMenu,%a > 100 8 0 Order),2,32)
      mpopup MPAddItem %sub > 375 4 0 Move Up > -
      mpopup MPAddItem %sub > 376 5 0 Move Down > -
      mpopup MPAddItem %sub > 377 10 0 Set 1st priority > -
    }
    mpopup MPAddItem %a > 371 7 0 Join All > -
    mpopup MPAddItem %a > 372 11 0 Request All > -
    mpopup MPAddItem %a > 101 -1 -1 - > -
    if ($did(xdccb,308,0).sel = 1) mpopup MPAddItem %a > 386 14 0 Edit information > -
    if ($did(xdccb,308,0).sel = 1) && (%scid)  mpopup MPAddItem %a > 10 9 0 Get Network's Channel List > -
    mpopup MPAddItem %a > 374 6 0 Quit Irrelevant Channels/Networks > -
    mpopup MPAddItem %a > 373 2 0 Remove Selected > -
    mpopup MPopup XDCCB308 > $mouse.dx $mouse.dy
    return 
  }
  if ($1-2 == headerclick headerEvent) {
    var %size = $hget(xdccboptions,sort)
    if ($gettok(%size,5,32) != $3) xdccb-addoption sort $gettok(%size,1-4,32) $3 u 
    else xdccb-addoption sort $puttok(%size,$iif($gettok(%size,6,32) = u,d,u),6,32)
    xdccb-sort-308
  }
}
on *:dialog:XDCCb:dclick:308: {
  var %nick = $replace($did-list(6,$did(xdccb,308).seltext),[,$chr(60),],$chr(62))
  var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
  var %scid = $XDCCb-network(%network)
  var %chan = $hget($+(Xdccbhash-,%nick),chan)
  var %pack = $did-list(1,$did(308).seltext)
  if (% isin $did-list(4,$did(xdccb,308).seltext)) {
    window -a @ $+ $get($Xdccb-getactive($did-list(6,$did(xdccb,308).seltext))).wid
    return
  }
  if (%scid) var %comchan = $xdccb-changet(%scid,$did-list(6,$did(xdccb,308).seltext))
  if (%comchan) {
    if (*File server* iswm %pack) Xdccb-request-fserv $did-list(6,$did(xdccb,308).seltext) %network %scid %pack
    else XDCCb-request-Pack $did-list(6,$did(xdccb,308).seltext) $+($chr(35),$did-list(2,$did(308).seltext)) %scid %network %pack
    return
  }
  elseif (%scid) && ($XDCCb-onchan(%scid,%chan,$me)) && (!$XDCCb-onchan(%scid,%chan,$did-list(6,$did(xdccb,308).seltext))) return
  if ($XDCCb-network(%network,%chan)) {
    scid -t1 $v1 /join %chan
    return
  }
  else server -m $hget($+(Xdccbhash-,%nick),server) $hget($+(Xdccbhash-,%nick),port) -j %chan
}
on *:dialog:XDCCb:sclick:350: xdccb-addoption XDCCAutoGet $iif($did(350).state = 1,on,off) 
on *:dialog:XDCCb:sclick:351: xdccb-addoption XDCCResume $iif($did(351).state = 1,on,off)
on *:dialog:XDCCb:sclick:352: xdccb-addoption XDCCDelete-hash $iif($did(352).state = 1,on,off)
on *:dialog:XDCCb:sclick:353: xdccb-addoption XDCC-Requestlist $iif($did(353).state = 1,on,off)
on *:dialog:XDCCb:sclick:354: {
  var %check = $hget(Xdccboptions,Mode)
  if (o isin %check) {
    dialog -n xdccb
    xdccb-addoption Mode $remove(%check,o)
  }
  else {
    dialog -o xdccb
    xdccb-addoption Mode $+(%check,o)
  }
}
on *:dialog:XDCCb:sclick:355: {
  var %check = $hget(Xdccboptions,Mode)
  if (d isin %check) xdccb-addoption Mode $remove(%check,d)
  else xdccb-addoption Mode $+(%check,d)
  dialog -c xdccb
  .timer 1 1 XDCCb
}
on *:dialog:XDCCb:sclick:358: xdccb-addoption Request /.msg
on *:dialog:XDCCb:sclick:359: xdccb-addoption Request /.ctcp
on *:dialog:XDCCb:sclick:360: xdccb-addoption Echo $iif($did(360).state = 1,on,off)
on *:dialog:XDCCb:sclick:369: xdccb-addoption Join-channels $iif($did(369).state = 1,Yes,no)
on *:dialog:XDCCb:sclick:380: xdccb-addoption Auto-connect $iif($did(380).state = 1,on,off)
on *:dialog:XDCCb:sclick:382: xdccb-addoption Hide-Packs $iif($did(382).state = 1,on,off)
on *:dialog:XDCCb:sclick:383: xdccb-addoption Delete $iif($did(383).state = 1,on,off)
on *:dialog:XDCCb:sclick:384: {
  if ($did(384).state = 1) {
    xdccb-addoption Sessions on
    var %a = 1
    while ($scon(%a)) {
      scid $v1 $+(/.timerXdcc-sessions,$gettok($scid($v1).network,1,46)) 1 43200 Xdccb-Session 
      inc %a
    }
  }
  else {
    xdccb-addoption Sessions off
    var %a = 1
    while ($scon(%a)) {
      scid $v1 $+(/.timerXdcc-sessions,$gettok($scid($v1).network,1,46)) off 
      inc %a
    }
  }
}
on *:dialog:XDCCb:sclick:385: {
  if ($did(385).state = 1) {
    Xdccb-Make-reg
    xdccb-addoption Links on
    if (!$portable) run regedit /s /c XdccB.reg
  }
  else {
    write -c XdccB.reg
    if (9* iswm $os) || ($os = ME) write XdccB.reg REGEDIT4
    else write XdccB.reg Windows Registry Editor Version 5.00
    write XdccB.reg $crlf
    write XdccB.reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec]
    write XdccB.reg @=" $+ $chr(37) $+ 1"
    write XdccB.reg $crlf 
    write XdccB.reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\ifexec]
    write XdccB.reg @=" $+ $chr(37) $+ 1"
    write XdccB.reg $crlf
    write XdccB.reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\Topic]
    write XdccB.reg @="Connect"
    write XdccB.reg $crlf
    write XdccB.reg [-HKEY_CLASSES_ROOT\XDCC]
    write XdccB.reg $crlf
    write XdccB.reg [-HKEY_CLASSES_ROOT\.xcb]
    xdccb-addoption Links off
    if (!$portable) run regedit /s /c XdccB.reg
    .timer 1 1 .remove XdccB.reg
  }
}
on *:dialog:XDCCb:sclick:386: xdccb-addoption Channel-pack $iif($did(386).state = 1,Yes,No)
on *:dialog:XDCCb:sclick:387: {
  var %check = $gettok($readini(mirc.ini,options,n7),19,44) 
  var %a = 1
  if (%check = 1) .dcc trust off
  else .dcc trust on
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    if (%check = 0) {
      var %net = $hget($+(Xdccbhash-,%nick),Network)
      var %scid = $XDCCb-network(%net)
      if (%scid) {
        var %nick = $replace(%nick,$chr(60),[,$chr(62),])
        var %comchan = $xdccb-changet(%scid,%nick)
        if (%comchan) .dcc trust $+(%nick,!*@*)
      }
    }
    else .dcc trust -r $+($replace(%nick,$chr(60),[,$chr(62),]),!*@*) 
    inc %a 
  }
}
on *:dialog:XDCCb:sclick:388: {
  var %check = $hget(Xdccboptions,Listing)
  if ($did(388).state = 1) xdccb-addoption Listing $puttok(%check,1,1,32)
  else xdccb-addoption Listing $puttok(%check,0,1,32)
  XDCCb27
  did -r xdccb 28
}
on *:dialog:XDCCb:sclick:389: {
  var %check = $hget(Xdccboptions,Listing)
  if ($did(389).state = 1) xdccb-addoption Listing $puttok(%check,1,2,32)
  else xdccb-addoption Listing $puttok(%check,0,2,32)
  XDCCb27
  did -r xdccb 28
}
on *:dialog:XDCCb:sclick:390: {
  var %check = $hget(Xdccboptions,Listing)
  if ($did(390).state = 1) xdccb-addoption Listing $puttok(%check,1,3,32)
  else xdccb-addoption Listing $puttok(%check,0,3,32)
  XDCCb27
  did -r xdccb 28
}
on *:dialog:XDCCb:sclick:391: xdccb-addoption Hide-Fserv $iif($did(391).state = 1,on,off)
on *:dialog:XDCCb:sclick:392: xdccb-addoption Remove $iif($did(392).state = 1,on,off)
on *:dialog:XDCCb:sclick:393: {
  if ($did(393).state = 1) {
    xdccb-addoption Autosave on
    if (!$timer(xdccb-autosave)) .timerXDCCb-autosave -i 0 $calc($hget(Xdccboptions,Autosave-time) * 3600) XDCCb-autosave
    if ($dialog(xdccb-lists)) did -c xdccb-lists 19 
  }
  else {
    xdccb-addoption Autosave off
    if ($timer(xdccb-autosave)) .timerXDCCb-autosave off
    if ($dialog(xdccb-lists)) did -u xdccb-lists 19 
  }
}
on *:dialog:XDCCb:sclick:394: xdccb-addoption Finish-Quit $iif($did(394).state = 1,on,off)
on *:dialog:XDCCb:sclick:395: xdccb-addoption Finish-Shutdown $iif($did(395).state = 1,on,off)
on *:dialog:XDCCb:sclick:396: xdccb-addoption Fserv-Browser $iif($did(396).state = 1,on,off)
on *:dialog:XDCCb:sclick:397: xdccb-addoption Move $iif($did(397).state = 1,on,off)
on *:dialog:XDCCb:sclick:399: {
  var %finish = $sdir($hget(Xdccboptions,Finish),Choose a directory for the completed files)
  if (%finish) {
    xdccb-addoption Finish %finish
    if (!$isdir(%finish)) .mkdir $qt(%finish)
    did -ra xdccb 398 %finish
  }
}
on *:dialog:XDCCb:sclick:400: xdccb-addoption Startup $iif($did(400).state = 1,on,off)
on *:dialog:XDCCb:sclick:401: {
  if ($did(401).state = 1) {
    xdccb-addoption Minimize on
    var %check = $hget(Xdccboptions,Mode)
    if (d !isin %check) {
      xdccb-addoption Mode $+(%check,d)
      did -c xdccb 355
      dialog -c xdccb
      .timer 1 1 XDCCb
    }
    if ($did(400).state != 1) {
      xdccb-addoption Startup on
      did -c xdccb 400
    }
    did -b xdccb 400,355
    tray -s1t1
    showmirc -t
  }
  else {
    xdccb-addoption Minimize off
    did -e xdccb 400,355
    tray -s0
  }
}
on *:dialog:XDCCb:sclick:402:  {
  xdccb-addoption Stats $iif($did(402).state = 1,on,off)
  if ($did(402).state = 0) && ($window($+(@XDCCB,$chr(160),Stats))) {
    close -@ $+(@XDCCB,$chr(160),Stats)
    .timerxdccb-statswindow off
  }
}
on *:dialog:XDCCb:sclick:403: {
  if ($did(403).state = 1) {
    if (!$sslready) {
      var %check = $input(You will have to download the latest full version of SSLopen and restart mIRC. Do you wish to continue?,yq,XDCC Browser - Download SSL)
      if (%check) run http://www.shininglightpro.com/products/Win32OpenSSL.html 
      did -u xdccb 403
      return
    }
    xdccb-addoption SSL on
  }
  else {
    xdccb-addoption SSL off
    .timerxdccbserver* off
  }
}
on *:dialog:XDCCb:sclick:407: {
  var %a = 2
  var %sends = 0
  While ($did(xdccb,308,%a)) {
    var %line = $v1
    if ($did-list(5,%line) = 1st) {
      var %nick = $did-list(6,%line)
      var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
      var %get = $hget($+(Xdccbhash-,%nick2),get)
      var %Pack = $readiniwm(%xdccgets.ini,%nick2,Pack*,%get)
      var %network = $gettok($hget($+(Xdccbhash-,%nick2),network),1,46)
      var %scid = $XDCCb-network(%network)
      var %comchan = $xdccb-changet(%scid,%nick)
      var %active-gets = 0
      if (%comchan) && (%Pack) {
        var %b = 1
        while ($get(%nick,0) >= %b) {
          if ($Get(%nick,%b).status = active) var %gets = active
          inc %b
          inc %active-gets
        }
        if (%gets != active) {
          if (%scid) $+(.TimerXDCCB-,%nick) 1 %a XDCCb-request-Pack %nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) %scid %network %Pack
          inc %sends
        }
        var %gets = not active
      }
    }
    inc %a
  }
  if (%sends = 0) return
}
on *:dialog:XDCCb:sclick:408: {
  var %a = 2
  while ($did-list(6,$did(xdccb,308,%a))) {
    var %nick = $v1
    var %network = $did-list(8,$did(xdccb,308,%a))
    var %scid = $XDCCb-network(%network)
    var %chan = $did-list(7,$did(xdccb,308,%a))
    if (!$XDCCb-onchan(%scid,%chan)) Xdccb-joinuser %nick
    inc %a
  }
}
on *:dialog:XDCCb:sclick:501: {
  tokenize 32 $did($dname,501,1)
  if ($1 = rclick) {
    if (!$did(xdccb,501).sel) return
    var %icon = $gettok($did(xdccb,501).seltext,3,32)
    var %a = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPCreateMenu,XDCCB501),2,32)
    MPopup MPAddIcon XDCCB501 > $shortfn($scriptdir\Xdccb-Icons.icl) > 4
    MPopup MPAddIcon XDCCB501 > $shortfn($scriptdir\Xdccb-Icons.icl) > 6
    MPopup MPAddIcon XDCCB501 > $shortfn($scriptdir\Xdccb-Icons.icl) > 17
    MPopup MPAddIcon XDCCB501 > $shortfn($scriptdir\Xdccb-Icons.icl) > 35
    MPopup MPAddIcon XDCCB501 > $shortfn($scriptdir\Xdccb-Icons.icl) > 36
    if ($did(xdccb,501,0).sel = 1) { 
      if (%icon = 1) mpopup MPAddItem %a > 380 5 0 Open/Run File > -
      elseif (%icon = 2) mpopup MPAddItem %a > 381 4 0 Stop download > -
    }
    mpopup MPAddItem %a > 0 0 0 - > -
    if (%icon != 2) mpopup MPAddItem %a > 382 3 0 Remove from list > -
    mpopup MPAddItem %a > 383 2 0 Clear Finished > -
    mpopup MPAddItem %a > 1 0 0 - > -
    mpopup MPAddItem %a > 384 1 0 Delete $iif($did(xdccb,501,0).sel = 1,File,Files) > -
    mpopup MPopup XDCCB501 > $mouse.dx $mouse.dy
    return 
  }
  if ($1-2 == headerclick headerEvent) {
    var %size = $hget(xdccboptions,sort)
    if ($gettok(%size,3,32) != $3) xdccb-addoption sort $gettok(%size,1-2,32) $3 u 
    else xdccb-addoption sort $puttok(%size,$iif($gettok(%size,4,32) = u,d,u),4,32)
    var %size = $hget(xdccboptions,sort)
    if ($3 = 1) {
      if ($gettok(%size,4,32) = u) {
        filter -criwt $+(2-,$did(xdccb,501).lines) 5- 32 xdccb 501 @tmpXdccb202 
        filter -co @tmpXdccb202 xdccb 501 *
      }
      else {
        filter -ecriwt $+(2-,$did(xdccb,501).lines) 5- 32 xdccb 501 @tmpXdccb202
        filter -co @tmpXdccb202 xdccb 501 *
      }
      return
    }
    elseif ($3 > 6) {
      if ($gettok(%size,4,32) = u) {
        filter -criwt $+(2-,$did(xdccb,501).lines) $3 9 xdccb 501 @tmpXdccb202 
        filter -co @tmpXdccb202 xdccb 501 *
      }
      else {
        filter -ecriwt $+(2-,$did(xdccb,501).lines) $3 9 xdccb 501 @tmpXdccb202
        filter -co @tmpXdccb202 xdccb 501 *
      }
      return
    }
    filter -criwt $+(2-,$did(xdccb,501).lines) $3 9 xdccb 501 @tmpXdccb202
    did -ra Xdccb 731 Sorting list ...
    did -a Xdccb 730 0 0 $int($calc($did(xdccb,501).lines * $log($did(xdccb,501).lines)))
    xdccb-noclose
    set %xdccb-sort-place $3
    if ($gettok(%size,4,32) = u) {
      if ($3 = 2) filter -aco @tmpXdccb202 xdccb 501 Xdccb-filter-Size730
      elseif ($3 > 3) && ($3 < 7) filter -aco @tmpXdccb202 xdccb 501 Xdccb-filter-num730
      elseif ($3 = 3)  filter -aco @tmpXdccb202 xdccb 501 Xdccb-filter-Time730
    }
    else {
      if ($3 = 2) filter -aco @tmpXdccb202 xdccb 501 Xdccb-filter-SizeD730
      elseif ($3 > 3) && ($3 < 7) filter -aco @tmpXdccb202 xdccb 501 Xdccb-filter-numD730
      elseif ($3 = 3) filter -aco @tmpXdccb202 xdccb 501 Xdccb-filter-TimeD730
    }
    did -ra Xdccb 731 Done
    did -a Xdccb 730 1 0 1
    xdccb-okclose
    unset  %xdccb-sort-place
  }
}
on *:dialog:XDCCb:dclick:501: {
  var %line = $did(xdccb,501).seltext
  run $did-list(8,%line)
}

;Corrupt files Dialog 

dialog XDCCb-c {
  title "XDCCb - Corrupt files request"
  size -1 -1 242 158

  option dbu

  list 11, 4 8 225 94, sort size hsbar
  list 13, 172 113 58 40, sort size

  box "#Incomplete on Network:", 23, 168 106 65 49

  button "Finish", 1, 4 141 48 14, ok
  button "&Add file", 2, 8 105 45 11
  button "&Remove file", 3, 8 117 45 11
  button "&Request Selected", 4, 62 117 49 11
  button "Join Network", 6, 120 109 46 14
  button "Join all", 7, 120 124 46 10
  Check "Auto Request on join", 9, 55 131 60 9

  button "Finish", 999, 1 1 1 1, hide

  Menu "Help", 800
  Item "Help", 31, 800
  Item "#Incomplete site", 32, 800
  Item Break, 33, 800
  Item "About...", 34, 800
  Item Break, 35, 800
  Item "&Donate",36, 800

}
on *:dialog:XDCCb-c:init:*: {
  mdx SetMircVersion $version
  mdx MarkDialog XDCCb-c
  mdx SetColor $dname textbg $rgb(16,252,252)

  dialogs SetControlMDX 999 positioner minbox 
  mdx SetBorderStyle 1,2,3,4,5,6,7,8 border

  views SetControlMDX XDCCb-c 11 ListView showsel report grid rowselect nosortheader infotip droptarget
  did -i XDCCb-c 11 1 headerdims 190:1 256:2
  did -i XDCCb-c 11 1 headertext File Name $chr(9) Description

  did -a XDCCb-c 13 A0HeLL
  did -a XDCCb-c 13 Asylo
  did -a XDCCb-c 13 Criten 
  did -a XDCCb-c 13 EFNet
  did -a XDCCb-c 13 Maximum-IRC
  did -a XDCCb-c 13 NoDramaIRC
  did -a XDCCb-c 13 Rizon
  did -c XDCCb-c 13 1

  var %a = $ini(%XDCCb-corrupt.ini,0)
  while (%a != 0) {
    var %file = $ini(%XDCCb-corrupt.ini,%a)
    var %desc = $readini(%XDCCb-corrupt.ini,%file,desc)
    did -a XDCCb-c 11 %file $chr(9) %desc
    dec %a
  }
  if ($hget(Xdccboptions,Auto-Corrupt) = yes ) did -c XDCCb-c 9
}
on *:dialog:XDCCb-c:sclick:2: {
  var %a = 1
  .dcc trust off
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    .dcc trust -r $+($replace(%nick,$chr(60),[,$chr(62),]),!*@*) 
    inc %a 
  }
  if ($did(11).lines > 5) return $input(ERROR - There's a limit of 5 requests at a Time... ,124, XDCC Browser)
  var %file = $sfile($getdir,Enter the corrupted file's name.. Or choose a file.)
  if (!%file) return $input(ERROR - No file name entered ! ,124, XDCC Browser)
  var %dir = $gettok($nofile(%file),-2-,92)
  if (CD* iswm $gettok(%dir,2,92)) var %dir = $replace(%dir,\,$+($chr(32),/,$chr(32)))
  else var %dir = $gettok(%dir,2,92)
  var %file = $nopath(%file)
  if ($ini(%XDCCb-corrupt.ini,%file)) return $input(ERROR - You are already requesting that file ! ,124, XDCC Browser)
  Var %desc = $input(Please enter a description for the file $+ $chr(44) and CD# at the end (if there's more then one CD),e,XDCC Browser, %dir )
  if (!%desc) return $input(ERROR - No description entered ! ,124, XDCC Browser)
  did -a XDCCb-c 11 %file $chr(9) %desc
  writeini -n $qt(%XDCCb-corrupt.ini) %file Desc %desc
  if (!$ini(%XDCCb-corrupt.ini,2)) Xdccb-c-requestall $+(0 + 0 0 0 %file, $chr(9) ,+ 0 0 0 %desc)
}
on *:dialog:XDCCb-c:sclick:3: {
  if (!$did(11).seltext) return
  var %file = $did-list(1,$did(11).seltext)
  var %a = $calc($ini(%XDCCb-corrupt.ini,%file,0) -1)
  while (%a > 0) {
    var %network = $ini(%XDCCb-corrupt.ini,%file,$calc(1 + %a))
    var %cid = $XDCCb-network(%network)
    if (%cid) && ($XDCCB-c-onchannel(%cid,#incomplete)) scid -t1 %cid /msg #incomplete !cancel $readini(%XDCCb-corrupt.ini,%file,%network)
    dec %a
  }
  remini -n $qt(%XDCCb-corrupt.ini) %file
  did -d XDCCb-c 11 $did(11).sel
}
on *:dialog:XDCCb-c:sclick:4: if ($did(11).seltext) && ($did(11).sel != 1) Xdccb-c-requestall $did(11).seltext
on *:dialog:XDCCb-c:sclick:6: XDCCb-c-connect $did(13).sel $did(13).seltext
on *:dialog:XDCCb-c:sclick:7: {
  var %a = 5
  while (%a != 0) {
    XDCCb-c-connect %a $did(13,%a)
    dec %a
  } 
}
on *:dialog:XDCCb-c:sclick:9: {
  if ($hget(Xdccboptions,Auto-Corrupt) = yes ) xdccb-addoption Auto-Corrupt no
  else xdccb-addoption Auto-Corrupt yes
}
on *:dialog:XDCCb-c:dclick:11: Xdccb-c-requestall $did(11).seltext
on *:dialog:XDCCb-c:sclick:11: {
  if ($gettok($did($did,1),1,32) = dragover) {
    did -i xdccb-c 11 1 dropeffect copy
  }
  if ($gettok($did($did,1),1,32) = drop) {
    did -i xdccb-c 11 1 page dropinfo
    var %file = $gettok($did(xdccb-c,11,1),3-,32)
    if ($isdir(%file)) return
    var %dir = $gettok($nofile(%file),-2-,92)
    if (CD* iswm $gettok(%dir,2,92)) var %dir = $replace(%dir,\,$+($chr(32),/,$chr(32)))
    else var %dir = $gettok(%dir,2,92)
    var %file = $nopath(%file)
    if ($ini(%XDCCb-corrupt.ini,%file)) return
    did -a XDCCb-c 11 %file $chr(9) %dir
    writeini -n $qt(%XDCCb-corrupt.ini) %file Desc %dir
    if (!$ini(%XDCCb-corrupt.ini,2)) Xdccb-c-requestall $+(0 + 0 0 0 %file, $chr(9) ,+ 0 0 0 %dir)
  }
}
on *:dialog:XDCCb-c:dclick:13: XDCCb-c-connect $did(13).sel $did(13).seltext
on *:dialog:XDCCb-c:menu:31: run "XDCC Browser.doc"
on *:dialog:XDCCb-c:menu:32: url -n www.incomplete.me.uk/
on *:dialog:XDCCb-c:menu:34: {
  return $input(XDCC Browser v4.50 for mIRC 6.35 $crlf $+ by Yochai Timmer <Yochai@XDCCBrowser.com> $&
    $crlf $+ www.XDCCBrowser.com $+ $crlf $+ $crlf Thanks to: $crlf All the people who send $crlf bug reports and suggestions.,124, XDCC Browser)
}
on *:dialog:XDCCb-c:menu:36: url -n https://www.paypal.com/xclick/business=Yochai%40Dorot.org.il&item_name=XDCC+Browser+Script&no_shipping=1&cn=Well%2C+what+do+you+think+%3F&tax=0&currency_code=USD

;List Control dialog

dialog XDCCb-lists {
  Title "XDCC Browser List Control"
  Size -1 -1 225 200
  Option dbu

  Tab "&Auto save", 100, -20 -14 0 0
  Tab "&View List", 200
  List 4, 7 5 218 10

  Button "OK", 1, 137 180 40 13, ok, default
  Button "Cancel", 2, 180 180 40 13, cancel
  Button "Minimizer", 3, 1 1 1 1,  hide

  ;Options 

  Button "Remove selected", 11, 138 90 80 12, Tab 100

  Text "Save every:", 15,137 50 50 8, Tab 100
  Edit "", 16,170 49 14 9, center limit 2, Tab 100
  Text "Hours", 17,187 50 80 8, Tab 100
  Check "Load lists when mIRC starts" , 18, 137 75 90 8, Tab 100
  Check "Autosave packet lists", 19, 137 62 90 8, Tab 100

  Check "Save all:", 24, 10 167 30 9
  Edit "", 25, 40 167 135 10, read
  Button "Change..", 26, 180 167 33 10

  List 27, 10 32 120 130, size sort

  Box "Autosave Lists:", 10, 7 22 126 143

  ;View List

  Button "View List...", 21, 138 30 70 12, Tab 200
  Button "Load List", 22, 138 80 70 12, Tab 200
  Button "Remove selected", 23, 138 105 70 12, Tab 200

  Text "Date made:",41,137 50 50 8, Tab 200
  Edit "", 42,167 49 40 11, read center , Tab 200
  Text "Time made:", 43,137 65 55 8, Tab 200
  Edit "", 44,167 64 40 11, read center , Tab 200

  ;Menu

  Menu "&Help", 820
  Item "Help", 821, 820
  Item Break, 822, 820
  Item "&About...", 823, 820
  Item Break, 824, 820
  Item "&Donate",825, 820
}

on *:dialog:XDCCb-lists:init:*: {
  mdx SetMircVersion $version
  mdx MarkDialog $dname

  mdx SetColor $dname textbg $rgb(16,252,252)

  dialogs SetControlMDX 3 positioner minbox 

  views SetControlMDX $dname 27 TreeView autosort haslines linesatroot hasbuttons showsel infotip insertdroptarget itemdroptarget
  did -i XDCCb-lists 27 1 iconsize normal small
  did -i XDCCb-lists 27 1 seticon normal 22, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i XDCCb-lists 27 1 seticon normal 0, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i XDCCb-lists 27 1 seticon normal 1, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)

  mdx SetBorderStyle XDCCb-lists 4,202
  bars SetControlMDX $dname 4 ToolBar flat nodivider list
  did -i XDCCb-lists 4 1 bmpsize 16 16
  did -i $dname 4 1 setimage +nh icon small 20, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i $dname 4 1 setimage +nh icon small 5, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  didtok -a $dname 4 59 +cgxW 85 1 Auto save;+cgW 85 2 View list

  did -a $dname 16 $hget(Xdccboptions,Autosave-time)
  did -a $dname 25 $readini(%Xdccb-Autosave.ini,@All,File)
  if ($readini(%Xdccb-Autosave.ini,@All,Mode) = on) {
    if ($readini(%Xdccb-Autosave.ini,@All,File)) {
      did -b $dname 27
      did -c $dname 24
    }
    else writeini -n $qt(%Xdccb-Autosave.ini) @All Mode Off
  }

  if ($hget(Xdccboptions,Load-lists) = on) did -c $dname 18 
  if ($hget(Xdccboptions,Autosave) = on) did -c $dname 19
  XDCCb-autosave-load
}
on *:dialog:XDCCb-lists:sclick:1: {
  var %text = $did(16)
  if (!%text) || (%text !isnum) || (%text <= 0) || ((%text = $hget(Xdccboptions,Autosave-time)) && ($timer(XDCCb-autosave))) return
  var %old-time = $calc($hget(Xdccboptions,Autosave-time) * 3600)
  xdccb-addoption Autosave-time $did(XDCCb-lists,16)
  if ($hget(Xdccboptions,Autosave) = on) {
    var %secs = $calc((%old-time - $timer(XDCCb-autosave).delay) + ($timer(XDCCb-autosave).delay - $timer(XDCCb-autosave).secs))
    var %time = $calc($hget(Xdccboptions,Autosave-time) * 3600)
    if ((%secs > %time) || (!$timer(XDCCb-autosave))) .timerXDCCb-autosave -i 0 %time XDCCb-autosave
    else .timerXDCCb-autosave -i 0 $calc(%time - %secs) XDCCb-autosave
  }
}
on *:dialog:XDCCb-lists:sclick:4: {
  var %sel = $did(4).sel
  if (%sel = 2) {
    if ($did(24).state = 1) did -b XDCCb-lists 27
    did -c XDCCb-lists 100
    did -f XDCCb-lists 27
    did -ra XDCCb-lists 10 Autosave Lists:
    did -i XDCCb-lists 27 1 seticon normal 1 22, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
    did -i XDCCb-lists 27 1 seticon normal 2 0, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
    did -i XDCCb-lists 27 1 seticon normal 3 1, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
    XDCCb-autosave-load
  }
  if (%sel = 3) {
    did -c XDCCb-lists 200
    did -fr XDCCb-lists 27
    did -i XDCCb-lists 27 1 seticon normal 1 0, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
    did -i XDCCb-lists 27 1 seticon normal 2 1, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
    did -i XDCCb-lists 27 1 seticon normal 3 12, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
    did -ra XDCCb-lists 10 Preview list
    did -e XDCCb-lists 27
  }
}
on *:dialog:XDCCb-lists:sclick:11: {
  var %loc = $did-tree(xdccb-lists,27).sel
  var %depth = $numtok(%loc,32)
  if (%depth = 1) {
    var %a = 1
    while ($ini(%Xdccb-Autosave.ini,%a)) {
      var %section = $v1
      var %b = 1
      while ($ini(%Xdccb-Autosave.ini,%section,%b)) {
        var %item = $v1
        var %file = $replace($readini(%Xdccb-Autosave.ini,%section,%item),$mircdir,...\)
        if (%file = $did-tree(xdccb-lists,27)) {
          remini -n $qt(%Xdccb-Autosave.ini) %section %item
          dec %b
        }
        inc %b
      }
      if ($ini(%Xdccb-Autosave.ini,%section,0) = 0) {
        remini -n $qt(%Xdccb-Autosave.ini) %section
        continue
      }
      inc %a
    }
    did -i xdccb-lists 27 1 cb root 1
    did -d xdccb-lists 27 %loc
  }
  elseif (%depth = 2) {
    var %section = $did-tree(xdccb-lists,27,$gettok(%loc,1-2,32))
    var %a = 1
    while ($ini(%Xdccb-Autosave.ini,%section,%a)) {
      var %item = $v1
      var %file = $replace($readini(%Xdccb-Autosave.ini,%section,%item),$mircdir,...\)
      if (%file = $did-tree(xdccb-lists,27,$gettok(%loc,1,32))) {
        remini -n $qt(%Xdccb-Autosave.ini) %section %item
        continue
      }
      inc %a
    }
    did -i xdccb-lists 27 1 cb root $did-tree(xdccb-lists,27).root
    did -d xdccb-lists 27 $gettok(%loc,2,32)
    if ($did-tree(xdccb-lists,27,$gettok(%loc,1,32)).lines < 1) {
      did -i xdccb-lists 27 1 cb root 1
      did -d xdccb-lists 27 $gettok(%loc,1,32)
    }
  }
  elseif (%depth = 3) {
    var %section = $did-tree(xdccb-lists,27,$gettok(%loc,1-2,32))
    var %a = 1
    while ($ini(%Xdccb-Autosave.ini,%section,%a)) {
      var %item = $v1
      if (%item = $did-tree(xdccb-lists,27)) {
        remini -n $qt(%Xdccb-Autosave.ini) %section %item
        continue
      }
      inc %a
    }
    if ($ini(%Xdccb-Autosave.ini,%section,0) = 0) remini -n $qt(%Xdccb-Autosave.ini) %section
    did -i xdccb-lists 27 1 cb root $gettok(%loc,1-2,32)
    did -d xdccb-lists 27 $gettok(%loc,3,32) 
    if ($did-tree(xdccb-lists,27,$gettok(%loc,1-2,32)).lines < 1) {
      did -i xdccb-lists 27 1 cb root $gettok(%loc,1,32)
      did -d xdccb-lists 27 $gettok(%loc,2,32)
    }
    if ($did-tree(xdccb-lists,27,$gettok(%loc,1,32)).lines < 1) {
      did -i xdccb-lists 27 1 cb root 1
      remini -n $qt(%Xdccb-Autosave.ini) $did-tree(xdccb-lists,27,$gettok(%loc,1,32))
      did -d xdccb-lists 27 $gettok(%loc,1,32)
    }
  }
}
on *:dialog:XDCCb-lists:sclick:18: xdccb-addoption Load-lists $iif($did(18).state = 1,on,off)
on *:dialog:XDCCb-lists:sclick:19: {
  var %check = $hget(Xdccboptions,Autosave)
  if ($did(19).state = 1) {
    xdccb-addoption Autosave on
    if (!$timer(xdccb-autosave)) .timerXDCCb-autosave -i 0 $calc($hget(Xdccboptions,Autosave-time) * 3600) XDCCb-autosave
    if ($dialog(xdccb)) did -c xdccb 393
  }
  else {
    xdccb-addoption Autosave off
    if ($timer(xdccb-autosave)) .timerXDCCb-autosave off
    if ($dialog(xdccb)) did -u xdccb 393
  }
}

on *:dialog:XDCCb-lists:sclick:21: XDCCbview-file
on *:dialog:XDCCb-lists:sclick:22: {
  if (!$isfile($did(Xdccb-lists,10))) return
  Xdccb-loadlist $did(Xdccb-lists,10)
}
on *:dialog:XDCCb-lists:sclick:23: {
  var %loc = $did-tree(xdccb-lists,27).sel
  var %depth = $numtok(%loc,32)
  var %file = $did(Xdccb-lists,10)
  var %section = $+(xdccb-,$did-tree(xdccb-lists,27,$gettok(%loc,1,32)))
  if (!$isfile(%file)) return
  if (%depth = 2) {
    var %chan = $did-tree(xdccb-lists,27,$gettok(%loc,1-2,32))
    var %a = 2
    did -i xdccb-lists 27 1 cb root $did-tree(xdccb-lists,27).root
    did -d xdccb-lists 27 $gettok(%loc,2,32)
    if ($did-tree(xdccb-lists,27,$gettok(%loc,1,32)).lines < 1) {
      did -i xdccb-lists 27 1 cb root 1
      did -d xdccb-lists 27 $gettok(%loc,1,32)
    }
    while ($did-tree(xdccb-lists,27,%loc %a)) {
      var %nick = $replace($v1,[,$chr(60),],$chr(62))
      while ($readiniwm(%file,%section,$+(%nick,˙*),1).sec) {
        dll $qt($scriptdir\WhileFix.dll) WhileFix 
        remini -n %file %section $v1
      }
      inc %a
    }
  }
  elseif (%depth = 3) {
    var %nick = $replace($did-tree(xdccb-lists,27),[,$chr(60),],$chr(62))
    did -i xdccb-lists 27 1 cb root $gettok(%loc,1-2,32)
    did -d xdccb-lists 27 $gettok(%loc,3,32) 
    if ($did-tree(xdccb-lists,27,$gettok(%loc,1-2,32)).lines < 1) {
      did -i xdccb-lists 27 1 cb root $gettok(%loc,1,32)
      did -d xdccb-lists 27 $gettok(%loc,2,32)
    }
    if ($did-tree(xdccb-lists,27,$gettok(%loc,1,32)).lines < 1) {
      did -i xdccb-lists 27 1 cb root 1
      remini -n %file $did-tree(xdccb-lists,27,$gettok(%loc,1,32))
      did -d xdccb-lists 27 $gettok(%loc,1,32)
    }
    while ($readiniwm(%file,%section,$+(%nick,˙*),1).sec) {
      dll $qt($scriptdir\WhileFix.dll) WhileFix 
      remini -n %file %section $v1
    }
  }
  if ($ini(%file,%section,0) = 0) || (%depth = 1) {
    remini -n %file %section
    if  ($lines(%file) = 0) {
      .remove %file
      did -ra XDCCb-lists 10 Preview list
    }
    if (%depth = 1) {
      did -i xdccb-lists 27 1 cb root 1
      did -d xdccb-lists 27 %loc
    }
  }
}
on *:dialog:XDCCb-lists:sclick:24: {
  if ($did(24).state = 1) {
    if (!$readini(%Xdccb-Autosave.ini,@All,File)) {
      did -u XDCCb-lists 24
      return
    }
    writeini -n $qt(%Xdccb-Autosave.ini) @All Mode On
    if ($dialog(XDCCb-lists).tab = 100) did -b XDCCb-lists 27
  }
  else {
    writeini -n $qt(%Xdccb-Autosave.ini) @All Mode Off
    if ($dialog(XDCCb-lists).tab = 100) did -e XDCCb-lists 27
  }
}
on *:dialog:XDCCb-lists:sclick:26: {
  var %all = $sfile($+(",$scriptdir*.xcb"),Save all lists to:,Save)
  if (%all) {
    writeini -n $qt(%Xdccb-Autosave.ini) @All File %all
    did -ra XDCCb-lists 25 %all
  }
}
on *:dialog:XDCCb-lists:*:27: {
  if ($dialog(XDCCb-lists).tab = 200) {
    tokenize 32 $did($did,1)
    if ($1 = dragover) {
      did -i XDCCb-lists 27 1 dropeffect copy
    }
    if ($1 = drop) && ($2 = dragDrop)  {
      did -i XDCCb-lists 27 1 page dropinfo 
      var %file = $gettok($did(XDCCb-lists,27,1),3-,32)
      if ($gettok(%file,-1,46) != xcb) || (!$isfile(%file)) return
      XDCCbview-file %file
    }
  }
  elseif ($gettok($did($did,1),1,32) = dragover) did -i XDCCb-lists 27 1 dropeffect none  
}
on *:dialog:XDCCb-lists:menu:821: run $qt($scriptdirXDCC Browser.doc)
on *:dialog:XDCCb-lists:menu:823: {
  return $input(XDCC Browser v4.50 for mIRC 6.35 $crlf $+ by Yochai Timmer <Yochai@XDCCBrowser.com> $&
    $crlf $+ www.XDCCBrowser.com $+ $crlf $+ $crlf Thanks to: $crlf All the people who send $crlf bug reports and suggestions.,124, XDCC Browser)
}
on *:dialog:XDCCb-lists:menu:825: url -n https://www.paypal.com/xclick/business=Yochai%40Dorot.org.il&item_name=XDCC+Browser+Script&no_shipping=1&cn=Well%2C+what+do+you+think+%3F&tax=0&currency_code=USD

;File Server Browser Dialog

dialog Xdccb-Fserv {
  Title "XDCC Browser - File Server (XDCC Browser v4.50)"
  Size -1 -1 380 200
  Option dbu

  Button "OK", 1, -20 -20 1 1, ok, default

  Button "Minimizer", 3, 1 1 1 1,  hide

  Box "Directory", 35, 3 10 126 183, Tab 100

  List 27, 5 18 120 172, size sort , Tab 100
  List 28, 132 13 245 180, size extsel , Tab 100
  Text "[\*.*]",29,9 2 300 9

  Menu "&Help", 820
  Item "Help", 11, 820
  Item Break, 15, 820
  Item "&About...", 12, 820
  Item Break, 14, 820
  Item "&Donate",13, 820

}
on *:dialog:Xdccb-Fserv*:init:*: {
  mdx SetMircVersion $version
  mdx MarkDialog $dname

  mdx SetColor $dname textbg $rgb(16,252,252)

  dialogs SetControlMDX 3 positioner minbox 

  views SetControlMDX $dname 27 TreeView autosort haslines linesatroot hasbuttons showsel infotip

  views SetControlMDX $dname 28 ListView report showsel infotip
  did -i $dname 28 1 headerdims 316:1 70:2 100:3
  did -i $dname 28 1 headertext Filename $chr(9) Size $chr(9) File Type

  Xdccb-FservSeticon $dname 28
  Xdccb-FservSeticon2 $dname 27
  hadd xdccboptions Fsort 1 u
}
on *:dialog:Xdccb-Fserv*:close:*: {
  if ($hget(Xdccb-FileIcons)) .hfree Xdccb-FileIcons
  close -c $gettok($dname,2,61)
}
on *:dialog:Xdccb-Fserv*:menu:11: run $qt($scriptdirXDCC Browser.doc)
on *:dialog:Xdccb-Fserv*:menu:12: {
  return $input(XDCC Browser v4.50 for mIRC 6.35 $crlf $+ by Yochai Timmer <Yochai@XDCCBrowser.com> $&
    $crlf $+ www.XDCCBrowser.com $+ $crlf $+ $crlf Thanks to: $crlf All the people who send $crlf bug reports and suggestions.,124, XDCC Browser)
}
on *:dialog:Xdccb-Fserv*:menu:13: url -n https://www.paypal.com/xclick/business=Yochai%40Dorot.org.il&item_name=XDCC+Browser+Script&no_shipping=1&cn=Well%2C+what+do+you+think+%3F&tax=0&currency_code=USD
on *:dialog:Xdccb-Fserv*:sclick:28: {
  tokenize 32 $did($dname,28,1)
  if ($1-2 == headerclick headerEvent) {
    var %size = $hget(xdccboptions,Fsort)
    if ($gettok(%size,1,32) != $3) hadd xdccboptions Fsort $3 u 
    else hadd xdccboptions Fsort $puttok(%size,$iif($gettok(%size,2,32) = u,d,u),2,32)
    var %size = $hget(xdccboptions,Fsort)
    var %window = $+(@Xdccb-fserv-,$dname)
    if (!$window(%window)) window -hn %window
    if ($3 = 3) {
      if ($gettok(%size,2,32) = u) {
        filter -criwt $+(2-,$did($dname,28).lines) $3 9 $dname 28 %window *
        filter -co %window $dname 28 *
      }
      else {
        filter -ecriwt $+(2-,$did($dname,28).lines) $3 9 $dname 28 %window *
        filter -co %window $dname 28 *
      }
      close -@ %window
      return
    }
    filter -criwt $+(2-,$did($dname,28).lines) $3 9 $dname 28 %window *
    if ($gettok(%size,2,32) = u) {
      if ($3 = 1) filter -aco %window $dname 28 Xdccb-filter-Fserv
      elseif ($3 = 2) filter -aco %window $dname 28 Xdccb-filter-FservSize
    }
    else {
      if ($3 = 1) filter -aco %window $dname 28 Xdccb-filter-FservD
      elseif ($3 = 2) filter -aco %window $dname 28 Xdccb-filter-FservSizeD
    }
    close -@ %window
  }
}
on *:dialog:Xdccb-Fserv*:dclick:28: {
  var %nick = $+(=,$gettok($dname,2,61))
  msg %nick Get $replace($did-list(1,$did($dname,28).seltext),$chr(160),$chr(32))
  var %nick = $remove(%nick,=)
  var %pack
  var %a = 1
  while ($hget(%a)) {
    var %if = $v1
    if (Xdccb- isin %if) {
      var %pack = $hget(%if,$+(%nick,$chr(255),$hget(%if,$+(%nick,$chr(255),Fserv-use))))
      if (%pack) break
    }
    inc %a
  }
  var %network = $gettok(%if,2-,45)
  if (%pack) {
    Saveinfo %nick %Pack %network
    var %scid = $XDCCb-network(%network)
    if ($ini(%xdccgets.ini,DCC˙Allow,$gettok(%network,1,46))) scid -t1 %scid /.DCCALLOW $+(+,%user)
    if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust $+(%user,!*@*)
  }
}
on *:dialog:Xdccb-Fserv*:sclick:27: {
  var %loc = $did-tree($dname,27).sel
  var %nick = $+(=,$gettok($dname,2,61))
  var %dir = $right($left($did($dname,29),-4),-1)
  var %len-loc = $numtok(%loc,32)
  var %len-dir = $numtok(%dir,92)
  var %cds = 0
  var %pos = $calc(%len-dir - %cds)
  var %a = 1
  while ($gettok(%dir,%a,92) = $replace($did-tree($dname,27,$gettok(%loc,$+(1-,$calc(%a +1)),32)),$chr(160),$chr(32))) {
    if (!$v2) break
    inc %cds
    inc %a
  }
  var %a = %len-dir
  while (%a != %cds) {
    did -ra $dname 29 $deltok($did($dname,29),-2,92)
    msg %nick cd.. 
    dec %a
  }
  var %a = $calc(%cds +2)
  while (%a <= %len-loc) {
    var %dir = $replace($did-tree($dname,27,$gettok(%loc,$+(1-,%a),32)),$chr(160),$chr(32))
    did -ra $dname 29 $instok($did($dname,29),%dir,-1,92)
    msg %nick cd %dir
    inc %a
  }
  hadd xdccboptions Fsort 1 u
  did -r $dname 28
  msg %nick dir
  dialog -t $dname $+($gettok($dname,2,61),'s) File Server (XDCC Browser v4.50)
  set $+(%,=,$gettok($dname,2,61),Start) Start
  $+(.timer,%dialog) off
}

;Dialog Processbar

dialog Xdccb-Processbar {
  title "Processing packet list"
  size -1 -1 150 20
  option dbu
  text "Text Label", 1, 9 5 132 10
  button "No close", 2, -1 -1 0 0
  button "Ok", 3, -1 -1 0 0, ok
}
on *:dialog:Xdccb-Processbar*:init:*:{
  mdx SetMircVersion $version
  mdx MarkDialog $dname
  mdx SetDialog Processbar style title
  ctl_gen SetControlMDX 1 ProgressBar
  dialogs SetControlMDX 2 Positioner noclose
}

;Edit dialog

dialog Xdccb-edit {
  Title "Edit pack information"
  Size -1 -1 200 75
  Option dbu

  Button "Save", 1, 50 59 42 13, ok, default
  Button "Cancel", 2, 100 59 42 13, cancel

  Text "" ,30, -1 -1 0 0

  Text "Nick:", 11,5 8 30 8
  Edit "", 21, 20 7 50 9, autohs
  Text "Channel:", 12,75 8 30 8
  Edit "", 22,100 7 50 9, autohs
  Text "Pack:", 13,5 32 30 8
  Edit "", 23,20 31 20 9, autohs
  Text "Description:", 14,45 32 30 8
  Edit "", 24,75 31 120 9, autohs
  Text "Network:", 15,5 20 30 8
  Edit "", 25,30 19 40 9, autohs
  Text "Server:", 16,75 20 30 8
  Edit "", 26,95 19 55 9, autohs
  Text "Command:", 17,5 44 30 8
  Edit "", 27,33 43 117 9, autohs


}
on *:dialog:Xdccb-edit:init:*: {
  mdx SetMircVersion $version
  mdx MarkDialog $dname
  mdx SetDialog $dname icon 47 $scriptdirxdccb-icons.icl
}
on *:dialog:Xdccb-edit:sclick:1: {
  var %pack-num = $did(23)
  if (%pack-num !isnum) return
  var %xdccgets.ini = $qt(%xdccgets.ini)
  var %nick = $replace($did(21),[,$chr(60),],$chr(62))
  var %old-packnum = $gettok($did(30),2,32)
  if (%old-packnum != %pack-num) && ($readiniwm(%xdccgets.ini,%nick,$+(Pack,%pack-num),1).line) return
  var %oldnick = $replace($gettok($did(30),1,32),[,$chr(60),],$chr(62))
  if (%nick != %oldnick) {
    var %check = $read(%xdccgets.ini,w,$+([,%oldnick,]))
    write $+(-l,$readn) %xdccgets.ini $+([,%nick,])
  }
  var %pack = $did(24) $chr(9) %pack-num $chr(9) $gettok($did(30),3,32)
  var %new-line = $readiniwm(%xdccgets.ini,%nick,$+(Pack,%old-packnum),1).line
  write $+(-l,%new-line) %xdccgets.ini $+(Pack,%Pack-num,=,%Pack)
  write $+(-l,$calc(%new-line + 1)) %xdccgets.ini $+(Date,%Pack-num,=,$Date)
  write $+(-l,$calc(%new-line + 2)) %xdccgets.ini $+(Time,%Pack-num,=,$Time)
  var %chan = $did(22)
  var %network = $did(25)
  var %server = $did(26)
  var %usage = $did(27)
  var %scid = $XDCCb-network(%network)
  if ($xdccb-chankey(%scid,%chan)) writeini %xdccgets.ini %nick Key $v1
  writeini %xdccgets.ini %nick Chan %chan
  writeini %xdccgets.ini %nick Network %network
  writeini %xdccgets.ini %nick Server %server
  if (msg isin $gettok(%usage,1,32)) writeini %xdccgets.ini %nick Usage /.msg $did(21) $gettok(%usage,3-,32)
  elseif (ctcp isin $gettok(%usage,1,32)) writeini %xdccgets.ini %nick Usage /.ctcp $did(21) $gettok(%usage,3-,32)
  Xdccb-Hashnick %nick
  var %oldnick = $gettok($did(30),1,32)
  var %nick = $did(21)
  if ($timer($+(XDCCB-,%oldnick))) {
    var %secs = $timer($v1).secs
    if ($remove($gettok($timer($v1).com,3,32),$chr(35)) == %old-packnum) {
      var %com = XDCCb-request-Pack %nick $+($chr(35),%pack-num) %scid %network %pack
      $+(.TimerXDCCB-,%nick) 1 %secs %com
      if (%oldnick != %nick) $+(.TimerXDCCB-,%oldnick) off
    }
  }
  xdccr8
}
menu nicklist,query {
  XDCC &Browser
  .&Browser: { 
    if (!$dialog(XDCCb)) XDCCb 
    else {
      did -a xdccb 3 Show
      dialog -v xdccb
    }
  }
  .&Corrupt files finder: { 
    if (!$dialog(XDCCb-c)) dialog -m XDCCb-c XDCCb-c
    else dialog -v XDCCb-c
  }
  .&List control {
    if (!$dialog(XDCCb-lists)) dialog $hget(Xdccboptions,Mode) XDCCb-lists XDCCb-lists
  }
  .-
  .&Send XDCC List: {
    var %ontop
    if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
      dialog -n xdccb
      var %ontop = yeap
    }
    var %file = $sfile($+(",$scriptdir*.xcb"),Choose a list to send:,Send)
    if (%file) .dcc send $1 %file
    if (%ontop) dialog -o xdccb
  }
  .&Request XDCC List: {
    var %a = 1
    while ($eval($+($,%a),2)) {
      .timer 1 %a $hget(Xdccboptions,Request) $v1 XDCC list
      inc %a
    }
  }
  . $iif($gettok($hmatch($+(XDCCb-,$gettok($network,1,46)),$+($1,$chr(255),*),1),1,255) = $1,&Show Packs ) : {
    XDCCb
    XDCCb27
    did -c XDCCb 27 $didwm(XDCCb,27,$1)
    XDCCb28
    filter -criw $+(2-,$did(xdccb,28).lines) xdccb 28 @tmpXdccb28 *
    filter -cot 1 9 @tmpxdccb28 xdccb 28 * 
  }
  . $iif($gettok($hmatch($+(XDCCb-,$gettok($network,1,46)),$+($1,$chr(255),*),1),1,255) = $1,&Remove from Queue ) : {
    var %scid = $gettok($Xdccb-getscid,1,32)
    scid -t1 %scid $hget(Xdccboptions,Request) $1 XDCC remove
    if ($ini(%xdccgets.ini,DCC˙Allow,$gettok($network,1,46))) .DCCALLOW $+(-,$1)
    if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust -r $+($1,!*@*)
  }
  .- 
  .Request Pack number..: {
    var %nick = $replace($1,[,$chr(60),],$chr(62))
    var %Packs = $remove($?="What number Pack do you want to request ????",$chr(35))
    if (!%packs) return
    var %desc = $?="What description do you want to give the Pack ?"
    var %a = 1
    while ($gettok(%packs,%a,44)) {
      var %pack = $v1
      if ($chr(45) isin %pack) {
        var %low = $gettok(%pack,1,45)
        var %high = $gettok(%pack,2,45)
        if ((%low isnum) && (%high isnum)) && (%low < %high) {
          while (%low <= %high) {
            if (%desc) var %desc2 = $+(%low,$chr(46) %desc)
            else var %desc2 = Requesting Pack no. %low
            dll $qt($scriptdir\WhileFix.dll) WhileFix
            saveinfo $1 %desc2 $chr(9) %low $chr(9) n/a $network
            if ($hget($+(Xdccbhash-,%nick),Get) >= $hfind($+(Xdccbhash-,%nick),pack*,0,w)) $+(.TimerXDCCB-,$1) 1 2 XDCCb-request-Pack $1 $+($chr(35),%low) $cid $network %desc2 $chr(9) %low $chr(9) n/a
            inc %low
          }
        }
        inc %a
        continue
      }
      elseif (%Pack isnum) {
        if (%desc) var %desc2 = $+(%pack,$chr(46) %desc)
        else var %desc2 = Requesting Pack no. %pack
        saveinfo $1 %desc2 $chr(9) %pack $chr(9) n/a $network
        if ($hget($+(Xdccbhash-,%nick),Get) >= $hfind($+(Xdccbhash-,%nick),pack*,0,w)) $+(.TimerXDCCB-,$1) 1 2 XDCCb-request-Pack $1 $+($chr(35),%Pack) $cid $network %desc $chr(9) %pack $chr(9) n/a
      }
      else return $input(Invalid Pack number !,124, XDCC Browser) 
      inc %a
    }
  }
  .-
  . $iif($gettok($hmatch($+(XDCCb-,$gettok($network,1,46)),$+($1,$chr(255),*),1),1,255) = $1,&Get Pack.... ) 
  .. $Submenu($Nicklist-Packs($1)) 
}
menu channel,status,menubar {
  XDCC &Browser
  .&Browser: { 
    if (!$dialog(XDCCb)) XDCCb 
    else {
      did -a xdccb 3 Show
      dialog -v xdccb
    }
  }
  .&Corrupt files finder: { 
    if (!$dialog(XDCCb-c)) dialog -m XDCCb-c XDCCb-c
    else dialog -v XDCCb-c
  }
  .&List control {
    if (!$dialog(XDCCb-lists)) dialog $hget(Xdccboptions,Mode) XDCCb-lists XDCCb-lists
  }
  .-
  .Search for XDCC
  ..XDCC Report: {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n www.xdccreport.com/search.php?&kw= $+ %search $+ &page=1
  }
  ..XDCCing: {
    var %search = $?="What are you searching for ??" 
    if (%search) url -n http://www.xdccing.com/ $+ %search
  }
  ..XDCC Finder {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://www.xdccfinder.com/results.php?search= $+ %search
  }
  ..SearchXDCC {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://www.searchxdcc.com/xdccsearch.php?Description= $+ %search $+ &x=0&y=0
  }
  ..-
  ..Search all {
    var %search = $?="What are you searching for ??" 
    var %search = $replace(%search,$chr(32),$chr(43))
    url -n www.xdccreport.com/search.php?&kw= $+ %search $+ &page=1
    .timer 1 2 url http://www.xdccing.com/ $+ %search
    .timer 1 2 url http://www.xdccfinder.com/results.php?search= $+ %search
    .timer 1 3 url http://www.searchxdcc.com/xdccsearch.php?Description= $+ %search $+ &x=0&y=0
  }
  .Search for channel
  ..Netsplit {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://irc.netsplit.de/channels/?query= $+ %search $+ &op23=modload&name3=mdSearch&file3=index&submit4=Go
  }
  ..Search IRC {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://searchirc.com/search.php?I= $+ %search $+ &Submit=Go
  }
  .-
  . $iif($chan,Request list from all bots) : XDCC-RequestList $chan
  . $iif($timerwm(xdcc-list*),Stop bots list request): .timerxdcc-list* off
}
menu @XDCCB Stats {
  dclick: XDCCb
  sclick: {
    var %window = $+(@XDCCB,$chr(160),Stats)
    var %font = tahoma 12
    var %hight = $calc($height(x,tahoma,12) +1)
    var %width = $window(%window).w
    if (($mouse.x >= 0 && $mouse.x <= $calc(%width /2)) && ($mouse.y >= $calc(%hight *3) && $mouse.y <= $calc(%hight *4))) {
      run $iif($exists($hget(Xdccboptions,Finish)),$hget(Xdccboptions,Finish),$getdir)
    }
  }
  &Open Finished folder: run $iif($exists($hget(Xdccboptions,Finish)),$hget(Xdccboptions,Finish),$getdir)
  &Browser: { 
    if (!$dialog(XDCCb)) XDCCb 
    else {
      did -a xdccb 3 Show
      dialog -v xdccb
    }
  }
  &List control {
    if (!$dialog(XDCCb-lists)) dialog $hget(Xdccboptions,Mode) XDCCb-lists XDCCb-lists
  }
  -
  .Search for XDCC
  ..XDCC Report: {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n www.xdccreport.com/search.php?&kw= $+ %search $+ &page=1
  }
  ..XDCCing: {
    var %search = $?="What are you searching for ??" 
    if (%search) url -n http://www.xdccing.com/ $+ %search
  }
  ..XDCC Finder {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://www.xdccfinder.com/results.php?search= $+ %search
  }
  ..SearchXDCC {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://www.searchxdcc.com/xdccsearch.php?Description= $+ %search $+ &x=0&y=0
  }
  ..-
  ..Search all {
    var %search = $?="What are you searching for ??" 
    var %search = $replace(%search,$chr(32),$chr(43))
    url -n www.xdccreport.com/search.php?&kw= $+ %search $+ &page=1
    .timer 1 2 url http://www.xdccing.com/ $+ %search
    .timer 1 2 url http://www.xdccfinder.com/results.php?search= $+ %search
    .timer 1 3 url http://www.searchxdcc.com/xdccsearch.php?Description= $+ %search $+ &x=0&y=0
  }
  Search for channel
  .Netsplit {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://irc.netsplit.de/channels/?query= $+ %search $+ &op23=modload&name3=mdSearch&file3=index&submit4=Go
  }
  .Search IRC {
    var %search = $replace( $?="What are you searching for ??" ,$chr(32),$chr(43))
    if (%search) url -n http://searchirc.com/search.php?I= $+ %search $+ &Submit=Go
  }
}
;Aliases 

Alias -l mdx { dll $qt($scriptdir\mdx.dll) $1- }
Alias -l ctl_gen { mdx $1- > $scriptdir\ctl_gen.mdx }
Alias -l dialogs { mdx $1- > $scriptdir\dialog.mdx }
Alias -l bars { mdx $1- > $scriptdir\bars.mdx }
Alias -l views { mdx $1- > $scriptdir\views.mdx }
Alias -l Mpopup { dll $qt($scriptdirMPopup.dll) $1- }

Alias -l addPacket {
  if ($3 = $null) return
  var %xdccgets.ini = $qt(%xdccgets.ini)
  var %server = $2
  var %chan = $3
  var %port = $4
  var %Pack = $5-
  var %network = $gettok($network,1,46)
  var %hash = $+(XDCCb-,%network)
  var %reason
  if (FTP Site: = $5) hadd -m %hash $+($1,$chr(255),FTP) $5-
  elseif (File Server !isin $6) {
    var %p-num = $remove($gettok($1-,2,9),$chr(32))
    if (!%p-num) return
    var %nick = $replace($1,[,$chr(60),],$chr(62))
    var %nick-hash = $+(Xdccbhash-,%nick)
    if ($ini(%xdccgets.ini,%nick)) && ($hget(%nick-hash,network) = %network) {
      var %a = 1   
      while ($hget(%nick-hash,$hfind(%nick-hash,Pack*,%a,w))) {
        var %pack2 = $remove($gettok($hget(%nick-hash,$v1),1,9),$chr(32))
        var %section = $gettok($v1,2,107)
        var %section2 = $remove($gettok(%pack,2,9),$Chr(32)))
        if ((%pack2 = $remove($gettok(%pack,1,9),$chr(32))) && (%section != %section2)) $& 
          || (($+(*,RequestingPackno.,*) iswm %pack2) && (%section = %section2)) {
          var %Date = $hget(%nick-hash,$+(Date,%section))
          var %Time = $hget(%nick-hash,$+(Time,%section))
          var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,%a).line
          write $+(-l,%line) %xdccgets.ini $+(Pack,%section2,=,%Pack)
          write $+(-l,$calc(%line + 1)) %xdccgets.ini $+(Date,%section2,=,%Date)
          write $+(-l,$calc(%line + 2)) %xdccgets.ini $+(Time,%section2,=,%Time)
          if ($dialog(xdccb)) {
            var %b = 2
            while ($did(xdccb,308,%b)) {
              var %v1 = $v1
              if ($did-list(6,%v1) = $1) && ($did-list(2,%v1) = %section) {
                did -o xdccb 308 $gettok(%pack,1-3,9) $chr(9) $did-list(4-,%v1)
                if (s isin $gettok(%v1,2,32)) did -c xdccb 308 %b
              }
              inc %b
            }
          }
        }
        inc %a
      }
    }
    var %table = $+($1,$chr(255),%p-num)
    var %temp = $hget(%hash,%table)
    if ($gettok(%temp,1-3,9) = $gettok(%Pack,1-3,9)) {
      if ($gettok(%temp,4,9) != $gettok(%Pack,4,9)) var %reason = gets
      else return
    } 
    if (%p-num = 1) && ( $hget(%hash) ) {
      var %a = 1
      while ($hget(%hash,$+($1,$chr(255),%a))) {
        hdel -w %hash $+($1,$chr(255),%a,*)
        inc %a
      }
    }
    if ( $hget(%hash) ) {
      hdel -m %hash %table
      hadd -m %hash %table %Pack
    }
    else hadd -m %hash %table %Pack
  }
  else {
    var %p-num = $5
    var %pack = $+($6,:) $7- $chr(9) %p-num
    if ($hget(%hash,$+($1,$chr(255),$+(File Server,%p-num))) = %pack) return
    if (%p-num = 1) && ( $hget(%hash) ) hdel -w %hash $+($1,$chr(255),File Server*)
    hadd -m %hash $+($1,$chr(255),$+(File Server,%p-num)) %pack
  }
  hadd -m $+(%hash,-data) $+($1,$chr(255),Server) %server
  hadd $+(%hash,-data) $+($1,$chr(255),Chan) %chan
  hadd $+(%hash,-data) $+($1,$chr(255),Port) %port
  if ((File Server isin $6) && ($gettok($hget(Xdccboptions,Listing),2,32) = 0)) || ((FTP Site: = $5) && ($gettok($hget(Xdccboptions,Listing),3,32) = 0)) return
  elseif ($gettok($hget(Xdccboptions,Listing),1,32) = 0) return
  if ($dialog(XDCCb)) {
    var %root = $Find-branch(xdccb,27,%network)
    var %new
    if (!%root) {
      did -a xdccb 27 +eb 1 1 %network $chr(9) Click on the network for a list of channels.
      var %root = $Find-branch(xdccb,27,%network)
    }
    var %chan-num = $Find-branch(xdccb,27,%chan,%root)
    if (!%chan-num) {
      did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
      var %chan-num = $Find-branch(xdccb,27,%chan,%root)
    }
    did -i xdccb 27 1 cb root %root %chan-num
    if (!$Find-branch(xdccb,27,$1,%root %chan-num) ) { 
      var %new = True
      did -a xdccb 27 +b 3 3 $1 $chr(9) Click on the nick for a list of packs.
    }
    did -i xdccb 27 1 cb root %root
    if ($did-tree(xdccb,27) = $1) {
      var %num = $remove(%p-num,$chr(35))
      if (%num = 1) && ( $+(*,$replace(%Pack,$chr(32),$chr(42)),*) !iswm $did(xdccb,28,$didwm(xdccb,28,$+(*,$chr(9),+*0?0?0? %p-num $chr(9),*),1))) did -r xdccb 28
      if ( $didwm(xdccb,28,$+(*,$chr(9),+*0?0?0? %p-num $chr(9),*),1) > 0) did -o xdccb 28 $v1 %Pack
      else {
        if (File Server isin %pack) did -a xdccb 28 %pack $chr(4) $hget($+(XDCCb-,%network,-data),$+($1,$chr(255),File ServT)))
        else did -a xdccb 28 %Pack $chr(9) $iif($hget($+(XDCCb-,%network,-data),$+($1,$chr(255),Queue)),$v1,n/a) $chr(9) $iif($hget($+(XDCCb-,%network,-data),$+($1,$chr(255),MaxCps)),$v1,n/a) $chr(4) Double click on a pack to request it.
      }
    }
    if (%new) did -ra XDCCb 42 $calc($did(xdccb,42) + 1)
    if (!%reason) did -ra XDCCb 44 $calc($did(xdccb,44) + 1)
  }
}
Alias -l cutbinvar {
  ;$1 is var
  ;$2 is start
  ;$3 is end
  var %len = $calc($3 - $2 +1)
  bcopy -c $1 1 $1 $2 %len 
  return
  :error
  reseterror
  bcopy -c $1 1 $1 1 1
}
Alias -l did-tree {
  var %dialog = $1
  var %id = $2
  if (!$dialog(%dialog)) return
  if ($3) {
    var %Loc = $3- 
    if ($prop = lines) {
      did -i %dialog %id 1 cb root %loc
      return $calc($did(%dialog,%id,0).lines -1)
    }
    if ($numtok(%Loc,32) = 1) did -i %dialog %id 1 cb root
    else { did -i %dialog %id 1 cb root $gettok(%loc,1- $+ $calc($numtok(%loc,32) -1),32) }
    var %line = $gettok($did(%dialog,%id,$gettok(%Loc,-1,32)),7-,32)
    if ($prop = tooltip) return $gettok(%line,2-,9)
    if ($prop = Icon) return $gettok($did(%dialog,%id,$gettok(%Loc,-1,32)),2,32)
    if ($prop = flag) return $gettok($did(%dialog,%id,$gettok(%Loc,-1,32)),1,32)
    return $gettok(%line,1,9)
  }
  var %entry = $did(%dialog,%id,1)
  if ($gettok(%entry,1,32) = slclick) var %loc = $gettok(%entry,4-,32)
  else var %loc = $gettok(%entry,3-,32)
  var %depth = $calc($numtok(%loc,32) -1)
  var %branch = $gettok(%loc,-1,32)
  if (%depth = 0) did -i %dialog %id 1 cb root 
  else did -i %dialog %id 1 cb root $gettok(%loc,1- $+ %depth,32) 
  var %line = $gettok($did(%dialog,%id,%branch),7-,32)
  if (!$prop) return $gettok(%line,1,9)
  if ($prop = root) return $gettok(%loc,1,32)
  if ($prop = sel) return %loc
  if ($prop = lines) return $calc($did(%dialog,%id,0).lines -1)
  if ($prop = len) return $len(%line)
  if ($prop = tooltip) return $gettok(%line,2-,9)
  if ($prop = event) return $gettok(%entry,1,32)
}
Alias -l did-list {
  if (- !isin $1) return $gettok($gettok($2-,$1,9),$iif($1 = 1,6-,5-),32)
  if ($gettok($1,1,45) = 1) return $gettok($remove($gettok($2-,$1,9),+fs 0 0 0,+s 0 0 0,+ 0 0 0),2-,32)
  return $remove($gettok($2-,$1,9),+fs 0 0 0,+s 0 0 0,+ 0 0 0)
}
Alias -l Find-branch {
  if (!$dialog($1)) return
  if (!$4) var %loc = 1
  else %loc = $4
  if (Xdccb-Fserv isin $1) var %word = $+(+*,$3)
  else var %word = $+(+*,$3,$chr(32),*,$chr(9),*)
  did -i $1 $2 1 cb root %loc
  return $didwm($1,$2,%word,2)
}
Alias -l Nicklist-Packs {
  if ($1 = begin) return -
  if ($1 = end) return
  var %nick = $snick($active)
  var %item = $hfind($+(XDCCb-,$gettok($network,1,46)),$+(%nick,*),$1,w).item
  var %Pack = $hget($+(XDCCb-,$gettok($network,1,46)),%item)
  if (%Pack) {
    var %num = $gettok(%item,2,255)
    var %sec = $gettok(%item,2,255)
    if (%sec != Usage) && (%sec != server) && (%sec != chan) && (%sec != port) {
      return %Pack : XDCCb-request-Pack %nick $+($chr(35),%num) $cid $network %Pack 
      Saveinfo %nick $+($iif(%num < 10,$+(0,%num),%num),.) %Pack $network
    }
  }
  return  :
}
Alias -l readiniwm {
  var %section = $+([,$2,])
  var %low = $read($1,w,%section,1)
  var %low = $readn
  if ($prop = line) && ($3 = $null) return %low
  if ($4 = $null) || ($4 < 0) return
  var %high = $read($1,w,[*],$calc(%low +1))
  var %high = $readn
  var %a = $4
  var %lines = 0
  if ($4 = 0) {
    while ($read($1,w,$+($3,=*),$calc(%low + 1))) {
      var %low = $readn
      if (%high != 0) && (%low >= %high) return %lines
      inc %lines
      inc %a
    }
    return %lines
  }  
  while (%a != 0 ) {
    var %line = $read($1,w,$+($3,=*),$calc(%low + 1))
    var %low = $readn
    if (%high != 0) && (%low >= %high) return
    dec %a
  }
  if ($prop = line) return %low
  if ($prop = sec) return $gettok(%line,1,61)
  else return $gettok(%line,2-,61)
}
Alias -l getnext {
  ;$1 is the var
  ;$2 is the tag
  ;$3 is the number of tag you want to find
  ;the functions moves the starting position of the var as a side effect.
  if ($3 isnum) var %i = $3
  else var %i = 1
  while (%i >= 1) {
    var %a = $get-tag($1,1). [ $+ [ $2 ] ]
    var %start = $gettok(%a,1,32)
    var %end = $gettok(%a,2,32)
    var %line = $bvar($1,%start,$calc(%end - %start)).text
    bcopy -c $1 1 $1 %start $calc($bvar($1,0) - %start +1)
    dec %i
  }
  return %line
  :error
  reseterror
}
Alias -l get-tag {
  ;prop is the tag.
  ;$1 is the binvar, $2 is starting position
  ;$3 is the number of tag you want to find
  if ( !$2 ) { return 0 }
  if ($3 isnum) var %i = $3
  else var %i = 1
  var %endbyte = $2
  while (%i >= 1) {
    tokenize 32 $1 %endbyte
    var %startingbyte = $bfind($1,$2,$+(<,$prop))
    if ( %startingbyte == 0 ) { return 0 }
    var %endstart = $bfind($1,%startingbyte,>)
    var %len = $calc(%endstart - %startingbyte + 1)
    var %tag = $bvar($1,%startingbyte,%len).text
    inc %startingbyte %len
    if ( !$regex(%tag,/^<[^<]+>/) ) { return 0 }
    var %endbyte = $bfind($1,%startingbyte,$+(</,$prop,>))
    dec %i
  }
  return %startingbyte %endbyte
  :error | reseterror | return 0
}
alias -l GetEnvStr {
  .comopen env WScript.Shell
  var %r = $com(env,ExpandEnvironmentStrings,3,bstr,$+(%,$1,%))
  if (%r) %r = $com(env).result
  .comclose env
  return $iif(%r == $+(%,$1,%),$null,%r)
}
alias -l parsesearchxdcc {
  if ($dialog(xdccb)) did -ra xdccb 211,711 Getting results
  var %file = $qt($scriptdir\search.tmp)
  bread %file 1 $file(%file).size &xdccbparse
  var %sizecompare = $hget(Xdccboptions,Search-Size)
  var %compare = $iif($gettok(%size,1,44) = 1,<,>)
  var %sizecompare = $calc($gettok(%sizecompare,2,44) * (1024 ^ $gettok(%sizecompare,3,44)))
  var %total = $getnext(&xdccbparse,strong)
  if (($dialog(xdccb)) && ($gettok($did(xdccb,710),3,32) == 1)) did -a Xdccb 710 0 0 %total
  noop $getnext(&xdccbparse,td)
  while ($getnext(&xdccbparse,td)) {
    var %line = $v1
    if (color="#FFFFFF" isin %line) {
      var %line = $regsubex(%line,/(<[^>.]*>)/g,)
      if (Network: isin %line) var %network = $gettok(%line,2,32)
      elseif (Channel: isin %line) var %chan = $gettok(%line,2,32)
      elseif (Bot: isin %line) var %nick = $gettok(%line,2,32)
    }
    elseif (Pack</strong> isin %line) noop $getnext(&xdccbparse,td,8)
    else {
      var %usage = $gettok(%line,2,39)
      var %server = $gettok(%line,3,47)
      var %packN = $int($remove($getnext(&xdccbparse,a),$chr(35)))
      var %size = $getnext(&xdccbparse,td)
      if (%size = N/A) var %size = n/a 
      var %cps = $getnext(&xdccbparse,td)
      noop $getnext(&xdccbparse,td,2)
      var %gets = $getnext(&xdccbparse,td)
      if (%gets = NA) var %gets = n/a 
      noop $getnext(&xdccbparse,td,2)
      var %slots = $getnext(&xdccbparse,font)
      if (%slots = NA) var %slots = n/a 
      var %pack = $getnext(&xdccbparse,td)
      if (%pack) && (%server) && ($dialog(xdccb) && ($Xdccb-Calcsize(%size) %compare %sizecompare)) {
        did -a xdccb 207 + 0 0 0 $replace($replace(%pack,$chr(32),$chr(160)) $chr(9) %packN $chr(9) %size $chr(9) %gets $chr(9) %slots $chr(9) %cps $chr(9) %nick $chr(9) %chan $chr(9) %network $chr(9) %server $chr(4) %usage,&nbsp;,$chr(32),&quot;,",&lt;,<,&gt;,>)
      }
    }
  }
}
alias -l parsexdccfinder {
  if ($dialog(xdccb)) did -ra xdccb 211,711 Getting results
  var %file = $qt($scriptdir\search.tmp)
  bread %file 1 $file(%file).size &xdccbparse
  var %sizecompare = $hget(Xdccboptions,Search-Size)
  var %compare = $iif($gettok(%size,1,44) = 1,<,>)
  var %sizecompare = $calc($gettok(%sizecompare,2,44) * (1024 ^ $gettok(%sizecompare,3,44)))
  if ($dialog(xdccb)) {
    if ($gettok($did(xdccb,710),3,32) == 1) {
      var %total = $gettok($gettok($getnext(&xdccbparse,td),3,62),2,32)
      did -a Xdccb 710 0 0 %total
    }
  }
  var %a = $get-tag(&xdccbparse,1).table
  cutbinvar &xdccbparse $gettok(%a,1,32) $bvar(&xdccbparse,0)
  noop $getnext(&xdccbparse,td,6)
  while ($getnext(&xdccbparse,td)) {
    var %pack = $gettok($v1,1,60)
    noop $getnext(&xdccbparse,td)
    var %network = $gettok($getnext(&xdccbparse,a),1,46)
    noop $getnext(&xdccbparse,td)
    var %chan = $getnext(&xdccbparse,a)
    var %size = $getnext(&xdccbparse,td)
    var %cps = $getnext(&xdccbparse,td)
    if (N/A isin %cps) var %cps = n/a
    var %line = $getnext(&xdccbparse,td)
    var %usage = $gettok(%line,2,39)
    var %server = $gettok(%line,3,47)
    var %chan = $gettok($gettok(%line,4,47),1,34)
    var %nick = $gettok(%usage,2,32)
    var %packN = $remove($getnext(&xdccbparse,a),$chr(35))
    if (%pack) && (%server) && ($dialog(xdccb) && ($Xdccb-Calcsize(%size) %compare %sizecompare)) {
      did -a xdccb 207 + 0 0 0 $replace($replace(%pack,$chr(32),$chr(160)) $chr(9) %packN $chr(9) %size $chr(9) n/a $chr(9) n/a $chr(9) %cps $chr(9) %nick $chr(9) $+($chr(35),%chan) $chr(9) %network $chr(9) %server $chr(4) %usage,&nbsp;,$chr(32),&quot;,",&lt;,<,&gt;,>)
    }
    noop $getnext(&xdccbparse,td,5)
  }
}
alias -l parsexdccreport {
  if ($dialog(xdccb)) did -ra xdccb 211,711 Getting results
  var %file = $qt($scriptdir\search.tmp)
  bread %file 1 $file(%file).size &xdccbparse
  var %sizecompare = $hget(Xdccboptions,Search-Size)
  var %compare = $iif($gettok(%size,1,44) = 1,<,>)
  var %sizecompare = $calc($gettok(%sizecompare,2,44) * (1024 ^ $gettok(%sizecompare,3,44)))
  var %total = $gettok($getnext(&xdccbparse,div,6),3,62)
  if (($dialog(xdccb)) && ($gettok($did(xdccb,710),3,32) == 1)) did -a Xdccb 710 0 0 $ceil($calc(%total /30))
  var %a = $get-tag(&xdccbparse,1).table
  cutbinvar &xdccbparse $gettok(%a,1,32) $bvar(&xdccbparse,0)
  while ($getnext(&xdccbparse,td)) {
    var %pack = $gettok($regsubex($v1,/(<[^>.]*>)/g,),1,60)
    var %size = $getnext(&xdccbparse,td)
    var %cps = $getnext(&xdccbparse,td)
    if (N/A isin %cps) var %cps = n/a
    var %line = $getnext(&xdccbparse,td)
    var %usage = $gettok(%line,2,39)
    var %server = $gettok(%line,3,47)
    var %network = $gettok(%server,2,46)
    var %chan = $gettok($gettok(%line,4,47),1,34)
    var %nick = $gettok(%usage,2,32)
    var %packN = $remove($getnext(&xdccbparse,a),$chr(35))
    if (%pack) && (%server) && ($dialog(xdccb) && ($Xdccb-Calcsize(%size) %compare %sizecompare)) {
      did -a xdccb 207 + 0 0 0 $replace($replace(%pack,$chr(32),$chr(160)) $chr(9) %packN $chr(9) %size $chr(9) n/a $chr(9) n/a $chr(9) %cps $chr(9) %nick $chr(9) $+($chr(35),%chan) $chr(9) %network $chr(9) %server $chr(4) %usage,&nbsp;,$chr(32),&quot;,",&lt;,<,&gt;,>)
    }
    noop $getnext(&xdccbparse,td)
  }
}
alias -l parsexdccing {
  if ($dialog(xdccb)) did -ra xdccb 211,711 Getting results
  var %file = $qt($scriptdir\search.tmp)
  bread %file 1 $file(%file).size &xdccbparse
  var %sizecompare = $hget(Xdccboptions,Search-Size)
  var %compare = $iif($gettok(%size,1,44) = 1,<,>)
  var %sizecompare = $calc($gettok(%sizecompare,2,44) * (1024 ^ $gettok(%sizecompare,3,44)))
  var %a = $get-tag(&xdccbparse,1,3).table
  cutbinvar &xdccbparse $gettok(%a,1,32) $bvar(&xdccbparse,0)
  var %total = $getnext(&xdccbparse,b,4)
  if (($dialog(xdccb)) && ($gettok($did(xdccb,710),3,32) == 1)) did -ra Xdccb 710 0 0 $ceil($calc(%total /100))
  var %a = $get-tag(&xdccbparse,1).table
  cutbinvar &xdccbparse %a
  noop $getnext(&xdccbparse,td,8)
  var %network
  var %chan
  while ($getnext(&xdccbparse,td)) {
    var %pack = $gettok($replace($v1,&nbsp;,$chr(32),<B>,,</B>,),1-,32)
    var %usage = $gettok($getnext(&xdccbparse,td),8,39)
    var %packN = $getnext(&xdccbparse,b)
    var %size = $replace($getnext(&xdccbparse,td),&nbsp;,$chr(32))
    var %cps = $getnext(&xdccbparse,td)
    if (- isin %cps) var %cps = n/a
    var %network = $gettok($iif($getnext(&xdccbparse,td) != &nbsp;,$getnext(&xdccbparse,a),%network),1,42)
    var %server = $xdccb-RandomServerGet($null,%network)
    var %chan = $iif($getnext(&xdccbparse,td) != &nbsp;,$getnext(&xdccbparse,a),%chan)
    var %nick = $iif($getnext(&xdccbparse,td) != &nbsp;,$v1,%nick)
    noop $getnext(&xdccbparse,td)
    if (%pack) && (%server) && ($dialog(xdccb) && ($Xdccb-Calcsize(%size) %compare %sizecompare)) {
      did -a xdccb 207 + 0 0 0 $replace($replace(%pack,$chr(32),$chr(160)) $chr(9) %packN $chr(9) %size $chr(9) n/a $chr(9) n/a $chr(9) %cps $chr(9) %nick $chr(9) $+($chr(35),%chan) $chr(9) %network $chr(9) %server $chr(4) %usage,&nbsp;,$chr(32),&quot;,",&lt;,<,&gt;,>)
    }
  }
}
Alias -l regread {
  var %a = regread
  .comopen regread WScript.Shell
  if (!$comerr) {
    var %a = $com(regread,RegRead,3,bstr,$1-)
    var %a = $com(regread).result
    .comclose regread
    return %a
  }
  if ($com(regread)) .comclose regread
}
Alias -l Saveinfo {
  var %xdccgets.ini = $qt(%xdccgets.ini)
  var %match,%pack
  var %network = [ [ $+($,$0) ] ]
  var %nick = $replace($1,[,$chr(60),],$chr(62))
  if ($hget($+(xdccb-,%network,-data),$+($1,$chr(255),server))) {
    var %Server = $hget($+(xdccb-,%network,-data),$+($1,$chr(255),server))
    var %port = $hget($+(xdccb-,%network,-data),$+($1,$chr(255),port))
    var %chan = $hget($+(xdccb-,%network,-data),$+($1,$chr(255),chan))
  }
  else {
    var %Server = $server
    var %port = $port
    var %chan = $chan
    if (!%chan) {
      var %scid = $XDCCb-network(%network)
      var %chan = $xdccb-changet(%scid,$1)
    }
  }
  if (!%chan) || (!%Server) || (!%nick) || (!%network) halt
  var %network = $gettok(%network,1,46)
  var %pack =  [ [ $+($,2-,$calc($0 -1)) ] ] 
  if (0 +*0 0 0* iswm %pack) var %Pack = $did-list(1-,$gettok($replace(%pack,$chr(61),$chr(45)),1,4))
  var %pack = $gettok(%pack,1-3,9)
  while ($gettok(%pack,1,32) = 0) { var %pack = $gettok(%pack,2-,32) }
  var %a = 1
  while ($hget($+(Xdccbhash-,%nick),$hfind($+(Xdccbhash-,%nick),Pack*,%a,w))) {
    var %temp-Pack = $v1 
    if (%temp-Pack = %Pack) var %match = %Pack
    inc %a
  }
  if (!%match) {
    var %Pack-num = $remove($gettok(%Pack,2,9),$chr(32))
    if (File server isin %pack) {
      writeini -n %xdccgets.ini %nick $+(File server,%Pack-num) %pack
    }
    else writeini -n %xdccgets.ini %nick $+(Pack,%Pack-num) %Pack
    var %scid = $XDCCb-network(%network)
    if ($xdccb-chankey(%scid,%chan)) writeini -n $+(",%xdccgets.ini,") %nick Key $v1
    writeini -n %xdccgets.ini %nick $+(Date,%Pack-num) $Date
    writeini -n %xdccgets.ini %nick $+(Time,%Pack-num) $Time
    writeini -n %xdccgets.ini %nick Chan %chan
    Xdccb-RandomServer %network %nick %server %port
    writeini -n %xdccgets.ini %nick Network %network
    writeini -n %xdccgets.ini %nick Port %port
    if ( $hget($+(XDCCb-,%network),$+($1,$chr(255),Usage)) ) {
      var %usage = $v1
      if (msg isin $gettok(%usage,1,32)) || (ctcp isin $gettok(%usage,1,32)) writeini -n %xdccgets.ini %nick Usage %usage
    }
    if (!$hget($+(Xdccbhash-,%nick),Get)) writeini -n %xdccgets.ini %nick Get 1
    Xdccb-Hashnick %nick
  }
  if ($dialog(XDCCb)) {
    if ( $didwm(xdccb,308,$+(*,$replace(%pack,$chr(9),$+(*,$chr(9),*)),*,$1,*),1) = 0 ) {
      var %stat = $Xdccb-stats($1,%network,%chan,%order)
      if (File server isin %pack) {
        did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 %pack $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) $1 $chr(9) %chan $chr(9) %network $chr(9) %server
        return
      }
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %a = $hfind($+(Xdccbhash-,%nick),Pack*,0,w)
      var %order = $iif($calc(%a - %get +1) > 0,$v1,Finished)
      var %command = did -a XDCCb 308
      if ($didwm(xdccb,308,$+(*,$chr(9),*,%Pack-num,$str($+(*,$chr(9)),4),*,$1,*),1) != 0) var %command = did -o XDCCb 308 $v1 
      %command + 8 0 0 $gettok(%stat,2,9) %pack $chr(9) $gettok(%stat,1,9) $chr(9) $ord(%order) $chr(9) $1 $chr(9) %chan $chr(9) %network $chr(9) %server
    } 
  }
}
alias -l server {
  if ($1 = -a) {
    !.server $1-
    return
  }
  if ($hget(xdccboptions,ssl) = on) {
    var %ports = +9999 +6697 +7000 +994
    var %max-reps = $gettok($readini(mirc.ini,options,n4),16,44)
    if (+ isin $port) {
      var %port = $findtok(%ports,$port,1,32)
      var %port = $gettok(%ports,$calc((%port % $numtok(%ports,32)) + 1),32)
    }
    else var %port = $gettok(%ports,$rand(1,4),32)
    if ($1 = -m) {
      if ($3 isnum) var %extra = $4-
      else var %extra = $3-
      var %server = $gettok($2,1,58)
    }
    else {
      if ($2 isnum) var %extra = $3-
      else var %extra = $2-
      var %server = $gettok($1,1,58)
    }
    var %network = $server(%server).group
    var %new-server = $xdccb-randomserverget(%server,%network)
    if (%new-server != %server) {
      var %new-server = $xdccb-randomserverget(%server,%server)
      if (%new-server != %server) var %network = %server
    }
    if ($readini(xdccb-ssl.ini,Network,%network)) {
      var %ssl-server = $v1
      var %port = $readini(xdccb-ssl.ini,Server,%ssl-server)
    }
    if ($1 = -m) {
      if (%ssl-server) !server -me %ssl-server %port %extra
      elseif (%new-server) !server -me %new-server %port %extra
      else !server -me %server %port %extra
      scon $scon(0) $+(.timerxdccbserver,$scon($scon(0))) %max-reps 19 server $2-
    }
    else {
      if (%new-server) !server -e %new-server %port %extra
      else !server -e %server %port %extra
    }
  }
  else !server $1-
}
Alias -l Timerwm {
  if (!$isid) return
  var %a = 1
  while ($timer(%a)) {
    if ($1- iswm $timer(%a)) return %a
    inc %a
  } 
}
Alias -l uPackno {
  var %Packs = 0
  var %nicks = 0
  var %a = 1
  while ($hget(%a)) {
    var %get = $v1
    if ($+(XDCCb-,*) iswm %get) && (*-data !iswm %get) {
      inc %Packs $hget(%get,0).item
      inc %nicks $hfind($+(%get,-data),$+(*,$chr(255),server),0,w)
    }
    inc %a
  }
  did -ra XDCCb 42 %nicks
  did -ra XDCCb 44 %Packs
  var %num = $calc($did(xdccb,28).lines -1)
  did -i XDCCb 28 1 headertext $iif(%num = 1,$+(%num,$chr(160),Pack),$iif(%num = 0,Packs,$+(%num,$chr(160),Packs))) $chr(9) $chr(35) $chr(9) Size $chr(9) Gets $chr(9) Queue $chr(9) Rec. CPS $chr(9) Nick
}
Alias -l XDCCb-autosave {
  var %time = $calc($hget(Xdccboptions,Autosave-time) * 3600)
  .timerXDCCb-autosave -i 0 %time XDCCb-autosave  
  var %a = 1
  var %num = 0
  if ($readini(%Xdccb-Autosave.ini,@All,Mode) = on) && ($readini(%Xdccb-Autosave.ini,@All,File)) {
    window -h @Xdccb-save
    var %file = $readini(%Xdccb-Autosave.ini,@All,File)
    .remove $qt(%file)
    var %num = 0
    while ($hget(%a)) {
      var %get = $v1
      if ($+(XDCCb-,*) iswm %get) inc %num
      inc %a
    }
    var %a = 1
    while ($hget(%a)) {
      var %if = $v1
      if (Xdccb- isin %if) {
        var %active = $appactive
        if (%active) {
          if (!$dialog(Xdccb-Processbar)) dialog -m xdccb-processbar Xdccb-Processbar
          dialog -t Xdccb-Processbar Saving list - $gettok(%if,2-,45) ...
          did -a Xdccb-Processbar 1 0 0 $hget(%if,0).item
        }
        aline @Xdccb-save $+([,%if,])
        var %b = 1
        while ($Hget(%if,%b).item) {
          dll $qt($scriptdir\WhileFix.dll) WhileFix
          var %ifmatch = $v1
          aline @Xdccb-save $+($replace(%ifmatch,[,$chr(60),],$chr(62)),=,$hget(%if,%ifmatch))
          inc %b 
          if (%active) did -a Xdccb-Processbar 1 %b
        }
      }
      inc %a
    }
    if ($dialog(Xdccb-Processbar)) dialog -nk Xdccb-Processbar
    savebuf @Xdccb-save $qt(%file)
    window -c @Xdccb-save
    return
  }
  while ($ini(%Xdccb-Autosave.ini,%a)) {
    var %section = $v1
    var %b = 1
    while ($ini(%Xdccb-Autosave.ini,%section,%b)) {
      var %item = $v1
      var %file = $readini(%Xdccb-Autosave.ini,%section,%item)
      var %hash = $+(xdccb-,%section)
      inc %num
      $+(.timerXdccbSave,%num) -i 1 $calc(%num * 60) Xdccb-autosave-save $iif(%item = File,1,2) %hash %item %file
      inc %b
    }
    inc %a
  }
}
Alias -l XDCCb-autosave-load {
  did -r xdccb-lists 27
  if (!$isfile(%Xdccb-Autosave.ini)) return
  var %a = 1
  while ($ini(%Xdccb-Autosave.ini,%a)) {
    var %section = $v1
    if (%section = @all) {
      inc %a
      continue
    }
    var %b = 1
    while ($ini(%Xdccb-Autosave.ini,%section,%b)) {
      dll $qt($scriptdir\WhileFix.dll) WhileFix
      var %item = $v1
      var %file = $replace($readini(%Xdccb-Autosave.ini,%section,%item),$mircdir,...\)
      var %root = $Find-branch(XDCCb-lists,27,%file)
      if (!%root) { 
        did -a XDCCb-lists 27 +eb 1 1 %file $chr(9) %file
        var %root = $Find-branch(XDCCb-lists,27,%file)
      }
      did -i XDCCb-lists 27 1 cb %root
      var %sec-num = $Find-branch(xdccb-lists,27,%section,%root)
      if (!%sec-num) {
        if (%item = File) did -a XDCCb-lists 27 + 2 2 %section $chr(9) Saving $+(%section,'s) Network list
        else did -a XDCCb-lists 27 +d 2 2 %section $chr(9) Saving channel lists on %section
        var %sec-num = $Find-branch(xdccb-lists,27,%section,%root)
      }
      if (%item != File) && (!$Find-branch(xdccb-lists,27,%item,%root %sec-num)) {
        did -i XDCCb-lists 27 1 cb root %root %sec-num
        did -a XDCCb-lists 27 +d 3 3 %item
        did -i XDCCb-lists 27 1 cb root %root
      }
      inc %b
    }
    did -i XDCCb-lists 27 1 cb root 1
    inc %a
  }
}
Alias -l Xdccb-autosave-save {
  var %depth = $1
  var %hash = $2
  var %item = $3
  var %file = $4-
  if ($hget(%hash)) {
    window -h @Xdccb-save
    if (!$dialog(Xdccb-Processbarsave)) dialog -m xdccb-processbarSave Xdccb-Processbar
    dialog -t Xdccb-ProcessbarSave Loading Browser Data ...
    did -a Xdccb-ProcessbarSave 1 0 0 $hget(%hash,0).item
    var %a = 1
    aline @Xdccb-save $+([,%hash,])
    if (%depth = 1) && ($hget(%hash)) {
      if ($isfile(%file)) .remove $qt(%file)
      while ($Hget(%hash,%a).item) {
        var %ifmatch = $v1
        aline @Xdccb-save $+($replace(%ifmatch,[,$chr(60),],$chr(62)),=,$hget(%hash,%ifmatch))
        inc %a 
        did -a Xdccb-ProcessbarSave 1 %a
      }
      savebuf @Xdccb-save $qt(%file)
    }
    elseif (%depth = 2) && ($hfind(%hash,%item,0).data != 0) {
      var %packs = 0
      if ($isfile(%file)) .remove $qt(%file)
      while ($hfind(%hash,%item,%a).data) {
        dll $qt($scriptdir\WhileFix.dll) WhileFix
        var %ifmatch = $v1
        var %b = 1
        while ($hfind(%hash,$+($gettok(%ifmatch,1,255),$chr(255),*),%b,w)) {
          aline @Xdccb-save $+($replace($v1,[,$chr(60),],$chr(62)),=,$hget(%hash,$v1))
          inc %b
          inc %packs
          did -a Xdccb-ProcessbarSave 1 %packs
        }
        inc %a
      }
      savebuf @Xdccb-save $qt(%file)
    }
    if ($dialog(Xdccb-ProcessbarSave)) dialog -k Xdccb-ProcessbarSave
    window -c @Xdccb-save
  }
}
Alias -l Xdccb-Calcsize return $calc($replace($remove($1,$chr(32),b,$chr(160),/,s,\,%),k,* 1024,m,* 1048576,g,* 1073741824,$chr(44),$chr(46))) 
Alias -l Xdccb-chankey {
  var %chan = $2
  scid -t1 $1 /return $eval($chan(%chan).key,0)
}
Alias -l Xdccb-Check {
  var %a = $gettok($dll($+(",$scriptdirMPopup.dll,"),MPCreateMenu,Check),2,32)
  MPopup MPAddIcon Check > $shortfn($scriptdir\Xdccb-Icons.icl) > 9
  MPopup MPAddIcon Check > $shortfn($scriptdir\Xdccb-Icons.icl) > 10
  MPopup MPAddIcon Check > $shortfn($scriptdir\Xdccb-Icons.icl) > 11
  mpopup MPAddItem %a > 3 1 1 $1 > -
  if ($2) mpopup MPAddItem %a > 4 0 1 $2 > -
  if ($3) mpopup MPAddItem %a > 5 0 0 $3 > -
  mpopup MPAddItem %a > 0 0 0 - > -
  mpopup MPAddItem %a > 1 2 0 Yes > -
  mpopup MPAddItem %a > 2 3 0 No > -
  mpopup MPMenuColor Check > RGB_GRAY > 0,0,0
  mpopup MPMenuColor Check > RGB_BACK > 16777215
  mpopup MPMenuColor Check > RGB_TEXT > 15990813
  mpopup MPMenuColor Check > RGB_HIGH > 14737632
  var %check = $dll($+(",$scriptdirMPopup.dll,"),MPopup, Check > $mouse.dx $mouse.dy)
  if (%check = 1) return $true
  elseif (%check = 2) return $false
  else halt
}
alias -l xdccb-cutfile {
  if ($1 > 0) {
    if ($1 < 102400) {
      if ($file($3-).size = $1) .remove $qt($3-)
      else btrunc $qt($3-) $calc($file($3-).size - $1)
    }
    elseif ($file($3-).size < 102400) .remove $qt($3-)
    elseif ($1 > 102400) btrunc $qt($3-) $calc($file($3-).size - 102400)
  }
}
Alias -l XDCCb-c-connect {
  var %net = $1
  if ($XDCCb-network($2)) {
    var %cid = $v1
    scid -t1 %cid /join #incomplete
    return 
  }
  if (%net = 1) server -m irc.a0hell.org -j #incomplete
  elseif (%net = 2) server -m irc.Asylo.com -j #incomplete
  elseif (%net = 3) server -m irc.criten.net -j #incomplete
  elseif (%net = 4) server -m efnet.demon.co.uk -j #incomplete
  elseif (%net = 5) server -m irc.maximum-irc.org -j #incomplete
  elseif (%net = 6) server -m irc.artificialirc.net -j #incomplete
  elseif (%net = 7) server -m irc.rizon.net -j #incomplete
}
Alias -l XDCCB-c-onchannel scid -t1 $1 if ( $!me ison $2 ) return yeap
Alias -l Xdccb-c-requestall {
  var %file = $did-list(1,$1-)
  var %desc = $did-list(2,$1-)
  var %a = 5
  while (%a != 0) {
    var %network = $did(13,%a)
    var %cid = $XDCCb-network(%network)
    if (%cid) && ($XDCCB-c-onchannel(%cid,#incomplete)) && (!$Readini(%XDCCb-corrupt.ini,%file,%network)) {
      scid -t1 %cid /msg #incomplete !Request %file / %desc
    }
    dec %a
  } 
}
Alias -l XDCCb {
  if (!$dialog(XDCCb)) dialog $hget(Xdccboptions,Mode) XDCCb XDCCb
  did -a xdccb 3 Show
  dialog -v xdccb
}
Alias -l XDCCb27 {
  if (!$dialog(xdccb)) halt
  did -r XDCCb 27
  uPackno
  var %num = $did(xdccb,42)
  did -a xdccb 700 0 0 %num
  did -ra xdccb 701 Loading Data...
  xdccb-noclose
  var %a = 1
  var %count = 0
  while ($hget(%a)) {
    var %get = $v1
    if ($+(XDCCb-,*) iswm %get) && (*-data !iswm %get) {
      inc %count
      did -ra xdccb 701 $gettok(%get,2-,45)
      XDCCb27-write %get
    }
    inc %a
  }
  var %a = 1
  while ($scon(%a)) {
    var %scid = $v1
    if (%a = 0) return  
    var %network = $gettok($scid(%scid).network,1,46)
    if ($scon(%a).status = connected) && (%network) {
      if (!$Find-branch(xdccb,27,%Network)) did -a xdccb 27 +eb 1 1 %Network $chr(9) Click on the network for a list of channels.
      var %root = $Find-branch(xdccb,27,%network)
      var %b = 1
      while ($XDCCb-ChangetMe(%scid,%b)) {
        var %chan = $v1
        if (!$Find-branch(xdccb,27,%chan,%root)) did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
        inc %b
      }
    }
    inc %a
  }
  did -ra xdccb 701 Done
  did -a Xdccb 700 1 0 1
  xdccb-okclose
}
Alias -l XDCCb27-write {
  var %hash = $1
  var %network = $remove(%hash,XDCCb-) 
  var %check = $hget(Xdccboptions,Listing)
  var %scid = $XDCCb-network(%network)
  if (($gettok(%check,1,32) = 1) && ($hfind(%hash,*˙1,1,w))) || (($gettok(%check,2,32) = 1) && ($hfind(%hash,*˙File Server*,1,w))) $&
    || (($gettok(%check,3,32) = 1) && ($hfind(%hash,*˙FTP*,1,w))) && (!$Find-branch(xdccb,27,%Network)) {
    if (%scid) did -a xdccb 27 +eb 1 1 %Network $chr(9) Click on the network for a list of channels.
    else did -a xdccb 27 +eb 4 4 %Network $chr(9) Click on the network for a list of channels.
  }
  did -i xdccb 27 1 cb root
  var %root = $Find-branch(xdccb,27,%network)
  var %a = 1 
  while ($hget($+(%hash,-data),%a).item) {
    var %v1 = $v1
    if (*˙Chan iswm %v1) {
      dll $qt($scriptdir\WhileFix.dll) WhileFix
      var %chan = $hget($+(%hash,-data),%v1)    
      var %nick = $gettok(%v1,1,255)
      if (($gettok(%check,1,32) = 1) && ($hget(%hash,$+(%nick,˙1)))) || (($gettok(%check,2,32) = 1) && ($hget(%hash,$+(%nick,˙File Server1)))) || (($gettok(%check,3,32) = 1) && ($hfind(%hash,$+(%nick,*˙FTP*),1,w))) {
        if (!$Find-branch(xdccb,27,%chan,%root)) {
          if (!%scid) || (!$XDCCb-onchan(%scid,%chan)) did -a xdccb 27 + 5 5 %chan $chr(9) Click on the channel for a list of nicks.
          else did -a xdccb 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
        }
        var %chan-num = $Find-branch(xdccb,27,%chan,%root)
        did -i xdccb 27 1 cb root %root %chan-num
        if (!%scid) || (!$XDCCb-onchan(%scid,%chan)) || (!$XDCCb-onchan(%scid,%chan,%nick)) did -a xdccb 27 +b 6 6 %nick $chr(9) Click on the nick for a list of packs.
        else did -a xdccb 27 +b 3 3 %nick $chr(9) Click on the nick for a list of packs.
        did -i xdccb 27 1 cb root %root
        did -a xdccb 700 delta 1
      }
    }
    inc %a
  }
  did -i xdccb 27 1 cb root 1
}
Alias -l XDCCb28 {
  var %a = 1
  if ($did-tree(xdccb,27).root) {
    var %net = $did-tree(xdccb,27,$v1)
    XDCCb28-write %net
  }
}
Alias -l XDCCb28-write {
  window -h @tmpXdccb28-write
  did -r XDCCb 28
  var %network = $1
  var %check = $hget(Xdccboptions,Listing)
  var %a = 1
  var %hash = $+(XDCCb-,%network)
  did -i xdccb 28 1 page headerdims
  xdccb-addoption Dims28 $gettok($did(xdccb,28,1),3-8,32)
  did -i XDCCb 28 1 headerdims $hget(Xdccboptions,Dims28)
  did -i XDCCb 28 1 headertext Pack $chr(9) $chr(35) $chr(9) Size $chr(9) Gets $chr(9) Queue $chr(9) Rec. CPS
  var %nick = $did-tree(xdccb,27)
  did -ra xdccb 701 %nick
  did -a Xdccb 700 0 0 $hfind(%hash,$+(%nick,$chr(255),*),0,w)
  while ($hfind(%hash,$+(%nick,$chr(255),*),%a,w)) {
    dll $qt($scriptdir\WhileFix.dll) WhileFix
    var %ifmatch = $v1
    var %num = $gettok(%ifmatch,$numtok(%ifmatch,255),255)
    if ((%num isnum) && ($gettok(%check,1,32) = 1)) || ((File Server isin %num) && ($gettok(%check,2,32) = 1)) || ((FTP = %num) && ($gettok(%check,3,32) = 1)) {
      if ($didwm(xdccb,28,$hget(%hash,%ifmatch),1) = 0) {
        if (FTP isin %num) aline @tmpXdccb28-write $hget(%hash,%ifmatch) $chr(4) $hget($+(%hash,-data),$+(%nick,$chr(255),FTPm))
        else aline @tmpXdccb28-write $hget(%hash,%ifmatch) $chr(9) $iif($hget($+(%hash,-data),$+(%nick,$chr(255),Queue)),$v1,n/a) $chr(9) $iif($hget($+(%hash,-data),$+(%nick,$chr(255),MaxCps)),$v1,n/a) $iif(File Server !isin %num,$chr(4) Double click on a pack to request it.,$chr(9) n/a $chr(9) n/a $chr(4) $hget($+(%hash,-data),$+(%nick,$chr(255),File ServT))))
      }
    }
    inc %a
    did -a Xdccb 700 delta 1
  }
  filter -o @tmpXdccb28-write XDCCB 28
  window -c @tmpXdccb28-write
  did -ra xdccb 701 Done
  did -a Xdccb 700 1 0 1
  uPackno
}
Alias -l xdccb202 {
  var %network = $1
  var %a = 1
  var %search = $+(*,$replace($did(xdccb,206),$chr(32),*),*)
  var %hash = $+(XDCCb-,%network)
  window -h @tmpXdccb202 
  var %size = $hget(Xdccboptions,Search-Size)
  var %compare = $iif($gettok(%size,1,44) = 1,>=,<=)
  var %size = $calc($gettok(%size,2,44) * (1024 ^ $gettok(%size,3,44)))
  while ($hget(%hash,%a).item) {
    dll $qt($scriptdir\WhileFix.dll) WhileFix
    var %item = $v1
    if (%Xdccb-searchstop) {
      did -ra xdccb 211,711 Done
      did -ra xdccb 710 1 0 1
      xdccb-okclose
      halt
    }
    var %value = $gettok($hget(%hash,%item),1,9)
    var %pack = $hget(%hash,%item)
    did -a Xdccb 710 delta 1
    if (%search iswm %value) {
      var %pack-size = $Xdccb-Calcsize($gettok(%pack,3,9))
      if (%pack-size %compare %size) {
        var %sec = $gettok(%Item,2,255)
        var %name = $gettok(%item,1,255)
        if (%sec isnum) aline @tmpXdccb202 %pack $chr(9) $iif($hget($+(%hash,-data),$+(%name,$chr(255),Queue)),$v1,n/a) $chr(9) $iif($hget($+(%hash,-data),$+(%name,$chr(255),MaxCps)),$v1,n/a) $chr(9) %name $chr(9) $hget($+(%hash,-data),$+(%name,$chr(255),Chan)) $chr(9) %network $chr(9) $hget($+(%hash,-data),$+(%name,$chr(255),Server)) $chr(4) Double click on a pack to request it.
        elseif (File Server isin %sec) aline @tmpXdccb202 %pack $chr(9) n/a $chr(9) n/a $chr(9) $iif($hget($+(%hash,-data),$+(%name,$chr(255),Queue)),$v1,n/a) $chr(9) $iif($hget($+(%hash,-data),$+(%name,$chr(255),MaxCps)),$v1,n/a) $chr(9) %name $chr(9) $hget($+(%hash,-data),$+(%name,$chr(255),Chan)) $chr(9) %network $chr(9) $hget($+(%hash,-data),$+(%name,$chr(255),Server)) $chr(4) $hget($+(%hash,-data),$+(%name,$chr(255),File ServT)))
        elseif (FTP = %sec) aline @tmpXdccb202 %pack $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) $iif($hget($+(%hash,-data),$+(%name,$chr(255),Queue)),$v1,n/a) $chr(9) $iif($hget($+(%hash,-data),$+(%name,$chr(255),MaxCps)),$v1,n/a) $chr(9) %name $chr(9) $hget($+(%hash,-data),$+(%name,$chr(255),Chan)) $chr(9) %network $chr(9) $hget($+(%hash,-data),$+(%name,$chr(255),Server)) $chr(4) $hget($+(%hash,-data),$+(%name,$chr(255),FTPm)))
      }
    }
    inc %a
  }
}
Alias -l XDCCb-Changet {
  var %nick = $2
  var %num = $3
  scid -t1 $1 /return $eval($comchan(%nick,$iif(%num,%num,1)),0)
}
Alias -l XDCCb-ChangetMe {
  var %num = $2
  scid -t1 $1 /return $eval($chan(%num),0)
}
Alias -l Xdccb-close-get {
  if ($window(@ $+ $1)) window -c @ $+ $1
}
Alias -l Xdccb-DCC {
  var %nick2 = $1
  var %ip = $2
  var %filename = $3-
  var %file = $nopath($filename)
  var %a = 1
  var %get-nick,%check
  var %xdccgets.ini = $qt(%xdccgets.ini)
  while ($get(%a)) {
    if ($get(%a).file = %file) && (($get(%a).status = active) || ($get(%a).status = waiting)) var %get-nick = $get(%a)
    inc %a
  }
  var %nick = $replace(%nick2,[,$chr(60),],$chr(62))
  var %get = $hget($+(Xdccbhash-,%nick),get)
  var %pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
  var %network = $gettok($network,1,46)
  xdccb-removeQueue %nick2 %network 
  if (%get-nick) {
    var %gets = $hfind($+(Xdccbhash-,%nick),Pack*,0,w)
    if ($calc(%gets - %get +1) > 1) {
      var %Pack-num = $remove($gettok(%Pack,2,9),$Chr(32))
      var %Date = $hget($+(Xdccbhash-,%nick),$+(Date,%pack-num))
      var %Time = $hget($+(Xdccbhash-,%nick),$+(Time,%pack-num))
      var %line = $readiniwm(%xdccgets.ini,%nick,Pack*,1).line
      var %new-line = $calc($readiniwm(%xdccgets.ini,%nick,time*,%gets).line +1)
      write $+(-il,%new-line) %xdccgets.ini $+(Pack,%Pack-num,=,%Pack)
      write $+(-il,$calc(%new-line + 1)) %xdccgets.ini $+(Date,%Pack-num,=,%Date)
      write $+(-il,$calc(%new-line + 2)) %xdccgets.ini $+(Time,%Pack-num,=,%Time)
      write $+(-dl,$calc(%line + 2)) %xdccgets.ini
      write $+(-dl,$calc(%line + 1)) %xdccgets.ini
      write $+(-dl,%line) %xdccgets.ini
      Xdccb-Hashnick %nick
      if ($dialog(xdccb)) {
        var %a = 1
        while ($did(xdccb,308,%a)) {
          var %v1 = $v1
          if ($did-list(6,%v1) = %nick2) {
            if ($did-list(5,%v1) = 1st) {
              var %check = $calc(%gets - %get +1)
              did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
            }
            elseif ($remove($did-list(5,%v1),st,nd,rd,th) > 1) {
              var %check = $calc($v1 -1)
              did -o xdccb 308 %a $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
            }
          }
          inc %a
        }
      }
      var %get = $hget($+(Xdccbhash-,%nick),get)
      var %pack = $readiniwm(%xdccgets.ini,%nick,Pack*,%get)
    }
    $+(.TimerXDCCB-,%nick2) 1 $hget(Xdccboptions,Request-Timer) XDCCb-request-Pack %nick2 $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) $cid $gettok($network,1,46) %Pack
    var %sec = $replace(%file,[,$chr(60),],$chr(62))
    if ($istok($readini(%Xdccb-Downloads.ini,%sec,Priority),%nick2,32)) {
      remini -n $qt(%Xdccb-Downloads.ini) %sec Priority
      writeini -n $qt(%Xdccb-Downloads.ini) %sec Nick %nick2
      writeini -n $qt(%Xdccb-Downloads.ini) %sec Path $nofile($3-)
      var %got = $calc($get(%get-nick).rcvd - $get(%get-nick).resume)
      var %filename = $3-
      close -g* %get-nick
      xdccb-cutfile %got %get-nick %filename
      var %size = $gettok($1-,-1,32)
      var %rcvd = $readini(%Xdccb-Downloads.ini,%sec,Rcvd)
      var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
      if ($dialog(xdccb)) {
        var %a = 2
        while ($did(xdccb,501,%a)) {
          var %v1 = $v1
          if ($did-list(1,%v1) = %file) did -o xdccb 501 %a $gettok(%v1,2,32) 2 %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) %nick2 $chr(9) $nofile($3-)
          inc %a
        }
      }
      writeini -n $qt(%Xdccb-Downloads.ini) %sec Size %size
    }
    elseif ( [ [ $+($,$0) ] ] = $get(%get-nick).size) {
      var %got = $calc($get(%get-nick).rcvd - $get(%get-nick).resume)
      var %check
      var %a = 1
      while ($isdir($+($getdircps-test,%a,\))) inc %a
      var %dir = $+($getdircps-test,%a,\)
      if (!$isdir(%dir)) .mkdir $qt(%dir)
      dcc get %dir
      $+(.timerPriority,$nick) 1 30 Xdccb-Priority %nick2 $+(%dir,%file)
    }
    else haltdef
    return
  }
  var %finishdir = $hget(Xdccboptions,Finish)
  if ($isfile($+(%finishdir,%file))) && ($getdir(%file) != %finishdir) {
    var %scid = $cid
    var %comchan = $xdccb-changet(%scid,%nick2)
    if ($hget($+(Xdccbhash-,%nick))) { 
      if ($hget(Xdccboptions,Remove) = on) {
        var %packnum = $right($readiniwm(%xdccgets.ini,%nick,pack*,%get).sec,-4)
        xdccb-remove %Nick $+(Pack,%packnum)
        xdccb-remove %Nick $+(Time,%packnum)
        xdccb-remove %Nick $+(Date,%packnum)
        if ($dialog(xdccb)) {
          var %c = 2
          while ($did(xdccb,308,%c)) {
            var %v1 = $v1
            if ($did-list(6,%v1) = %nick2) {
              if ($did-list(5,%v1) = 1st) {
                did -d XDCCb 308 %c
                dec %c
              }
              elseif ($remove($did-list(5,%v1),st,nd,rd,th) > 1) {
                var %check = $calc($v1 -1)
                did -o xdccb 308 %c $puttok($did-list(1-,%v1),$+($Chr(32),$ord(%check),$chr(32)),5,9)
              }
            }
            inc %c
          }
        }
        if ($hfind($+(Xdccbhash-,%nick),Pack*,0,w) = 0) {
          xdccb-remove %Nick
          Xdccb-Shutdown-quit %network %scid %nick2
          dec %a
          haltdef
        }
      }
      elseif (%get <= $hfind($+(Xdccbhash-,%nick),Pack*,0,w)) {
        inc %get
        writeini -n $qt(%xdccgets.ini) %nick get %get
        hadd $+(Xdccbhash-,%nick) get %get
      }
      if (%comchan) && (%pack) && (%scid) scid -t1 %scid $+(/.TimerXdccb-,%nick2) 1 $hget(Xdccboptions,Getfail-Timer) XDCCb-request-Pack %nick2 $+($chr(35),$right($readiniwm(%xdccgets.ini,%nick,Pack*,%get).sec,-4)) %scid $gettok($network,1,46) %pack
    }
    haltdef
    return
  }
  if ($len(%file) >= $calc(255 - $len(%nick2))) {
    linesep
    Echo -ts $+(,$color(info)) %nick2 $+(,$color(highlight)) tried to send you an exploit file to crash your mIRC !
    Echo -ts Stoping send connection!
    linesep
    halt
  }
  if ($gettok($1-,-4,32) isnum) && ($gettok($1-,-3,32) = 0) {
    var %lip = $gettok($1-,-4,32) 
    var %port = $gettok($1-,-1,32) 
    var %size = $gettok($1-,-2,32)
  }
  else {
    var %lip = $gettok($1-,-3,32) 
    var %port = $gettok($1-,-2,32) 
    var %size = $gettok($1-,-1,32)
  }
  if (%lip !isnum) return
  if (%port = 0) return
  if ((%lip >= 167772160) && (%lip <= 184549375)) || ((%lip >= 3232235520) && (%lip <= 3232301055)) || ((%lip >= 2886729728) && (%lip <= 2887778303)) {
    var %unable = $hget($+(Xdccbhash-,%nick),Unable)
    writeini -n $qt(%xdccgets.ini) %nick Unable $calc(%unable +1) 
    hadd $+(Xdccbhash-,%nick) Unable $calc(%unable +1)
  }
  var %a = 1
  while ($get(%a)) {
    if ($get(%a).file = %file) && ($get(%a).status = failed) Xdccb-close-get $get(%a).wid
    inc %a
  }
  var %downloads.ini = $qt(%Xdccb-Downloads.ini)
  var %sec = $replace(%file,[,$chr(60),],$chr(62))
  if (!$ini(%downloads.ini,%sec)) {
    writeini -n %downloads.ini %sec File %file
    writeini -n %downloads.ini %sec Size %size
    writeini -n %downloads.ini %sec Rcvd 0
    writeini -n %downloads.ini %sec Nick $nick
    writeini -n %downloads.ini %sec Path $nofile($filename)
    var %cps = $iif(%cps < 1024,%cps b/s,%cps Kb/s)
    if ($dialog(xdccb)) did -a xdccb 501 + 2 0 0 %File $chr(9) 0% $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) 0 $chr(9) $nick $chr(9) $nofile($filename)
  }
  else {
    writeini -n %downloads.ini %sec Nick $nick
    writeini -n %downloads.ini %sec Path $nofile($filename)
    var %rcvd = $readini(%downloads.ini,%sec,Rcvd)
    var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
    if (%size != $readini(%downloads.ini,%sec,size)) && ($dialog(xdccb)) {
      var %a = 2
      while ($did(xdccb,501,%a)) {
        var %v1 = $v1
        if ($did-list(1,%v1) = %file) did -o xdccb 501 %a $gettok(%v1,2,32) 2 %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) $nick $chr(9) $nofile($filename)
        inc %a
      }
    }
    writeini -n %downloads.ini %sec Size %size
  }
}
Alias -l xdccb-downloads-load {
  var %Xdccb-Downloads.ini = $qt(%Xdccb-Downloads.ini) 
  var %a = 1 
  while ($get(%a)) {
    var %sec = $replace($get(%a).file,[,<,],>)
    if (!$ini(%Xdccb-Downloads.ini,%sec)) && ($get(%a).status = active) {
      writeini -n %Xdccb-Downloads.ini %sec File $get(%a).file
      var %size = $gettok($1-,-1,32)
      writeini -n %Xdccb-Downloads.ini %sec Size $get(%a).size
      writeini -n %Xdccb-Downloads.ini %sec Rcvd $get(%a).rcvd
      writeini -n %Xdccb-Downloads.ini %sec Nick $get(%a)
      writeini -n %Xdccb-Downloads.ini %sec Path $get(%a).path
    }
    inc %a
  }
  var %a = 1
  while ($ini(%Xdccb-Downloads.ini,%a)) {
    var %sec = $v1
    var %rcvd = $readini(%Xdccb-Downloads.ini,%sec,Rcvd)
    if (%rcvd = Delete) {
      remini -n %Xdccb-Downloads.ini %sec
      continue
    }
    var %file = $readini(%Xdccb-Downloads.ini,%sec,File)
    var %path = $readini(%Xdccb-Downloads.ini,%sec,Path)
    if ($isfile($+(%path,%file))) {
      writeini -n %Xdccb-Downloads.ini %sec Rcvd $file($+(%path,%file)).size
      var %size = $readini(%Xdccb-Downloads.ini,%sec,Size)
      var %rcvd = $readini(%Xdccb-Downloads.ini,%sec,Rcvd)
      var %nick = $readini(%Xdccb-Downloads.ini,%sec,Nick)
      var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
      var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
      if (%size = %rcvd) var %icon = 1
      else var %icon = $iif(!$ini(%xdccgets.ini,%nick2),4,3)
      did -a xdccb 501 + %icon 0 0 %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) %nick $chr(9) %Path
    }
    else remini %Xdccb-Downloads.ini %sec
    inc %a
  }
}
Alias -l Xdccb-fileicon {
  if ($hget(Xdccb-FileIcons,$1)) return $v1
  var %root = $GetEnvStr(SystemRoot)
  var %icon = $regread($+(HKEY_CLASSES_ROOT\.,$1,\DefaultIcon\))
  if (!%icon) var %icon = $regread($+(HKEY_CLASSES_ROOT\,$regread($+(HKEY_CLASSES_ROOT\.,$1,\)),\DefaultIcon\))
  if ($+(%,*,%) iswm $gettok(%icon,1,92) ) var %icon = $+($GetEnvStr($gettok($v2,1,37)),\,$gettok(%icon,2-,92))
  if (!%icon) var %icon = $+(%root,\,system32\SHELL32.dll,$chr(44),0)
  var %file = $gettok(%icon,1,44)
  if (%file = $+($chr(37),1)) var %icon = $+(%root,\,system32\SHELL32.dll,$chr(44),2)
  elseif ($exists($+(%root,\system32\,%file))) var %icon = $puttok(%icon,$+(%root,\system32\,%file),1,44)
  elseif (!$exists(%file)) var %icon = $+(%root,\,system32\SHELL32.dll,$chr(44),0)
  var %num = $gettok(%icon,2,44)
  if (!%num) var %num = 0
  var %file = $shortfn($gettok(%icon,1,44))
  var %b = 1
  while ($dialog(%b)) {
    var %dialog = $v1
    if (Xdccb-Fserv* iswm %dialog) {
      if (%icon = $+(%,1)) did -i %dialog 28 1 seticon normal 0 $+(2,$chr(44),$GetEnvStr(SystemRoot),\,system32\SHELL32.dll)
      else did -i %dialog 28 1 seticon normal 0 $+(%num,$chr(44),%file)
    }
    inc %b
  }
  var %icon = $calc($hget(Xdccb-FileIcons,0).item +1)
  hadd -m Xdccb-FileIcons $1 %icon
  return %icon
}
Alias -l Xdccb-filter-Fserv {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $did-list(1,$2) 
  var %a = $did-list(1,$1)
  var %return = $iif(%b > %a,-1,$iif(%a > %b,1,0))
  return %return
}
Alias -l Xdccb-filter-FservD {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $did-list(1,$2) 
  var %a = $did-list(1,$1)
  var %return = $iif(%b > %a,1,$iif(%a > %b,-1,0))
  return %return
}
Alias -l Xdccb-filter-FservSize {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $Xdccb-Calcsize($gettok($2,2,9))
  if (n isin %a) || (%b !isnum) return -1
  var %a = $Xdccb-Calcsize($gettok($1,2,9))
  if (n isin %a) || (%a !isnum) return 1
  var %return = $iif(%b > %a,-1,$iif(%a > %b,1,0))
  return %return
}
Alias -l Xdccb-filter-FservSizeD {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $Xdccb-Calcsize($gettok($2,2,9))
  if (n isin %a) || (%b !isnum) return -1
  var %a = $Xdccb-Calcsize($gettok($1,2,9))
  if (n isin %a) || (%a !isnum) return 1
  var %return = $iif(%b > %a,1,$iif(%a > %b,-1,0))
  return %return
}
Alias -l Xdccb-filter-size700 return $Xdccb-filter-size($1,$2,700)
Alias -l Xdccb-filter-size710 return $Xdccb-filter-size($1,$2,710)
Alias -l Xdccb-filter-size720 return $Xdccb-filter-size($1,$2,720)
Alias -l Xdccb-filter-size730 return $Xdccb-filter-size($1,$2,730)
Alias -l Xdccb-filter-size {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $Xdccb-Calcsize($gettok($2,%xdccb-sort-place,9))
  if (n isin %b) || (%b !isnum) return 1
  var %a = $Xdccb-Calcsize($gettok($1,%xdccb-sort-place,9))
  if (n isin %a) || (%a !isnum) return -1
  var %return = $iif(%b > %a,-1,$iif(%a > %b,1,0))
  did -a Xdccb $3 delta 1
  return %return
}
Alias -l Xdccb-filter-sizeD700 return $Xdccb-filter-sizeD($1,$2,700)
Alias -l Xdccb-filter-sizeD710 return $Xdccb-filter-sizeD($1,$2,710)
Alias -l Xdccb-filter-sizeD720 return $Xdccb-filter-sizeD($1,$2,720)
Alias -l Xdccb-filter-sizeD730 return $Xdccb-filter-sizeD($1,$2,730)
Alias -l Xdccb-filter-sizeD {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $Xdccb-Calcsize($gettok($2,%xdccb-sort-place,9))
  if (n isin %b) || (%b !isnum) return -1
  var %a = $Xdccb-Calcsize($gettok($1,%xdccb-sort-place,9))
  if (n isin %a) || (%a !isnum) return 1
  var %return = $iif(%b > %a,1,$iif(%a > %b,-1,0))
  did -a Xdccb $3 delta 1
  return %return
}
Alias -l Xdccb-filter-Time {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $duration($gettok($gettok($2,3,9),5-,32))
  if (n isin %a) || (%b !isnum) return -1
  var %a = $duration($gettok($gettok($1,3,9),5-,32))
  if (n isin %a) || (%a !isnum) return 1
  var %return = $iif(%b > %a,-1,$iif(%a > %b,1,0))
  return %return
}
Alias -l Xdccb-filter-TimeD {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %b = $duration($gettok($gettok($2,3,9),5-,32))
  if (n isin %a) || (%b !isnum) return -1
  var %a = $duration($gettok($gettok($1,3,9),5-,32))
  if (n isin %a) || (%a !isnum) return 1
  var %return = $iif(%b > %a,1,$iif(%a > %b,-1,0))
  return %return
}
Alias -l Xdccb-filter-num700 return $Xdccb-filter-num($1,$2,700)
Alias -l Xdccb-filter-num710 return $Xdccb-filter-num($1,$2,710)
Alias -l Xdccb-filter-num720 return $Xdccb-filter-num($1,$2,720)
Alias -l Xdccb-filter-num730 return $Xdccb-filter-num($1,$2,730)
Alias -l Xdccb-filter-num {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %a = $calc($remove($gettok($1,%xdccb-sort-place,9),$chr(32)))
  var %b = $calc($remove($gettok($2,%xdccb-sort-place,9),$chr(32)))
  var %return = $iif(%b > %a,-1,$iif(%a > %b,1,0)) 
  if ($1 != %xdccb-sort-b) && (%return != -1) {
    did -a Xdccb $3 delta 1
    set %xdccb-sort-b $1
  }
  return %return
}
Alias -l Xdccb-filter-numD700 return $Xdccb-filter-numD($1,$2,700)
Alias -l Xdccb-filter-numD710 return $Xdccb-filter-numD($1,$2,710)
Alias -l Xdccb-filter-numD720 return $Xdccb-filter-numD($1,$2,720)
Alias -l Xdccb-filter-numD730 return $Xdccb-filter-numD($1,$2,730)
Alias -l Xdccb-filter-numD {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %a = $calc($remove($gettok($1,%xdccb-sort-place,9),$chr(32)))
  var %b = $calc($remove($gettok($2,%xdccb-sort-place,9),$chr(32)))
  var %return = $iif(%b > %a,1,$iif(%a > %b,-1,0)) 
  if ($1 != %xdccb-sort-b) && (%return != -1) {
    did -a Xdccb $3 delta 1
    set %xdccb-sort-b $1
  }
  return %return
}
Alias -l Xdccb-filter-Queue700 return $Xdccb-filter-Queue($1,$2,700)
Alias -l Xdccb-filter-Queue710 return $Xdccb-filter-Queue($1,$2,710)
Alias -l Xdccb-filter-Queue720 return $Xdccb-filter-Queue($1,$2,720)
Alias -l Xdccb-filter-Queue730 return $Xdccb-filter-Queue($1,$2,730)
Alias -l Xdccb-filter-Queue {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %a = $remove($gettok($gettok($1,5,9),1,47),$chr(32))
  if (Fr isin %a) || (n isin %a) return -1
  var %b = $remove($gettok($gettok($2,5,9),1,47),$chr(32))
  if (Fr isin %b) || (n isin %b) return 1
  var %return = $iif(%b > %a,-1,$iif(%a > %b,1,0))
  if ($1 != %xdccb-sort-b) && (%return != -1) {
    did -a Xdccb $3 delta 1
    set %xdccb-sort-b $1
  }
  return %return
}
Alias -l Xdccb-filter-QueueD700 return $Xdccb-filter-QueueD($1,$2,700)
Alias -l Xdccb-filter-QueueD710 return $Xdccb-filter-QueueD($1,$2,710)
Alias -l Xdccb-filter-QueueD720 return $Xdccb-filter-QueueD($1,$2,720)
Alias -l Xdccb-filter-QueueD730 return $Xdccb-filter-QueueD($1,$2,730)
Alias -l Xdccb-filter-QueueD {
  dll $qt($scriptdir\WhileFix.dll) WhileFix
  var %a = $remove($gettok($gettok($1,5,9),1,47),$chr(32))
  if (Fr isin %a) || (n isin %a) return 1
  var %b = $remove($gettok($gettok($2,5,9),1,47),$chr(32))
  if (Fr isin %b) || (n isin %b) return -1
  var %return = $iif(%b > %a,1,$iif(%a > %b,-1,0))
  if ($1 != %xdccb-sort-b) && (%return != -1) {
    did -a Xdccb $3 delta 1
    set %xdccb-sort-b $1
  }
  return %return
}
Alias -l Xdccb-Fservtimer {
  if (!$dialog($1)) return
  if ($gettok($dialog($1).title,7,32) = 1) {
    dialog -x $1
    return
  }
  dialog -t $1 $+($gettok($1,2,61),'s) File Server (XDCC Browser v4.50) ... Closing in $calc($gettok($dialog($1).title,10,32) -1) Seconds
  $+(.timer,$1) 1 1 Xdccb-Fservtimer $1
}
Alias -l Xdccb-FservSeticon {
  did -i $1 $2 1 iconsize normal small
  var %a = 1
  while ($hfind(Xdccb-FileIcons,%a,1,W).data) {
    var %type = $v1
    var %icon = $regread($+(HKEY_CLASSES_ROOT\.,%type,\DefaultIcon\))
    if (!%icon) var %icon = $regread($+(HKEY_CLASSES_ROOT\,$regread($+(HKEY_CLASSES_ROOT\.,%type,\)),\DefaultIcon\))
    if ($+(%,*,%) iswm $gettok(%icon,1,92) ) var %icon = $+($GetEnvStr($gettok($v2,1,37)),\,$gettok(%icon,2-,92))
    if (!%icon) var %icon = $+($GetEnvStr(SystemRoot),\,system32\SHELL32.dll,$chr(44),0)
    var %file = $shortfn($gettok(%icon,1,44))
    var %num = $gettok(%icon,2,44)
    if (%file = Shell32.dll) || (!$exists(%file)) var %file =  $+($GetEnvStr(SystemRoot),\,system32\SHELL32.dll)
    if (%icon = $+(%,1)) did -i $1 28 1 seticon normal 0 $+(2,$chr(44),$GetEnvStr(SystemRoot),\,system32\SHELL32.dll)
    else did -i $1 28 1 seticon normal 0 $+(%num,$chr(44),%file)
    inc %a
  }
}
Alias -l Xdccb-FservSeticon2 {
  did -i $1 $2 1 iconsize normal small
  var %icon = $regread(HKEY_CLASSES_ROOT\Directory\DefaultIcon\)
  if ($+(%,*,%) iswm $gettok(%icon,1,92) ) var %icon = $+($GetEnvStr($gettok($v2,1,37)),\,$gettok(%icon,2-,92))
  did -i $1 $2 1 seticon normal $+($gettok(%icon,2,44),$chr(44),$shortfn($gettok(%icon,1,44)))
  did -i $1 $2 1 seticon normal $+(0,$chr(44),$GetEnvStr($gettok($v2,1,37)),\,Explorer.exe)
}
Alias -l Xdccb-FservTrigger {
  var %start = $2
  var %end = $3
  var %sep = $1
  var %triggers = $4-
  if ($left(%triggers,1) = /) var %check = yeap
  else var %check = nope
  var %network = $gettok($network,1,46)
  if (%end = 93) && (%check = yeap) var %Slashes = $count($nick,$chr(93))
  else %slashes = 0
  var %oldpack = $gettok($gettok(%triggers,1,%sep),$+(1-,$calc(%Slashes + 1)),%end)
  var %last = $gettok(%oldpack,-1,32)
  if ($+(*,$chr(40),*,/,*,$chr(41)) iswm %last) {
    var %last = $left($gettok(%last,-1,40),-1)
    if ($gettok(%last,1,47) isnum) && ($gettok(%last,2,47) isnum) var %oldpack = $deltok(%oldpack,-1,40))
  }
  var %a = 2
  var %num = 1
  if (!$gettok(%triggers,%a,%sep)) addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %num File Server %oldpack
  else {
    while ($gettok(%triggers,%a,%sep)) { 
      var %newpack = $v1
      var %newpack = $gettok(%newpack,$+(1-,$calc(%Slashes + 1)),%end)
      var %last = $gettok(%newpack,-1,32)
      if ($+(*,$chr(40),*,/,*,$chr(41)) iswm %last) {
        var %last = $left($gettok(%last,-1,40),-1)
        if ($gettok(%last,1,47) isnum) && ($gettok(%last,2,47) isnum) var %newpack = $deltok(%oldpack,-1,40))
      }
      if ($findtok($1-,$wildtok($1-,$+(*,%newpack,*),1,%start),1,%start) > $calc((%Slashes * %num) + 1)) {
        addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %num File Server %oldpack
        goto end
      }
      if ((%check = yeap) && ($left($remove(%newpack,$chr(32)),1) = /)) || (%check = nope) {
        addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %num File Server %oldpack
        inc %num
        if (!$gettok(%triggers,$calc(%a +1),%sep)) addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %num File Server %newpack
        var %oldpack = %newpack
      }
      else {
        if (%sep = 38) var %oldpack = %oldpack & %newpack
        if (!$gettok(%triggers,$calc(%a +1),%sep)) {
          addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %num File Server %oldpack
          inc %num
        }
      }
      inc %a
    }
  }
  :end
  dec %a
  if (%slashes = 0) var %slashes = 1 
  hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),File ServT) $gettok($1-,$+($calc((%Slashes * %a) + 1),-),%end)
}
Alias -l Xdccb-getscid {
  if ($dialog(xdccb)) {
    if ($dialog(xdccb).tab = 100) && ($did-tree(xdccb,27).root) var %net = $did-tree(xdccb,27,$did-tree(xdccb,27).root)
    elseif ($dialog(xdccb).tab = 300) && ($did(xdccb,308).sel) var %net = $did-list(8,$did(xdccb,308).seltext)
    else {
      var %a = 1
      while ($hget(%a)) {
        var %get = $v1
        if ($+(XDCCb-,*) iswm %get) && (*-data !iswm %get) {
          var %network = $remove(%get,XDCCb-)
          if ($hfind($+(XDCCb-,%network),$+(*,$did-list(1-,$did(XDCCb,28).seltext)),1,w).DATA) {
            var %net = %network
          }
        }
        inc %a
      }
    }
    var %scid = $XDCCb-network(%net)
  }
  if (%scid) return %scid %net
  else return no %net
}
alias -l Xdccb-gets if ($Xdccb-getactive($1)) return $+($get($1,$v1).pc,%)
alias -l Xdccb-getactive {
  var %a = 1
  while ($get($1,%a)) {
    if ($get($1,%a).status = active) return %a
    inc %a
  }
}
Alias -l Xdccb-getserver scid -t1 $1 /return $eval($Server)
Alias -l Xdccb-RandomServer {
  var %network = $1
  var %nick = $2
  var %server = $3
  var %port = $4
  if ($read($+(",$mircdirservers.ini"),w,*= $+ %network $+ : Random serverSERVER:*)) writeini -n $+(",%xdccgets.ini,") %nick Server $gettok($v1,3,58)
  elseif ($read($+(",$mircdirservers.ini"),w,*=Random* %Network *serverSERVER:*)) writeini -n $+(",%xdccgets.ini,") %nick Server $gettok($v1,2,58)
  elseif ($read($+(",$mircdirservers.ini"),w,$+(*irc.,%Network,.,*,Group:,*,%network))) {
    var %v1 = $v1
    if (random isin $gettok(%v1,2,58)) writeini -n $+(",%xdccgets.ini,") %nick Server $gettok(%v1,3,58))
    else writeini -n $+(",%xdccgets.ini,") %nick Server $gettok(%v1,2,58)
  }
  else {
    writeini -n $+(",%xdccgets.ini,") %nick Server %server
    .server -a %server -p %port -g %network
  }
}
Alias -l xdccb-RandomServerGet {
  if (!$2) return
  var %server = $1
  var %network = $2
  if ($read($+(",$mircdirservers.ini"),w,*= $+ %network $+ : Random serverSERVER:*)) var %server = $gettok($v1,3,58)
  elseif ($read($+(",$mircdirservers.ini"),w,*=Random* %Network *serverSERVER:*)) var %server = $gettok($v1,2,58)
  elseif ($read($+(",$mircdirservers.ini"),w,$+(*irc.,%Network,.,*,Group:,*,%network))) {
    var %v1 = $v1
    if (random isin $gettok(%v1,2,58)) var %server = $gettok(%v1,3,58))
    else var %server = $gettok(%v1,2,58)
  }
  elseif ($read($mircdirservers.ini,w,$+(*group:,%network,*))) var %server = $gettok($v1,2,58)
  return %server
}
Alias -l Xdccb-Hashoptions {
  if (!$hget(Xdccboptions)) hmake Xdccboptions
  hload -i Xdccboptions $qt(%xdccgets.ini) $+($chr(38),Options,$chr(38))
}
Alias -l Xdccb-Hashnick {
  var %hash = $+(Xdccbhash-,$1)
  if (!$hget(%hash)) hmake %hash
  else hdel -w %hash *
  var %xdccgets.ini = $qt(%xdccgets.ini)
  hload -i $+(Xdccbhash-,$1) %xdccgets.ini $1
}
Alias -l Xdccb-HashUsers {
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    if (%nick != DCC˙Allow) && (%nick != $+($chr(38),Options,$chr(38))) Xdccb-Hashnick %nick
    inc %a
  }
}
Alias -l xdccb-Addoption {
  writeini -n $qt(%xdccgets.ini) $+($chr(38),Options,$chr(38)) $1-
  hadd Xdccboptions $1-
}
Alias -l Xdccb-Join {
  var %network = $2
  var %server = $3
  var %chan = $4
  var %key = $5
  if (!$hget(xdccboptions,ssl)) var %server = $xdccb-RandomServerGet(%server,%network)
  var %scid = $XDCCb-network(%network)
  if (%scid) {
    if (%chan) && (!$XDCCb-onchan(%scid,%chan)) scid -t1 %scid /join %chan %key
    return
  }
  else {
    if ($1 = Joinall) {
      if ($findtok(%xdccb-Join-All,%network,44)) return
      set %xdccb-Join-All $addtok(%xdccb-Join-All,%network,44)
    }
    if ($read($+(",$mircdirservers.ini"),w,*= $+ %network $+ : Random serverSERVER:*)) || ($read($+(",$mircdirservers.ini"),w,*=Random* %network *serverSERVER:*)) || $& 
      ($read($+(",$mircdirservers.ini"),w,$+(*irc.,%Network,.,*,Group:,*,%network))) server -m %network $hget($+(Xdccbhash-,%nick),port) $iif(%chan,-j %chan)
    else server -m %server $hget($+(Xdccbhash-,%nick),port) $iif(%chan,-j %chan %key)
  }
}
Alias -l Xdccb-joinuser {
  var %nick = $replace($1,[,$chr(60),],$chr(62))
  var %chan = $hget($+(Xdccbhash-,%nick),chan)
  var %network = $gettok($hget($+(Xdccbhash-,%nick),network),1,46)
  var %server = $hget($+(Xdccbhash-,%nick),server) 
  var %key = $hget($+(Xdccbhash-,%nick),key)
  if (!%network) && (!%chan) {
    var %network = $2
    var %chan = $hget($+(xdccb-,%network,-data),$+(%nick,$chr(255),Chan))
    var %server = $hget($+(xdccb-,%network,-data),$+(%nick,$chr(255),Server))
  }
  var %scid = $XDCCb-network(%network,%chan)
  if (!%chan) return
  if (%scid) && (!$XDCCb-onchan(%scid,%chan)) scid -t1 %scid /join %chan %key
  else Xdccb-Join $iif($2,$2,1) %network %server %chan %key
}
alias Xdccb-Link {
  var %chan = $+($chr(35),$gettok($1-,3,47))
  var %server = $gettok($1-,2,47)
  if (!%server) return
  var %network = $gettok(%server,2,46)
  if (!%network) return
  var %port = $readini($qt($mircdirmirc.ini),text,defport)
  var %line = $gettok($read($qt($mircdirservers.ini),w,$+(*,%server,*)),2-,61)
  if (%line) {
    if (*Random* iswm %line) var %network = $gettok(%server,2,46)
    else var %network = $gettok(%line,-1,58)
  }
  tokenize 32 $cb
  if (($1 = /ctcp) || ($1 = /msg)) && ($3-4 = XDCC Send) {
    var %xdccgets.ini = $qt(%xdccgets.ini)
    var %nick = $2
    var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
    var %Pack-num = $remove( [ [ $+($,$0) ] ] ,$chr(35))
    var %pack = $+(Requesting Pack no.,$chr(32),$chr(35),%Pack-num) $chr(9) %Pack-num $chr(9) n/a
    if ($hget($+(Xdccbhash-,%nick2),$+(Pack,%Pack-num))) return
    writeini -n %xdccgets.ini %nick2 $+(Pack,%Pack-num) %pack
    writeini -n %xdccgets.ini %nick2 $+(Date,%Pack-num) $Date
    writeini -n %xdccgets.ini %nick2 $+(Time,%Pack-num) $Time
    writeini -n %xdccgets.ini %nick2 Chan %chan
    Xdccb-RandomServer %network %nick2 %server %port
    writeini -n %xdccgets.ini %nick2 Network %network
    writeini -n %xdccgets.ini %nick2 Port %port
    writeini -n %xdccgets.ini %nick2 Usage $replace($gettok($1-,$+(1-,$calc($numtok($1-,35) -1)),35),/msg,/.msg,/ctcp,/.ctcp)
    var %get = $hget($+(Xdccbhash-,%nick2),get)
    if (!%get) writeini -n %xdccgets.ini %nick2 Get 1
    Xdccb-Hashnick %nick2
    Xdccb-joinuser %nick
    var %scid = $XDCCb-network(%network)
    if ($XDCCb-onchan(%scid,%chan)) && ((!%get) || (%get = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w))) XDCCb-request-Pack %nick $+($chr(35),%pack-num) %scid %network %pack 
    clipboard Requesting pack $+($chr(35),%Pack-num) from %nick 
    if ($dialog(XDCCb)) {
      if ( $didwm(xdccb,308,$+(*,$gettok(%pack,1-2,9),$chr(9),*,%nick,$chr(9),*),1) = 0 ) {
        var %a = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)
        var %get = $hget($+(Xdccbhash-,%nick2),get)
        var %order = $iif($calc(%a - %get +1) > 0,$ord($v1),Finished)
        var %stat = $Xdccb-stats(%nick,%network,%chan,%order)
        did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 $gettok(%pack,1-3,9) $chr(9) $gettok(%stat,1,9) $chr(9) %order $chr(9) %nick $chr(9) %chan $chr(9) %network $chr(9) %server
      }
    }
  }
  else Xdccb-Join 1 %network %server %chan
}
alias Xdccb-xdccLink {
  var %xdccgets.ini = $qt(%xdccgets.ini)
  var %chan = $gettok($1-,4,47)
  var %server = $gettok($1-,3,47)
  if (!%server) return
  var %network = $gettok($1-,2,47)
  if (!%network) return
  var %port = $readini($+(",$mircdirmirc.ini"),text,defport)
  var %line = $gettok($read($+(",$mircdirservers.ini"),w,$+(*,%server,*)),2-,61)
  if (%line) {
    if (*Random* iswm %line) var %network = $gettok(%server,2,46)
    else var %network = $gettok(%line,-1,58)
  }
  var %nick = $gettok($1-,5,47)
  var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
  var %Pack-num = $calc($remove($gettok($1-,6,47),$chr(35)))
  var %pack = $gettok($1-,7,47) $chr(9) %Pack-num $chr(9) n/a
  if ($hget($+(Xdccbhash-,%nick2),$+(Pack,%Pack-num))) return
  writeini -n %xdccgets.ini %nick2 $+(Pack,%Pack-num) %pack
  writeini -n %xdccgets.ini %nick2 $+(Date,%Pack-num) $Date
  writeini -n %xdccgets.ini %nick2 $+(Time,%Pack-num) $Time
  writeini -n %xdccgets.ini %nick2 Chan %chan
  Xdccb-RandomServer %network %nick2 %server %port
  writeini -n %xdccgets.ini %nick2 Network %network
  writeini -n %xdccgets.ini %nick2 Port %port
  writeini -n %xdccgets.ini %nick2 Usage $replace($+(/,$gettok($1-,8,47)),/msg,/.msg,/ctcp,/.ctcp)
  var %get = $hget($+(Xdccbhash-,%nick2),get)
  if (!%get) writeini -n %xdccgets.ini %nick2 Get 1
  Xdccb-Hashnick %nick2
  Xdccb-joinuser %nick
  var %scid = $XDCCb-network(%network)
  if ($XDCCb-onchan(%scid,%chan)) && ((!%get) || (%get = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w))) XDCCb-request-Pack %nick $+($chr(35),%pack-num) %scid %network %pack 
  clipboard Requesting pack $+($chr(35),%Pack-num) from %nick 
  if ($dialog(XDCCb)) {
    if ( $didwm(xdccb,308,$+(*,$gettok(%pack,1-2,9),$chr(9),*,%nick,$chr(9),*),1) = 0 ) {
      var %a = $hfind($+(Xdccbhash-,%nick2),Pack*,0,w)
      var %get = $hget($+(Xdccbhash-,%nick2),get)
      var %order = $iif($calc(%a - %get +1) > 0,$ord($v1),Finished)
      var %stat = $Xdccb-stats(%nick,%network,%chan,%order)
      did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 $gettok(%pack,1-3,9) $chr(9) $gettok(%stat,1,9) $chr(9) %order $chr(9) %nick $chr(9) %chan $chr(9) %network $chr(9) %server
    }
  }
}
Alias Xdccb-loadlist {
  var %file = $remove($1-,")
  if (!$isfile(%file)) return
  var %a = 1
  while ($ini(%file,%a)) {
    var %hash = $ini(%file,%a)
    if (!%hash) {
      if ($dialog(xdccb)) {
        if ($dialog(Xdccb-ProcessbarLoad)) dialog -nk Xdccb-ProcessbarLoad
        xdccb27
      }
      return
    }
    if (!$dialog(Xdccb-ProcessbarLoad)) dialog -m xdccb-processbarLoad Xdccb-Processbar
    dialog -t Xdccb-ProcessbarLoad Loading list - $gettok($ini(%file,%a),2-,45) ...
    did -a Xdccb-ProcessbarLoad 1 0 0 $ini(%file,%a,0)
    window -h @Xdccb-load
    loadbuf $+(-rt,%hash) @Xdccb-load $qt(%file)
    var %b = 1
    while ($line(@Xdccb-load,%b)) {
      hadd -m %hash $replace($gettok($v1,1,61),$chr(60),[,$chr(250),[,$chr(62),],$chr(251),]) $gettok($v1,2,61)
      did -a Xdccb-ProcessbarLoad 1 %b
      inc %b 
    }
    inc %a
  }
  window -c @Xdccb-load
  if ($dialog(Xdccb-ProcessbarLoad)) dialog -nk Xdccb-ProcessbarLoad
  if (!$dialog(XDCCb)) XDCCb
  else xdccb27
}
Alias -l xdccb-Loadoptions {
  if ($hget(Xdccboptions,XDCCAutoGet) = on) did -c XDCCb 350
  if ($hget(Xdccboptions,XDCCResume) = on) did -c XDCCb 351
  if ($hget(Xdccboptions,XDCCDelete-hash) = on) did -c XDCCb 352
  if ($hget(Xdccboptions,XDCC-Requestlist) = on) did -c XDCCb 353
  if (o isin $hget(Xdccboptions,Mode)) did -c Xdccb 354
  if (d isin $hget(Xdccboptions,Mode)) did -c Xdccb 355
  did -c xdccb $iif($hget(Xdccboptions,Request) = /.msg,358,359)
  if ($hget(Xdccboptions,Echo) = on) did -c Xdccb 360
  did -ra Xdccb 362 $hget(Xdccboptions,Request-Timer)
  did -ra Xdccb 365 $hget(Xdccboptions,Getfail-Timer)
  did -j xdccb 362,365
  if ($hget(Xdccboptions,Join-channels) = Yes) did -c Xdccb 369
  if ($hget(Xdccboptions,Auto-connect) = on) did -c Xdccb 380
  if ($hget(Xdccboptions,Hide-Packs) = on) did -c Xdccb 382
  if ($hget(Xdccboptions,Delete) = on) did -c Xdccb 383
  if ($hget(Xdccboptions,Sessions) = on) did -c Xdccb 384
  if ($portable) did -b Xdccb 385
  elseif ($hget(Xdccboptions,Links) = on) did -c Xdccb 385
  if ($hget(Xdccboptions,Channel-pack) = Yes) did -c Xdccb 386
  if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) did -c Xdccb 387
  if ($gettok($hget(Xdccboptions,Listing),1,32) = 1) did -c Xdccb 388
  if ($gettok($hget(Xdccboptions,Listing),2,32) = 1) did -c Xdccb 389
  if ($gettok($hget(Xdccboptions,Listing),3,32) = 1) did -c Xdccb 390
  if ($hget(Xdccboptions,Hide-Fserv) = on) did -c Xdccb 391
  if ($hget(Xdccboptions,Remove) = on) did -c Xdccb 392
  if ($hget(Xdccboptions,Autosave) = on) did -c Xdccb 393
  if ($hget(Xdccboptions,Finish-Quit) = on) did -c Xdccb 394
  if ($hget(Xdccboptions,Finish-Shutdown) = on) did -c Xdccb 395
  if ($hget(Xdccboptions,Fserv-Browser) = on) did -c Xdccb 396
  if ($hget(Xdccboptions,Move) = on) did -c Xdccb 397
  if ($hget(Xdccboptions,Startup) = on) did -c Xdccb 400
  if ($hget(Xdccboptions,Stats) = on) did -c Xdccb 402
  if ($hget(Xdccboptions,SSL) = on) did -c Xdccb 403
  if ($hget(Xdccboptions,Minimize) = on) {
    did -c Xdccb 401
    did -b XDccb 355,400
  }
  did -a xdccb 398 $hget(Xdccboptions,Finish)
}
Alias -l Xdccb-Make-reg {
  window -h @xdccb-reg
  if ($exists(Xdccb.reg)) write -c Xdccb.reg
  if (9* iswm $os) || ($os = ME) aline @xdccb-reg REGEDIT4
  else aline @xdccb-reg Windows Registry Editor Version 5.00
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\IRC\Shell\open\command]
  aline @xdccb-reg @=" $+ $replace($mircexe,\,\\) -noconnect"
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec]
  aline @xdccb-reg @="/Xdccb-Link $+($chr(37),1,")
  aline @xdccb-reg $crlf 
  aline @xdccb-reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\ifexec]
  aline @xdccb-reg @="/.timer 1 1 Xdccb-Link $+($chr(37),1,")
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\Topic]
  aline @xdccb-reg @="Command"
  aline @xdccb-reg [HKEY_CLASSES_ROOT\IRC\Shell\open\ddeexec\Application]
  aline @xdccb-reg @=" $+ $ddename $+ "
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\XDCC]
  aline @xdccb-reg @="URL:IRC Protocol"
  aline @xdccb-reg "URL Protocol"=""
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\XDCC\Shell\open\command]
  aline @xdccb-reg @=" $+ $replace($mircexe,\,\\) -noconnect"
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\XDCC\Shell\open\ddeexec]
  aline @xdccb-reg @="/Xdccb-xdccLink $+($chr(37),1,")
  aline @xdccb-reg $crlf 
  aline @xdccb-reg [HKEY_CLASSES_ROOT\XDCC\Shell\open\ddeexec\ifexec]
  aline @xdccb-reg @="/.timer 1 1 Xdccb-xdccLink $+($chr(37),1,")
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\XDCC\Shell\open\ddeexec\Topic]
  aline @xdccb-reg @="Command"
  aline @xdccb-reg [HKEY_CLASSES_ROOT\XDCC\Shell\open\ddeexec\Application]
  aline @xdccb-reg @=" $+ $ddename $+ "
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb]
  aline @xdccb-reg @="XDCC Browser List"
  aline @xdccb-reg $crlf 
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\DefaultIcon]
  aline @xdccb-reg @=" $+ $replace($scriptdirxdccb-Icons.icl,\,\\) $+ ,5"
  aline @xdccb-reg $crlf 
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\Open\command]
  aline @xdccb-reg @=" $+ $replace($mircexe,\,\\) -noconnect"
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\Open\ddeexec]
  aline @xdccb-reg @="/Xdccb-loadlist $+($chr(37),1")
  aline @xdccb-reg $crlf 
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\Open\ddeexec\ifexec]
  aline @xdccb-reg @="/.timer 1 1 Xdccb-loadlist $+($chr(37),1")
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\Open\ddeexec\Topic]
  aline @xdccb-reg @="Command"
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\Open\ddeexec\Application]
  aline @xdccb-reg @=" $+ $ddename $+ "
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\View\command]
  aline @xdccb-reg @=" $+ $replace($mircexe,\,\\) -noconnect"
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\View\ddeexec]
  aline @xdccb-reg @="/XDCCbview-file $+($chr(37),1")
  aline @xdccb-reg $crlf 
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\View\ddeexec\ifexec]
  aline @xdccb-reg @="/.timer 1 1 XDCCbview-file $+($chr(37),1")
  aline @xdccb-reg $crlf
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\View\ddeexec\Topic]
  aline @xdccb-reg @="Command"
  aline @xdccb-reg [HKEY_CLASSES_ROOT\.xcb\Shell\View\ddeexec\Application]
  aline @xdccb-reg @=" $+ $ddename $+ "
  aline @xdccb-reg $crlf
  savebuf @xdccb-reg XdccB.reg
  close -@ @xdccb-reg
}
Alias -l XDCCb-network {
  var %a = 1
  var %network = $gettok($1,1,46)
  while ($scon(%a)) {
    var %net = $gettok($scon(%a).network,1,46)
    if (%net = %network) && (($scon(%a).status = connected) || ($scon(%a).status = connecting)) return $scon(%a)
    inc %a
  }
  return
}
Alias -l Xdccb-noclose {
  if ($dialog(xdccb)) {
    mdx SetMDXStyle XDCCb 3 positioner size minbox maxbox noclose
    did -b xdccb 1
  }
}
Alias -l Xdccb-okclose {
  if ($dialog(xdccb)) && ($did(xdccb,701) = done) && ($did(xdccb,721) = done) && ($did(xdccb,731) = done)  {
    if ($did(xdccb,711) != done) && (($did(xdccb,203).sel = 6) || ($did(xdccb,203).sel = 7)) return
    mdx SetMDXStyle XDCCb 3 positioner size minbox maxbox
    did -e xdccb 1
  }
}
Alias -l XDCCb-onchan {
  if ($1 !isnum) return
  var %chan = $2
  if ($3) var %nick = $3
  else var %nick = $scid($1).me
  scid -t1 $1 /return $eval($nick(%chan,%nick),0)
}
Alias -l XDCCb-onme-join {
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %match = $v1
    var %nick = $replace(%match,$chr(60),[,$chr(62),])
    var %network = $gettok($readini(%xdccgets.ini,%match,network),1,46)
    var %chan = $hget($+(Xdccbhash-,%match),chan)
    var %get = $hget($+(Xdccbhash-,%match),get)
    var %Pack = $readiniwm(%xdccgets.ini,%match,Pack*,%get)
    if (%network = $gettok($2,1,46)) && ($1 = %chan) && (%nick ison $1) && (%Pack) $+(.TimerXDCCB-,%nick) 1 $calc(%a + $rand(20,60)) XDCCb-request-Pack %nick $+($chr(35),$right($readiniwm(%xdccgets.ini,%match,Pack*,%get).sec,-4)) $cid $2 %Pack
    inc %a
  }
  if ($dialog(xdccb)) {
    var %network = $2
    var %root = $find-branch(xdccb,27,%network)
    if ($find-branch(xdccb,27,$1,%root)) {
      var %root = %root $v1
      var %a = 2
      while ($did-tree(xdccb,27,%root %a)) {
        var %nick = $v1
        if (%nick ison $1) {
          did -i xdccb 27 1 cb root %root
          did -i xdccb 27 1 replaceitem %a $did-tree(xdccb,27,%root %a).flag 3 3 %nick $chr(9) Click on the nick for a list of packs.
        }
        else {
          did -i xdccb 27 1 cb root %root
          did -i xdccb 27 1 replaceitem %a $did-tree(xdccb,27,%root %a).flag 6 6 %nick $chr(9) Click on the nick for a list of packs.
        }
        inc %a
      }
    }
  }
}
Alias -l Xdccb-Priority {
  var %file = $nopath($2-)
  var %get-nick
  var %a = 1
  while ($get(%a)) {
    if ($get(%a).file = %file) && ($get(%a).path = $getdir(%file)) && (($get(%a).status = active) || ($get(%a).status = waiting)) var %get-nick = $get(%a)
    inc %a
  }
  if ($get($1).file = %file) && ($get(%get-nick).file = %file) && ($get($1).cps > $calc($get(%get-nick).cps * 1.2)) {
    var %sec = $replace(%file,[,$chr(60),],$chr(62))
    if ($ini(%Xdccb-Downloads.ini,%sec)) writeini -n $qt(%Xdccb-Downloads.ini) %sec Priority $+($readini(%Xdccb-Downloads.ini,%sec,Priority),$chr(32),$1)
  }
  else $+(.TimerXDCCB-,$1) 1 1800 $timer($+(XDCCB-,$1)).com
  close -g* $1
  if ($isfile($2-)) .remove $qt($2-)
  if ($findfile($nofile($2-),*,0) = 0) .rmdir $+(",$Nofile($2-),")
}
Alias -l xdccb-remove {
  remini -n $qt(%xdccgets.ini) $1 $2
  var %hash = $+(Xdccbhash-,$1)
  if ($hget(%hash)) {
    if ($2) hdel %hash $2
    else {
      hfree %hash
      if ($dialog(xdccb)) {
        var %a = 2
        while ($did(xdccb,501,%a)) {
          var %v1 = $v1
          var %nick = $replace($did-list(7,%v1),[,$chr(60),],$chr(62))
          var %icon = $gettok(%v1,3,32)
          if (%icon = 3) && (%nick = $1) did -o xdccb 501 %a $gettok(%v1,2,32) 4 $gettok($did-list(1-,%v1),5-,32)
          inc %a
        }
      }
    }
  } 
}
Alias -l xdccb-removeQueue {
  var %nick = $1
  var %file2 = $qt($+($scriptdir\Xdccb-queues-,$2,.txt))
  if ($read(%file2,s,%nick )) {
    while ($read(%file2,s,%nick )) {
      write $+(-dl,$calc($readn +1)) %file2
      dec %lines    
    }
    var %line = $read(%file2,w,%nick)
    write $+(-dl,$calc($readn +1)) %file2
    write -l0 %file2 $calc($read(%file2,0) - 1)
    if ($lines(%file2) < 2) .remove $qt(%file2)
  }
}
Alias -l Xdccb-resize {
  var %new-width = $1
  var %new-hight = $2
  mdx MoveControl xdccb 1 $calc(%new-width -143) $calc(%new-hight -40)
  mdx MoveControl xdccb 35 * * * $calc(%new-hight -54)
  mdx MoveControl xdccb 27 * * * $calc(%new-hight -80)
  mdx MoveControl xdccb 28 * * $calc(%new-width -292) $calc(%new-hight -180)
  mdx MoveControl xdccb 31 $calc(%new-width -484) $calc(%new-hight -120)
  mdx MoveControl xdccb 32 $calc(%new-width -180) $calc(%new-hight -120)
  mdx MoveControl xdccb 33 $calc(%new-width -250) $calc(%new-hight -80)
  mdx MoveControl xdccb 34 $calc(%new-width -332) $calc(%new-hight -120)
  mdx MoveControl xdccb 41 $calc(%new-width -486) $calc(%new-hight -84)
  mdx MoveControl xdccb 42 $calc(%new-width -346) $calc(%new-hight -86)
  mdx MoveControl xdccb 43 $calc(%new-width -486) $calc(%new-hight -50)
  mdx MoveControl xdccb 44 $calc(%new-width -346) $calc(%new-hight -52)
  mdx MoveControl xdccb 202 $calc(%new-width -462) *
  mdx MoveControl xdccb 203 $calc(%new-width -150) *
  mdx MoveControl xdccb 204 * * $calc(%new-width -40) *
  mdx MoveControl xdccb 205 * * $calc(%new-width -40) *
  mdx MoveControl xdccb 206 * * $calc(%new-width -492) *
  mdx MoveControl xdccb 207 * * $calc(%new-width -40) $calc(%new-hight -150)
  mdx MoveControl xdccb 208 $calc(%new-width -210) *
  mdx MoveControl xdccb 209 $calc(%new-width -410) $calc(%new-hight -40)
  mdx MoveControl xdccb 211 $calc(%new-width -520) $calc(%new-hight -40)
  mdx MoveControl xdccb 212 $calc(%new-width -600) $calc(%new-hight -38)
  mdx MoveControl xdccb 213 $calc(%new-width -390) *
  mdx MoveControl xdccb 214 $calc(%new-width -314) *
  mdx MoveControl xdccb 215 $calc(%new-width -280) *
  mdx MoveControl xdccb 303 $calc(%new-width -420) $calc(%new-hight -40)
  mdx MoveControl xdccb 304 * $calc(%new-hight -40)
  mdx MoveControl xdccb 308 * * $calc(%new-width -40) $calc(%new-hight -148)
  mdx MoveControl xdccb 407 * $calc(%new-hight -40)
  mdx MoveControl xdccb 408 * $calc(%new-hight -40)
  mdx MoveControl xdccb 501 * * $calc(%new-width -40) $calc(%new-hight -148)
  mdx MoveControl xdccb 901 * $calc(%new-hight -99) $calc(%new-width -40) *
  var %tab = $dialog(xdccb).tab
  if (%tab = 300) {
    did -c xdccb 600
    did -c xdccb 300
    did -h xdccb 1,2
    did -v xdccb 1,2
  }
  else {
    did -c xdccb 300
    did -c xdccb %tab
    did -h xdccb 1,2
    did -v xdccb 1,2
  }
}
Alias -l XDCCb-request-Fserv {
  var %nick = $1
  var %network = $2
  var %scid = $3
  var %pack = $gettok($4-,1,9)
  if ($asc($gettok(%pack,2,32)) = 47) scid -t1 %scid $replace($gettok(%pack,2,32),/,/.) $gettok(%pack,3-,32)
  else scid -t1 %scid /msg $XDCCb-Changet(%scid,%nick) $gettok(%pack,2-,32)
  if ($hget(Xdccboptions,Echo) = on) {
    scid -t1 %scid /linesep -s
    scid -t1 %scid /Echo -ts $+([ ,$color(ctcp text),Requesting File Server $+(,$color(info text), $chr(40),$5-,$chr(41)),,$color(ctcp text),$chr(32),from %nick, ])) 
    scid -t1 %scid /linesep -s
  }
}
Alias -l XDCCb-request-Pack {
  var %nick = $replace($1,[,$chr(60),],$chr(62))
  if ($hget($+(Xdccbhash-,%nick),Pause)) return
  var %network,%usage
  if ($timer($+(.TimerXDCCB-,$1))) $+(.TimerXDCCB-,$1) off
  if ($4) {
    var %scid = $3
    var %network = $gettok($4,1,46)
    var %Pack = $5-
  }
  if (!%network) {
    var %scid = $cid
    var %network = $gettok($network,1,46)
  }
  var %a = 1
  while ($get($1,%a)) {
    if ($get($1,%a).status = active) {
      $+(.TimerXDCCB-,$1) 1 $hget(Xdccboptions,Request-Timer) XDCCb-request-Pack $1-
      return
    }
    inc %a 
  }
  while ($gettok(%pack,1,32) = 0) { var %pack = $gettok(%pack,2-,32) }
  if (!$XDCCb-Changet(%scid,$1)) return
  if ($ini(%xdccgets.ini,DCC˙Allow,%network)) scid -t1 %scid /.DCCALLOW $+(+,$1)
  if ($gettok($readini(mirc.ini,options,n7),19,44) = 1) .dcc trust $+($1,!*@*)
  if (File Server?: iswm $gettok(%pack,1,32)) {
    var %pack = $remove(%pack,$chr(9))
    if ($asc($gettok(%pack,2,32)) = 47) scid -t1 %scid $replace($gettok(%pack,2,32),/,/.) $gettok(%pack,3-,32)
    else scid -t1 %scid /msg $XDCCb-Changet(%scid,$1) $gettok(%pack,2-,32)
    return
  }
  if (!%pack) return
  if ($hget($+(Xdccbhash-,%nick),Usage) ) {
    var %usage = $v1
    if (msg !isin $gettok(%usage,1,32)) && (ctcp !isin $gettok(%usage,1,32)) {
      if ($hget($+(XDCCb-,%network),$+($1,$chr(255),Usage))) {
        var %usage = $v1
        writeini -n $qt(%xdccgets.ini) %nick Usage %usage
        scid -t1 %scid $replace(%usage,/msg,/.msg,/ctcp,/.ctcp) $iif($chr(35) isin $2,$2,$+($chr(35),$2))
      }
    }
    else scid -t1 %scid $replace(%usage,/msg,/.msg,/ctcp,/.ctcp) $iif($chr(35) isin $2,$2,$+($chr(35),$2))
  }
  else {
    var %usage = $hget(Xdccboptions,Request)
    scid -t1 %scid %usage $1 XDCC send $iif($chr(35) isin $2,$2,$+($chr(35),$2))
  }
  if ($hget(Xdccboptions,Echo) = on) {
    scid -t1 %scid /linesep -s
    scid -t1 %scid /Echo -ts $+([ ,$color(ctcp text),Requesting Pack $iif($chr(35) isin $2,$2,$+($chr(35),$2))  $+(,$color(info text),$chr(40),$gettok(%Pack,1,9),$chr(41)),,$color(ctcp text),$chr(32),from $1, ])) 
    scid -t1 %scid /linesep -s
  }
  $+(.TimerXDCCB-,$1) 1 $hget(Xdccboptions,Request-Timer) XDCCb-request-Pack $1-
}
Alias -l Xdccb-Savedims {
  did -i xdccb 28,207,308,501 1 page headerdims
  xdccb-addoption Dims28 $gettok($did(xdccb,28,1),3-8,32)
  xdccb-addoption Dims207 $gettok($did(xdccb,207,1),3-,32)
  xdccb-addoption Dims308 $gettok($did(xdccb,308,1),3-,32)
  xdccb-addoption Dims501 $gettok($did(xdccb,501,1),3-,32)
}
alias -l xdccb-saveBot {
  var %hash = $1
  var %text = $2
  aline @Xdccb-save $+([,%hash,]) 
  var %a = 1
  while ($hfind(%hash,$+(%text,$chr(255),*),%a,w)) {
    aline @Xdccb-save $+($replace($v1,[,$chr(60),],$chr(62)),=,$hget(%hash,$v1))
    inc %a
    did -a Xdccb-Processbar 1 %a
  }
}
alias -l xdccb-saveChannel {
  var %hash = $1
  var %text = $2
  if (-data isin %hash) var %check = %hash
  else %check = $+(%hash,-data)
  aline @Xdccb-save $+([,%hash,]) 
  var %a = 1
  var %packs = 0
  while ($hfind(%check,%text,%a).data) {
    var %ifmatch = $v1
    var %b = 1
    while ($hfind(%hash,$+($gettok(%ifmatch,1,255),$chr(255),*),%b,w)) {
      aline @Xdccb-save $+($replace($v1,[,$chr(60),],$chr(62)),=,$hget(%hash,$v1))
      inc %b
      inc %packs
      did -a Xdccb-Processbar 1 %packs
    }
    inc %a
  }
}
alias -l xdccb-saveNetwork {
  var %hash = $1
  aline @Xdccb-save $+([,%hash,]) 
  var %a = 1
  while ($Hget(%hash,%a).item) {
    var %ifmatch = $v1
    aline @Xdccb-save $+($replace(%ifmatch,[,$chr(60),],$chr(62)),=,$hget(%hash,%ifmatch))
    inc %a 
    did -a Xdccb-Processbar 1 %a
  }
}
alias -l xdccb-SaveALL {
  var %ontop
  if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
    dialog -n xdccb
    var %ontop = yeap
  }
  var %file = $sfile($+(",$scriptdir*.xcb"),Save as..,Save)
  if (%ontop) dialog -o xdccb 
  if (!%file) return
  if ($gettok(%file,-1,46) != xcb) var %file = $+(%file,.xcb)
  var %a = 1
  var %num = 0
  while ( ($hget(%a)) && (%num < 700) ) {
    if (Xdccb- isin $hget(%a)) inc %num $hget(%a,0).item
    inc %a 
  }
  window -h @Xdccb-save
  .remove $qt(%file)
  var %num = 0
  while ($hget(%a)) {
    var %get = $v1
    if ($+(XDCCb-,*) iswm %get) inc %num
    inc %a
  }
  var %a = 1
  while ($hget(%a)) {
    var %if = $v1
    if (Xdccb- isin %if) {
      var %active = $appactive
      if (%active) {
        if (!$dialog(Xdccb-Processbar)) dialog -m xdccb-processbar Xdccb-Processbar
        dialog -t Xdccb-Processbar Saving list - $gettok(%if,2-,45) ...
        did -a Xdccb-Processbar 1 0 0 $hget(%if,0).item
      }
      aline @Xdccb-save $+([,%if,])
      var %b = 1
      while ($Hget(%if,%b).item) {
        dll $qt($scriptdir\WhileFix.dll) WhileFix
        var %ifmatch = $v1
        aline @Xdccb-save $+($replace(%ifmatch,[,$chr(60),],$chr(62)),=,$hget(%if,%ifmatch))
        inc %b 
        if (%active) did -a Xdccb-Processbar 1 %b
      }
    }
    inc %a
  }
  if ($dialog(Xdccb-Processbar)) dialog -nk Xdccb-Processbar
  savebuf @Xdccb-save $qt(%file)
  window -c @Xdccb-save
}
Alias -l Xdccb-Session {
  var %network = $gettok($network,1,46)
  var %server = $server
  .server -a %server -p $port -g %network
  if ($read($+(",$mircdirservers.ini"),w,*= $+ %network $+ : Random serverSERVER:*)) var %server = $gettok($v1,3,58)
  elseif ($read($+(",$mircdirservers.ini"),w,*=Random* %network *serverSERVER:*)) var %server = $gettok($v1,2,58)
  elseif ($read($+(",$mircdirservers.ini"),w,$+(*irc.,%Network,.,*,Group:,*,%network))) var %server = $gettok($v1,2,58) 
  if ($read($+(",$mircdirservers.ini"),w,*= $+ %network $+ : Random serverSERVER:*)) || ($read($+(",$mircdirservers.ini"),w,*=Random* %network *serverSERVER:*)) || $& 
    ($read($+(",$mircdirservers.ini"),w,$+(*irc.,%Network,.,*,Group:,*,%network))) server %network $hget($+(Xdccbhash-,%nick),port)
  else server %server $hget($+(Xdccbhash-,%nick),port)
}
Alias -l Xdccb-Seticon {
  did -i $1 $2 1 iconsize normal small
  did -i $1 $2 1 seticon normal 0, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i $1 $2 1 seticon normal 1, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i $1 $2 1 seticon normal 41, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i $1 $2 1 seticon normal 26, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i $1 $2 1 seticon normal 40, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i $1 $2 1 seticon normal 42, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
}
Alias -l XDCCB-Setup {
  if ($version < 6.35) {
    var %check = $input(You are using an old version of mIRC $+($chr(40),v,$version,$chr(41)) $+ $chr(44) The script can't run on a version older than 6.35 $crlf XDCC Browser was unable to load!,124,XDCC Browser)
    unload -rs xdccb.mrc
    return
  }
  if ($lock(dll) = $true) {
    var %check = $input(XDCC Browser was unable to load! $crlf Your /Dll commands are locked in the setup. $crlf To release those commands so the script can work follow these instructions: $crlf $crlf $&
      Go to the Options (Alt + O) > Other > Lock $crlf And remove the "V" from the "Disable run $+ $chr(44) dll $+ $chr(44) com commands" ,124,XDCC Browser)
    unload -rs xdccb.mrc
    return
  }
  var %xdccgets.ini = $qt(%xdccgets.ini)
  if ($ini(%xdccgets.ini,$+($chr(244),Options,$chr(244)))) {
    var %new-line = $readiniwm(%xdccgets.ini,$+($chr(244),Options,$chr(244))).line
    write $+(-l,%new-line) %xdccgets.ini $+([,$chr(38),Options,$chr(38),])
  }
  elseif (!$ini(%xdccgets.ini,$+($chr(38),Options,$chr(38)))) write -c %xdccgets.ini
  var %a = 1
  while ($ini(%xdccgets.ini,%a)) {
    var %sec = $v1
    if (($chr(255) isin %sec) || ($chr(251) isin %sec)) && (%sec != DCC˙Allow) {
      var %new-line = $readiniwm(%xdccgets.ini,%sec).line
      write $+(-l,%new-line) %xdccgets.ini $+([,$replace(%sec,$chr(255),$chr(60),$chr(251),$Chr(62)),])
    }
    inc %a
  }
  var %options = $+($chr(38),Options,$chr(38))
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Mode)) writeini -n %xdccgets.ini %options Mode -mh
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Request)) writeini -n %xdccgets.ini %options Request /.msg
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Echo)) writeini -n %xdccgets.ini %options Echo on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Request-Timer)) writeini -n %xdccgets.ini %options Request-Timer 300
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Getfail-Timer)) writeini -n %xdccgets.ini %options Getfail-Timer 190
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Join-channels)) writeini -n %xdccgets.ini %options Join-channels yes
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Auto-connect)) writeini -n %xdccgets.ini %options Auto-connect on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Hide-Packs)) writeini -n %xdccgets.ini %options Hide-Packs off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Auto-Corrupt)) writeini -n %xdccgets.ini %options Auto-Corrupt yes
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Delete)) writeini -n %xdccgets.ini %options Delete on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Sessions)) writeini -n %xdccgets.ini %options Sessions on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Channel-pack)) writeini -n %xdccgets.ini %options Channel-pack Yes
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Listing)) writeini -n %xdccgets.ini %options Listing 1 1 1
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Hide-Fserv)) writeini -n %xdccgets.ini %options Hide-Fserv off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Remove)) writeini -n %xdccgets.ini %options Remove on 
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Autosave-time)) writeini -n %xdccgets.ini %options Autosave-time 24
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Autosave)) writeini -n %xdccgets.ini %options Autosave off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Load-lists)) writeini -n %xdccgets.ini %options Load-lists off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Finish-Quit)) writeini -n %xdccgets.ini %options Finish-Quit off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Finish-Shutdown)) writeini -n %xdccgets.ini %options Finish-Shutdown off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Fserv-Browser)) writeini -n %xdccgets.ini %options Fserv-Browser on
  if ($1 = Reset) || ($numtok($readini(%xdccgets.ini,%options,Search-Size),44) != 3) || (!$readini(%xdccgets.ini,%options,Search-Size)) writeini -n %xdccgets.ini %options Search-Size 1,0,1
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,XDCCAutoGet)) writeini -n %xdccgets.ini %options XDCCAutoGet on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,XDCCResume)) writeini -n %xdccgets.ini %options XDCCResume on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,XDCCDelete-hash)) writeini -n %xdccgets.ini %options XDCCDelete-hash off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,XDCC-Requestlist)) writeini -n %xdccgets.ini %options XDCC-Requestlist off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,XDCCDialog-size)) writeini -n %xdccgets.ini %options XDCCDialog-size 760 400
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Move)) writeini -n %xdccgets.ini %options Move on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Startup)) writeini -n %xdccgets.ini %options Startup on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Minimize)) writeini -n %xdccgets.ini %options Minimize off  
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Finish)) {
    if (!$isdir($getdirFinish\)) .mkdir $qt($getdirFinish\)
    writeini -n %xdccgets.ini %options Finish $getdirFinish\
  }
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Dims28)) writeini -n %xdccgets.ini %options Dims28 224:1 30:2 70:3 50:4 55:5 70:6
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Dims207)) writeini -n %xdccgets.ini %options Dims207 324:1 30:2 70:3 50:4 54:5 70:6 120:7 120:8 120:9 120:10
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Dims308)) writeini -n %xdccgets.ini %options Dims308 344:1 30:2 70:3 80:4 50:5 90:6 90:7 90:8 100:9
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Dims501)) writeini -n %xdccgets.ini %options Dims501 250:1 60:2 85:3 70:4 90:5 90:6 110:7 200:8
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Searchselect)) writeini -n %xdccgets.ini %options Searchselect 2
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,Stats)) writeini -n %xdccgets.ini %options Stats on
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,SSL)) writeini -n %xdccgets.ini %options SSL off
  if ($1 = Reset) || (!$readini(%xdccgets.ini,%options,sort)) writeini -n %xdccgets.ini %options sort 1 u 1 u 1 u
  if (!$isdir($readini(%xdccgets.ini,%options,Finish))) .mkdir $qt($getdirFinish\)
  if ($readini(%xdccgets.ini,%options,DDE)) remini -n %xdccgets.ini %options DDE
  if ($readini(%xdccgets.ini,%options,Window)) remini -n %xdccgets.ini %options Window
  if ($readini(%xdccgets.ini,%options,Default)) remini -n %xdccgets.ini %options Default
  if ($readini(%xdccgets.ini,%options,Links) = on) && ($gettok($regread(HKEY_CLASSES_ROOT\xdcc\Shell\open\ddeexec\),1,32) != /Xdccb-xdccLink) && (!$portable) {
    Xdccb-Make-reg
    run regedit /s /c XdccB.reg
  }
  Xdccb-Hashoptions
}
alias -l Xdccb-Shutdown-quit {
  var %network = $1
  var %loc,%check
  var %scid = $2
  var %b = 1
  var %user = $3
  while ($ini(%xdccgets.ini,%b)) {
    var %ifmatch = $v1
    if ($readini(%xdccgets.ini,%ifmatch,Network) = %network) var %loc = $v1 
    if (!%check) && (%ifmatch != $+($chr(38),Options,$chr(38))) && (%ifmatch != DCC˙Allow) var %check = ok
    inc %b 
  }
  if ($hget(Xdccboptions,Finish-Shutdown) = on) && (%check != ok) {
    var %a = 1
    while ($scon(%a)) {
      var %message = $iif($read($scriptdir\XDCCb-quit-messages.txt,$rand(1,$lines($scriptdir\XDCCb-quit-messages.txt))),$v1,XDCC Browser v4.50 ... The Easy Way ...)
      scon -t1 %a /quit %message
      inc %a
    }
    if ($os = 95) run RUNDLL32.EXE USER.EXE,ExitWindows
    elseif ($os = 98) run RUNDLL32 KRNL386.EXE,exitkernel 
    elseif ($os = 2K) || ($os = NT) run shutdown /L /T:0 "XDCC Browser - Finished dowloading files. Prepare for shutdown"
    elseif ($os = 2003) run shutdown -S -T 0 /C "XDCC Browser - Finished dowloading files. Prepare for shutdown"
    else run shutdown -S -T 0 -C "XDCC Browser - Finished dowloading files. Prepare for shutdown"
    exit
    halt
  }
  if ($hget(Xdccboptions,Finish-Quit) = on) {
    var %message = $iif($read($scriptdir\XDCCb-quit-messages.txt,$rand(1,$lines($scriptdir\XDCCb-quit-messages.txt))),$v1,XDCC Browser v4.50 ... The Easy Way ...)
    if (!%loc) && (!$XDCCb-onchan(%scid,#incomplete)) {
      scid -t1 %scid quit %message
      scid -t1 %scid window -c "Status Window" 
    }
    else {
      var %b = 1
      while ($comchan(%user,%b)) {
        var %chan = $v1
        if (%chan = #incomplete) goto end374
        var %c = 1
        while ($ini(%xdccgets.ini,%c)) {
          if ($readini(%xdccgets.ini,$v1,Chan) = %chan) goto end374
          inc %c
        }
        var %message = $iif($read($scriptdir\XDCCb-quit-messages.txt,$rand(1,$lines($scriptdir\XDCCb-quit-messages.txt))),$v1,XDCC Browser v4.50 ... The Easy Way ...)
        scid -t1 %scid Part %chan %message
        :end374
        inc %b
      }
    }
  }
}
alias -l Xdccb-Sort-28 {
  var %size = $hget(xdccboptions,sort)
  var %direction = $gettok(%size,2,32)
  var %coloumn = $gettok(%size,1,32)
  if ($window(@tmpXdccb28)) window -h @tmpXdccb28
  if (%coloumn = 1) {
    if (%direction = u) {
      filter -criwt $+(2-,$did(xdccb,28).lines) 5- 32 xdccb 28 @tmpXdccb28 *
      filter -co @tmpXdccb28 xdccb 28 *
    }
    else {
      filter -ecriwt $+(2-,$did(xdccb,28).lines) 5- 32 xdccb 28 @tmpXdccb28 *
      filter -co @tmpXdccb28 xdccb 28 *
    }
    return
  }
  elseif (%coloumn > 6) {
    if (%direction = u) {
      filter -criwt $+(2-,$did(xdccb,28).lines) %coloumn 9 xdccb 28 @tmpXdccb28 *
      filter -co @tmpXdccb28 xdccb 28 *
    }
    else {
      filter -ecriwt $+(2-,$did(xdccb,28).lines) %coloumn 9 xdccb 28 @tmpXdccb28 *
      filter -co @tmpXdccb28 xdccb 28 *
    }
    return
  }
  filter -criwt $+(2-,$did(xdccb,28).lines) %coloumn 9 xdccb 28 @tmpXdccb28 *
  did -ra Xdccb 701 Sorting list ...
  did -a Xdccb 700 0 0 $int($calc($did(xdccb,28).lines * $log($did(xdccb,28).lines)))
  xdccb-noclose
  set %xdccb-sort-place %coloumn
  if (%direction = u) {
    if (%coloumn = 3) || (%coloumn = 6) filter -aco @tmpXdccb28 xdccb 28 Xdccb-filter-size700
    elseif (%coloumn = 2) || (%coloumn = 4) filter -aco @tmpXdccb28 xdccb 28 Xdccb-filter-num700
    elseif (%coloumn = 5) filter -aco @tmpXdccb28 xdccb 28 Xdccb-filter-Queue700
  }
  else {
    if (%coloumn = 3) || (%coloumn = 6) filter -aco @tmpXdccb28 xdccb 28 Xdccb-filter-sizeD700
    elseif (%coloumn = 2) || (%coloumn = 4) filter -aco @tmpXdccb28 xdccb 28 Xdccb-filter-numD700
    elseif (%coloumn = 5) filter -aco @tmpXdccb28 xdccb 28 Xdccb-filter-QueueD700
  }
  did -a Xdccb 700 1 0 1
  did -ra xdccb 701 Done
  xdccb-okclose
  unset %xdccb-sort-place
}
alias -l Xdccb-Sort-207 {
  var %size = $hget(xdccboptions,sort)
  var %direction = $gettok(%size,4,32)
  var %coloumn = $gettok(%size,3,32)
  if ($window(@tmpXdccb202)) window -h @tmpXdccb202
  if (%coloumn = 1) {
    if (%direction = u) {
      filter -criwt $+(2-,$did(xdccb,207).lines) 5- 32 xdccb 207 @tmpXdccb202 
      filter -co @tmpXdccb202 xdccb 207 *
    }
    else {
      filter -ecriwt $+(2-,$did(xdccb,207).lines) 5- 32 xdccb 207 @tmpXdccb202
      filter -co @tmpXdccb202 xdccb 207 *
    }
    return
  }
  elseif (%coloumn > 6) {
    if (%direction = u) {
      filter -criwt $+(2-,$did(xdccb,207).lines) %coloumn 9 xdccb 207 @tmpXdccb202 
      filter -co @tmpXdccb202 xdccb 207 *
    }
    else {
      filter -ecriwt $+(2-,$did(xdccb,207).lines) %coloumn 9 xdccb 207 @tmpXdccb202
      filter -co @tmpXdccb202 xdccb 207 *
    }
    return
  }
  filter -criwt $+(2-,$did(xdccb,207).lines) %coloumn 9 xdccb 207 @tmpXdccb202
  did -ra Xdccb 711 Sorting list ...
  did -a Xdccb 710 0 0 $int($calc($did(xdccb,207).lines * $log($did(xdccb,207).lines)))
  xdccb-noclose
  set %xdccb-sort-place %coloumn
  if (%direction = u) {
    if (%coloumn = 3) || (%coloumn = 6) filter -aco @tmpXdccb202 xdccb 207 Xdccb-filter-size710
    elseif (%coloumn = 2) || (%coloumn = 4) filter -aco @tmpXdccb202 xdccb 207 Xdccb-filter-num710
    elseif (%coloumn = 5) filter -aco @tmpXdccb202 xdccb 207 Xdccb-filter-Queue710
  }
  else {
    if (%coloumn = 3) || (%coloumn = 6) filter -aco @tmpXdccb202 xdccb 207 Xdccb-filter-sizeD710
    elseif (%coloumn = 2) || (%coloumn = 4) filter -aco @tmpXdccb202 xdccb 207 Xdccb-filter-numD710
    elseif (%coloumn = 5) filter -aco @tmpXdccb202 xdccb 207 Xdccb-filter-QueueD710
  }
  did -ra Xdccb 711 Done
  did -ra xdccb 710 1 0 1
  xdccb-okclose
  unset %xdccb-sort-place
}
alias -l xdccb-sort-308 {
  var %size = $hget(xdccboptions,sort)
  var %direction = $gettok(%size,6,32)
  var %coloumn = $gettok(%size,5,32)
  if (!$window(@tmpXdccb202)) window -h @tmpXdccb202
  if (%coloumn = 1) {
    if (%direction = u) {
      filter -criwt $+(2-,$did(xdccb,308).lines) 5- 32 xdccb 308 @tmpXdccb202 
      filter -co @tmpXdccb202 xdccb 308 *
    }
    else {
      filter -ecriwt $+(2-,$did(xdccb,308).lines) 5- 32 xdccb 308 @tmpXdccb202
      filter -co @tmpXdccb202 xdccb 308 *
    }
    return
  }
  elseif (%coloumn != 2) && (%coloumn != 3) {
    if (%direction = u) {
      filter -criwt $+(2-,$did(xdccb,308).lines) %coloumn 9 xdccb 308 @tmpXdccb202 
      filter -co @tmpXdccb202 xdccb 308 *
    }
    else {
      filter -ecriwt $+(2-,$did(xdccb,308).lines) %coloumn 9 xdccb 308 @tmpXdccb202
      filter -co @tmpXdccb202 xdccb 308 *
    }
    return
  }
  else {
    filter -criwt $+(2-,$did(xdccb,308).lines) %coloumn 9 xdccb 308 @tmpXdccb202
    did -ra Xdccb 721 Sorting list ...
    did -a Xdccb 720 0 0 $int($calc($did(xdccb,308).lines * $log($did(xdccb,308).lines)))
    xdccb-noclose
    set %xdccb-sort-place %coloumn
    if (%direction = u) {
      if (%coloumn = 3) filter -aco @tmpXdccb202 xdccb 308 Xdccb-filter-Size720
      elseif (%coloumn = 2) filter -aco @tmpXdccb202 xdccb 308 Xdccb-filter-num720
    }
    else {
      if (%coloumn = 3) filter -aco @tmpXdccb202 xdccb 308 Xdccb-filter-SizeD720
      elseif (%coloumn = 2) filter -aco @tmpXdccb202 xdccb 308 Xdccb-filter-numD720
    }
    did -ra Xdccb 721 Done
    did -a Xdccb 720 1 0 1
    xdccb-okclose
    unset %xdccb-sort-place
  }
}
alias -l Xdccb-statswindow {
  var %window = $+(@XDCCB,$chr(160),Stats)
  var %font = tahoma 12
  var %hight = $calc($height(x,tahoma,12) +1)
  var %width = $window(%window).w
  drawtext -pcrb %window 1 $RGB(186,229,242) %font 1 1 %width %hight Connected: $uptime(mIRC,2)
  var %cps = 0
  var %finished = 0
  var %gets = 0
  var %a = 1
  while ($get(%a)) {
    if ($get(%a).status = active) {
      var %cps = %cps + $get(%a).cps
      inc %gets
    }
    inc %a
  }
  var %a = 1  
  var %requests = 0
  while ($ini(%xdccgets.ini,%a)) {
    var %nick = $v1
    var %requests = %requests + $readiniwm(%xdccgets.ini,%nick,Pack*,0)
    inc %a
  }
  var %a = 1
  while ($ini(%Xdccb-Downloads.ini,%a)) {
    var %sec = $v1
    var %file = $readini(%Xdccb-Downloads.ini,%sec,File)
    var %path = $readini(%Xdccb-Downloads.ini,%sec,Path)
    var %rcvd = $readini(%Xdccb-Downloads.ini,%sec,Rcvd)
    if (%rcvd = Delete) || (!$isfile($+(%path,%file))) {
      remini -n $qt(%Xdccb-Downloads.ini) %sec
      continue
    }
    if (%rcvd = $readini(%Xdccb-Downloads.ini,%sec,Size)) inc %finished
    inc %a
  }
  drawtext -pcrb %window 1 $RGB(186,229,242) %font 1 %hight %width %hight Downloading: $+($chr(40),%gets,/,%requests,$chr(41))
  drawtext -pcrb %window 1 $RGB(186,229,242) %font 1 $calc(%hight *2) %width %hight Download Speed: $iif(%cps < 1024,%cps b/s,$bytes(%cps,k) Kb/s)
  drawtext -pcrb %window 1 $RGB(186,229,242) %font 1 $calc(%hight *3) %width %hight Finished: %finished $iif(%rcvd = 1,File,Files)
}
alias -l Xdccb-stats {
  var %nick = $1
  var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
  var %network = $2
  var %chan = $3
  var %order = $4
  var %stat
  var %icon
  if (%order = Finished) {
    var %stat = Finished
    var %icon = 1
  }
  elseif (%order = 1) && ($hget($+(Xdccbhash-,%nick2),Pause)) {
    var %stat = Paused
    var %icon = 12
  }
  else { 
    var %scid = $XDCCb-network(%network)
    if (%scid) {
      if (!$XDCCb-onchan(%scid,%chan)) {
        var %stat = Not connected
        var %icon = 6
      }
      elseif (!$XDCCb-onchan(%scid,%chan,%nick)) {
        var %stat = Offline
        var %icon = 8
      }
    }
    else {
      var %stat = Not connected
      var %icon = 7
    }
    if ($hget($+(Xdccbhash-,%nick2),Register)) {
      var %stat = Register
      var %icon = 9
    }
    if (!%stat) {
      if ($readini(%xdccgets.ini,%nick2,Unable) >= 3) {
        var %stat = Unable to Connect  
        var %icon = 11
      }
      elseif (%order > 1) {
        var %stat = Waiting
        var %icon = 5
      }
      elseif (%order = 1) {
        if ($Xdccb-gets(%nick)) {
          var %stat = $v1
          var %icon = 2
        }
        elseif ($xdccb-Queues(%nick,%network)) {
          var %stat = $v1
          var %icon = 4
        }
        elseif (!%stat) {
          var %stat = Requesting
          var %icon = 3
        }
      }
      if (%order = n/a) {
        var %stat = File Server
        var %icon = 10
      }
    }
  }
  return $+(%stat,$chr(9),%icon)
}
Alias -l Xdccb-Sockcontinue {
  if ($sock(xdccb)) .sockclose xdccb
  if ($hget(xdccboptions,Binvar,&temp)) hdel xdccboptions Binvar
  unset %xdccb-searchnetwork %xdccb-searchnick %xdccb-searchMaxcps %xdccb-searchQueue %xdccb-searchchan %xdccb-searchNext %xdccb-searchServer
  if ($hget(Xdccboptions,next) != 0) {
    did -ra xdccb 211 Getting results
    .timerXdccb-socket 1 5 sockopen xdccb $hget(Xdccboptions,site) 80
    xdccb-addoption Next 0
    if ($timer(xdccb-stopsocket)) .timerxdccb-stopsocket off
  }
}
Alias -l Xdccb-Stopsocket {
  if ($sock(xdccb)) .sockclose xdccb
  if ($timer(Xdccb-socket)) .timerXdccb-socket off 
  if ($dialog(xdccb)) {
    did -ra xdccb 211,711 Done
    did -ra xdccb 710 1 0 1
    var %num = $calc($did(xdccb,207).lines -1)
    did -ra xdccb 205 $iif(%num = 1,%num Result,%num Results)
  }
  if ($hget(xdccboptions,Binvar,&temp)) hdel xdccboptions Binvar
  unset %xdccb-searchnetwork %xdccb-searchnick %xdccb-searchMaxcps %xdccb-searchQueue %xdccb-searchchan %xdccb-searchNext
}
alias -l Xdccb-Queues {
  var %time
  var %file = $qt($+($scriptdir\Xdccb-queues-,$2,.txt))
  var %a = 1
  while ($read(%file,s,$1,%a)) {
    var %ifmatch = $v1
    var %line = $gettok(%ifmatch,$+(1-,$calc($numtok(%ifmatch,32) -1)),32)
    var %position = $numtok(%line,32)
    if (remove isin %line) var %position = $calc($findtok(%line,remove,1,32) -2)
    var %line = $gettok(%line,$+(1-,%position),32) 
    if (*Queued *h*m for "*"* in *position * of * remaining* iswm %line) {
      var %position $calc($findtok(%line,position,1,32) +1)
      return Que: $replace($remove($gettok(%line,$+(%position,-,$calc(%position + 2)),32),$chr(46)),of,/)
    }
    elseif (You have been queued isin %line) {
      var %position = $calc($findtok(%line,position,1,32) +1)
      return Que: $replace($remove($gettok(%line,$+(%position,-,$calc(%position + 2)),32),$chr(46)),of,/)
    }  
    elseif (*All Slots Full, Added * to the main queue * iswm %line) {
      var %position = $calc($findtok(%line,position,1,32) +1)
      return Que: $remove($gettok(%line,%position,32),$chr(46))
    }
    elseif (XDCC: Adding your file to queue slot isin %line) {
      var %position = $calc($findtok(%line,slot,1,32) +1)
      return Que: $remove($gettok(%line,%position,32),$chr(46))
    }
    elseif (XDCC: That file has already been queued in slot isin %line) {
      var %position = $calc($findtok(%line,slot,1,32) +1)
      return Que: $remove($gettok(%line,%position,32),$chr(33))
    }
    elseif (*Queu* It has been placed in queue* available* iswm %line) {
      var %position = $calc($findtok(%line,slot,1,32) +1)
      if ($remove($gettok(%line,%position,32),$chr(35),$chr(44)) != [) return Que: $v1
      else return Que: $remove($gettok(%line,$calc(%position + 1),32),$chr(35),$chr(44))
    }
    elseif (*you for pack* in slot* iswm %line) {
      var %position = $calc($findtok(%line,slot,1,32) +1)
      return Que: $gettok($gettok(%line,%position,32),1,47)
    }
    elseif (Sorry* that file already exists in queue slot* Try and get another file* iswm %line)  {
      var %position = $calc($findtok(%line,slot,1,32) +1)
      return Que: $remove($gettok(%line,%position,32),$chr(35),$chr(46))
    }
    elseif (*you already* this file queued in slot* iswm %line) {
      var %position = $calc($findtok(%line,slot,1,32) +1)
      return Que: $remove($gettok(%line,%position,32),$chr(35),$chr(46))
    }
    var %a = $readn
    inc %a 
  }
}
alias -l Xdccb-update {
  if ($dialog(xdccb)) {
    var %a = 2
    while ($did(xdccb,308,%a)) {
      var %v1 = $v1
      var %nick = $did-list(6,%v1)
      var %chan = $did-list(7,%v1)
      var %network = $did-list(8,%v1)
      var %order = $remove($did-list(5,%v1),st,nd,rd,th)
      var %old-stat = $did-list(4,%v1)
      var %stat = $Xdccb-stats(%nick,%network,%chan,%order)
      if (%old-stat != $gettok(%stat,1,9)) {
        did -o XDCCb 308 %a $puttok($puttok($did-list(1-9,%v1),$gettok(%stat,2,9),2,32),$gettok(%stat,1,9),4,9)
      }
      inc %a
    }
    var %a = 2
    while ($did(xdccb,501,%a)) {
      var %v1 = $v1
      var %file = $did-list(1,%v1)
      var %status = $did-list(2,%v1)
      var %size = $did-list(5,%v1)
      var %nick = $did-list(7,%v1)
      var %path = $did-list(8,%v1)
      var %flags = $gettok(%v1,2,32)
      var %icon = $gettok(%v1,3,32)
      var %check
      var %b = 1 
      while ($get(%nick,%b)) {
        if ($get(%nick,%b).file = %file) {
          var %check = yeap
          var %sec = $replace(%file,[,$chr(60),],$chr(62))
          if ($get(%nick,%b).status = active) {
            var %rcvd = $get(%nick,%b).rcvd
            var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
            var %cps = $get(%nick,%b).cps
            if (%size != $get(%nick,%b).size) {
              writeini -n $qt(%Xdccb-Downloads.ini) %sec Size $v2
              var %size = $v2
            }
            var %left = $duration($round($calc( (%size - %rcvd) / %cps),0))
            var %cps = $iif(%cps < 1024,%cps b/s,$bytes(%cps,k) Kb/s)
            did -o xdccb 501 %a %flags 2 %File $chr(9) %status $chr(9) %left $chr(9) %cps $chr(9) %size $chr(9) %rcvd $chr(9) %nick $chr(9) %Path
          }
          elseif ($get(%nick,%b).status = failed) && (%icon = 2) {
            var %rcvd = $file($+(%path,%file)).size
            if (!%rcvd) {
              did -d xdccb 501 %a
              remini -n $qt(%Xdccb-Downloads.ini) %sec
              dec %a
            }
            else {
              var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
              var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
              did -o xdccb 501 %a %flags $iif(!$ini(%xdccgets.ini,%nick2),4,3) %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) %nick $chr(9) %Path
            }  
            Xdccb-close-get $get(%nick,%b).wid 
            break    
          }
          elseif ($get(%nick,%b).done) && (%icon != 1) {
            var %rcvd = $get(%nick,%b).rcvd
            var %sec = $replace(%file,[,$chr(60),],$chr(62))
            var %Path = $readini(%Xdccb-Downloads.ini,%sec,Path)
            did -o xdccb 501 %a %flags 1 %File $chr(9) 100% $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) %nick $chr(9) %Path
          }
        }
        inc %b
      }
      if (!%check) && (%icon = 2) {
        var %sec = $replace(%file,[,$chr(60),],$chr(62))
        var %rcvd = $file($+(%path,%file)).size
        if (!%rcvd) {
          did -d xdccb 501 %a
          remini -n $qt(%Xdccb-Downloads.ini) %sec
          continue
        }
        else {
          var %status = $+($round($calc((%rcvd / %size) * 100),1),%)
          var %nick2 = $replace(%nick,[,$chr(60),],$chr(62))
          did -o xdccb 501 %a %flags $iif(!$ini(%xdccgets.ini,%nick2),4,3) %File $chr(9) %status $chr(9) n/a $chr(9) n/a $chr(9) %size $chr(9) %rcvd $chr(9) %nick $chr(9) %Path
        }  
      }
      inc %a
    }
  }
  else .timerXdccb-update off
}
Alias -l xdccb-Userinput {
  .dll $qt($scriptdir/UserInput.dll) start 1 0 0
  :error 
  reseterror
}
Alias XDCCbview-file {
  if (!$dialog(XDCCb-lists)) dialog $hget(Xdccboptions,Mode) XDCCb-lists XDCCb-lists
  did -c XDCCb-lists 200
  did -fr XDCCb-lists 27
  did -i XDCCb-lists 27 1 seticon normal 1 0, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i XDCCb-lists 27 1 seticon normal 2 1, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -i XDCCb-lists 27 1 seticon normal 3 12, $+ $findfile($scriptdir,Xdccb-Icons.icl,1)
  did -ra XDCCb-lists 10 Preview list
  did -e XDCCb-lists 27
  did -o XDCCb-lists 4 2 +cgW 85 1 Auto save
  did -o XDCCb-lists 4 3 +cgxW 85 2 View list
  var %ontop
  if (o isin $hget(Xdccboptions,Mode)) && ($dialog(xdccb)) {
    dialog -n xdccb
    var %ontop = yeap
  }
  var %check = $1-
  if (!%check) var %check = $sfile($+(",$scriptdir,%text,*.xcb"),Load file:,Load)
  if (!%check) return
  if (%ontop) dialog -o xdccb 
  did -r XDCCb-lists 27
  var %a = 1
  var %num = 0
  did -ra xdccb-lists 10 $qt(%check)
  var %a = 1
  while ($ini(%check,%a)) {
    var %get = $v1
    if (-data isin %get) XDCCbview-file-write $remove(%get,XDCCb-,-data) %check
    inc %a
  }
  if ($dialog(Xdccb-Processbar)) dialog -k Xdccb-Processbar
  var %time = $file(%check).ctime
  did -ra XDCCb-lists 42 $asctime(%time,dd/mmm/yy)
  did -ra XDCCb-lists 44 $asctime(%time,HH:nn:ss)
}
Alias -l XDCCbview-file-write {
  var %network = $1 
  var %file = $2-
  if (!$dialog(Xdccb-Processbar)) dialog -m xdccb-processbar Xdccb-Processbar
  dialog -t Xdccb-Processbar Loading List Data ... %network
  if (!$Find-branch(XDCCb-lists,27,%Network)) did -a XDCCb-lists 27 +eb 1 1 %Network $chr(9) Click on the network for a list of channels.
  var %root = $Find-branch(XDCCb-lists,27,%network)
  var %hash = $+(xdccb-,%network,-data)
  var %num = 1
  window -h @Xdccb-view
  loadbuf $+(-rt,%hash) @Xdccb-view $qt(%file)
  did -a Xdccb-Processbar 1 0 0 $fline(@xdccb-view,*˙Chan*,0)
  var %a = 1 
  while ($line(@xdccb-view,$fline(@xdccb-view,*˙Chan*,%a))) {
    dll $qt($scriptdir\WhileFix.dll) WhileFix 
    inc %num
    did -a Xdccb-Processbar 1 %num
    var %chan = $gettok($v1,-1,61)
    var %nick = $gettok($v1,1,255)
    if (!$Find-branch(xdccb-lists,27,%chan,%root)) did -a XDCCb-lists 27 + 2 2 %chan $chr(9) Click on the channel for a list of nicks.
    var %chan-num = $Find-branch(xdccb-lists,27,%chan,%root)
    did -i XDCCb-lists 27 1 cb root %root %chan-num
    did -a XDCCb-lists 27 +b 3 3 $replace(%nick,$chr(60),[,$chr(250),[,$chr(62),],$chr(251),]) $chr(9) Click on the nick for a list of packs.
    did -i XDCCb-lists 27 1 cb root %root
    inc %a
  }
  window -c @xdccb-view
  did -i XDCCb-lists 27 1 cb root 1
}
Alias -l XDCCr8 {
  var %b = 1
  did -r XDCCb 308
  while ($ini(%xdccgets.ini,%b)) {
    var %v1 = $v1
    var %nick = $replace($v1,$chr(60),[,$chr(62),])
    var %chan = $readini(%xdccgets.ini,$v1,Chan)
    var %server = $readini(%xdccgets.ini,$v1,server)
    var %network = $gettok($readini(%xdccgets.ini,$v1,network),1,46)
    var %get = $readini(%xdccgets.ini,$v1,get)
    if (%network) {
      var %a = 1
      while ( $readiniwm(%xdccgets.ini,%v1,File server*,%a) ) {
        did -a XDCCb 308 + 8 0 0 $v1 $chr(9) n/a $chr(9) n/a $chr(9) n/a $chr(9) %nick $chr(9) %chan $chr(9) %network $chr(9) %server
        inc %a
      }
      var %a = 1
      while ($readiniwm(%xdccgets.ini,%v1,Pack*,%a) ) {
        var %pack = $v1
        var %order = $iif($calc(%a - %get +1) > 0,$v1,Finished)
        var %stat = $Xdccb-stats(%nick,%network,%chan,%order)
        did -a XDCCb 308 + $gettok(%stat,2,9) 0 0 $gettok(%pack,1-3,9) $chr(9) $gettok(%stat,1,9) $chr(9) $ord(%order) $chr(9) %nick $chr(9) %chan $chr(9) %network $chr(9) %server
        inc %a
      }
    }
    inc %b
  }
  xdccb-sort-308
}
Alias -l XDCC-RequestList {
  var %a = 1
  var %net = $gettok($network,1,46)
  while (%a < $nick($1,0,v)) {
    var %nick = $nick($1,%a,v)
    if ($regex($right(%nick,3),/[0-9]/)) && ($regex(%nick,/[A-Z]/)) && (!$hfind($+(XDCCb-,%net),$+(%nick,*),1,w)) $+(.Timer,xdcc-list,%a) 1 $calc(%a * 20) /.ctcp %nick VERSION
    inc %a
  }
}
Alias -l xPack {
  if ($0 = 0) return
  tokenize 32 $strip($1-))
  var %pack
  var %gets = [ [ $+($,$calc($0 -1)) ] ]
  if (Get isin $1-) {
    var %format = (#*)
    if (%format iswm $1-) {
      ; (#*) - *  - * (*gets)
      ; (#14) - PAcket name - 6.6MB (27 gets)
      ; Invision XDCC
      var %format = - * - * (*gets)
      if (%format iswm $2-) {
        return [ [ $+($,3,-,$calc($0 - 4)) ] ]  $chr(9) $remove($1,$chr(40),$chr(41),$chr(35)) $chr(9) [ [ $+($,$calc($0 -2)) ] ] $chr(9) $remove(%gets,$chr(40)) 
      }

      ;(#*) Ğ*ğ (*gets)
      ; (#9) Ğ67.3MBğ    Packet name - (0 gets)
      ;  xSystemX
      var %format = Ğ*ğ * (*gets)
      if (%format iswm $2-) {
        var %gets = [ [ $+($,$calc($0 -1)) ] ]
        return [ [ $+($,3,-,$calc($0 -1)) ] ] $chr(9) $remove($1,$chr(40),$chr(41),$chr(35)) $chr(9) $remove($2,Ğ,ğ) $chr(9) $remove(%gets,$chr(40))
      }

      ;(#*) (*B) (*gets)
      ; (#9) (67.3MB)    Packet name - (0 gets)
      ;  xSystemX
      var %format = (*) * (*gets)
      if (%format iswm $2-) {
        var %gets = [ [ $+($,$calc($0 -1)) ] ]
        return [ [ $+($,3,-,$calc($0 -1)) ] ] $chr(9) $remove($1,$chr(40),$chr(41),$chr(35)) $chr(9) $remove($2,$chr(40),$chr(41)) $chr(9) $remove(%gets,$chr(40))
      }
    }

    ; *#* Ğ*ğ * - * (*gets)
    ; #4 Ğ765 MBğ Packet name - (1 gets)
    ; Invision XDCC
    var %format = *#* Ğ*ğ *- (* gets)
    if (%format iswm $1-) {
      if (*Bğ iswm $3 ) return [ [ $+($,4-,$calc($0 -3)) ] ] $chr(9) $remove($1,$chr(35)) $chr(9) $remove($2-3,Ğ,ğ) $chr(9) $remove(%gets,$chr(40))
      var %check =  [ [ $+($,3-,$calc($0 -3)) ] ]
      return %check $chr(9) $remove($1,$chr(35)) $chr(9) $remove($2,Ğ,ğ) $chr(9) $remove(%gets,$chr(40))
    }

    ; [#*] * (* *b,* gets)
    ; [#1] File name.zip (454.7 mb, 9 gets)
    var %format = [#*] * (*b,* gets)
    if (%format iswm $1-) {
      var %end = $gettok($2-,$numtok($2-,40),40)
      if (b isin $gettok(%end,2,44)) var %end2 = $replace(%end,$chr(44),$chr(46),$+($chr(46),$chr(32)),$+($chr(44),$chr(32)))
      else var %end2 = %end
      return $remove($gettok($2-,$+(1-,%end),40),%end,$chr(40),$chr(41)) $chr(9) $remove($1,[,],$chr(35)) $chr(9) $gettok(%end2,1,44) $chr(9) $gettok($gettok(%end2,2,44),1,32)
    }

    ;Ğ#*ğ [*B] Ğ*ğ [*]ĞGetsğ
    ; Ğ#5ğ [151.16MB] ĞPacket name hereğ [0]ĞGetsğ
    var %format = Ğ#*ğ [*B] Ğ*ğ [*]ĞGetsğ
    if (%format iswm $1-) {
      var %gets = $right($gettok($eval($+($,$calc($0 -1)),2),1,93),-1)
      return $left($right($eval($+($,3,-,$calc($0 -1)),2),-1),-1) $chr(9) $remove($1,Ğ,ğ,$chr(35)) $chr(9) $remove($2,$chr(93),$chr(91)) $chr(9) %gets
    }

    ;[#*] [*] - * [*gets]
    ;[#1] [333.6MB] - Packet name [4 Gets]
    ;SysReset 2.53
    var %format = [#*] [*] - * [*gets] 
    if (%format iswm $1-) {
      return [ [ $+($,4-,$calc($0 - 2)) ] ] $chr(9) $remove($1,[,],$chr(35)) $chr(9) $remove($2,[,],_) $chr(9) $remove(%gets,[)
    }

    ; % #* (*: * get*)*
    ; % #2  (733.88mb:   8 gets) Packet name
    ; cypress/cdcc
    var %format = $chr(37) #* (*: * get*)*
    if (%format iswm $1-) {
      return $6- $chr(9) $remove($2,$chr(35)) $chr(9) $remove($3,$chr(40),$chr(58)) $chr(9) $4 
    }

    ; (Pack #25) : Packet name | 1 meg's | Gets : (0)X
    ; ISOS XDCC Server
    var %format = (Pack #*) : * $chr(124) * $chr(124) * : * 
    if (%format iswm $1-) {
      return $gettok($4-,1,124) $chr(9) $remove($2,$chr(35),$chr(41)) $chr(9) $gettok($3-,2,124) $chr(9) $remove($gettok($gettok($3-,3,124),3-,32),$chr(40),$chr(41),x)
    }

    ;#10 874.6Kb - Packet name (8gets)
    var %format = #* *b -* (*gets)
    if (%format iswm $1-) {
      return $gettok($4-,$+(1-,$calc($0 -1)),32) $chr(9) $remove($1,$chr(35)) $chr(9) $2 $chr(9) $remove($eval($+($,$0),2),get,s,$chr(40),$chr(41))
    }
  }
  if (x isin $1-) {
    if (#?* iswm $1) {
      ; #?* *x [*?*] *
      ; #1 14x [ 50M] a_file.zip
      ; iroffer
      var %format = *x [*?*] *
      if (%format iswm $2-6) {
        if ( $3 == $chr(91) ) return $5- $chr(9) $remove($1,$chr(35)) $chr(9) $remove($4,[,]) $chr(9) $remove($2,x)
        else return $4- $chr(9) $remove($1,$chr(35)) $chr(9) $remove($3,[,]) $chr(9) $remove($2,x)
      }

      ;#?* [*x] Ğ*bğ *
      ;#2 [0x] Ğ11.1Mbğ packet name
      var %format = *[*x] Ğ*bğ *
      if (%format iswm $2-4) {
        return $4- $chr(9) $remove($1,$chr(35)) $chr(9) $remove($3,Ğ,ğ) $chr(9) $remove($2,[,x])
      }

      ; #37 (149.46mb) [divx] ğğ Packet name - (0x)
      ; Nightvision 2.2.3
      var %format = *(*) [*] ğğ * - (*x)
      if (%format iswm $2-) {
        return $gettok($3-,$+(1-,$calc($0 -1)),32) $chr(9) $remove($1,$chr(35)) $chr(9) $remove($2,,$chr(40),$chr(41)) $chr(9) $remove($eval($+($,$0),2),x,$chr(40),$chr(41))
      }

      ; #10 (784.84mb) ğğ Packet name - (0x)
      ; acidmax
      var %format = *(*) ğğ * - (*x)
      if (%format iswm $2-) {
        return $gettok($4-,$+(1-,$calc($0 -1)),32) $chr(9) $remove($1,$chr(35)) $chr(9) $remove($2,$chr(40),$chr(41)) $chr(9) $remove($eval($+($,$0),2),x,$chr(40),$chr(41))
      }

      ; #*/*x * [* file/* *B/min *B/s]
      ; #1/75x  Packet name [1 file/10.82 MB/min 10.00 kB/s]
      var %format = #*/*x *[* file/* *B/min *B/s]
      if (%format iswm $1-) {
        var %gets = [ [ $+($,$calc($0 - 3 )) ] ] [ [ $+($,$calc($0 - 2 )) ] ]
        return [ [ $+($,2-,$calc($0 - 5)) ] ] $chr(9) $remove($gettok($1,1,47),$chr(35)) $chr(9) $gettok($gettok(%gets,1,32),2,47) $gettok($gettok(%gets,2,32),1,47) $chr(9) $remove($gettok($1,2,47),x)
      }

      ;#?* *x Ğ*bğ *
      ;#2 0x Ğ202 Mbğ packet name
      var %format = *x Ğ*bğ *
      if (%format iswm $2-) {
        return $4- $chr(9) $remove($1,$chr(35)) $chr(9) $remove($3,Ğ,ğ) $chr(9) $remove($2,x)
      }

      ;#?* (*x|*b) - *
      ;#32 (4x|320.3Mb) - Packet name
      var %format = (*x|*b) - *
      if (%format iswm $2-) {
        return $4- $chr(9) $remove($1,$chr(35)) $chr(9) $remove($gettok($2,2,124),$chr(41)) $chr(9) $remove($gettok($2,1,124),$chr(40),x) 
      }

    } 
    if ([#*]* iswm $1-) {
      ;[#*] - * - *B [*x]
      ;[#86] - Packet name- 526MB [0x]
      ; ĞDEMONğ script
      var %format = -* *- *B [*x]
      if (%format iswm $2-) {
        var %gets = [ [ $+($,$0)) ] ]
        return [ [ $+($,3-,$calc($0 -3)) ] ] $chr(9) $remove($1,[,],$chr(35)) $chr(9) [ [ $+($,$calc($0 - 1)) ] ] $chr(9) $remove(%gets,[,],x)
      }

      ; [#*] - [*x/*] *
      ; [#12] - [1x/455.6Mb] [Packet name] - [TS]
      ; KVcd-script  
      var %format = [*x/*] *
      if (%format iswm $3-) {
        return $4- $chr(9) $remove($1,[,],$chr(35)) $chr(9) $remove($gettok($3,2,47),$chr(93)) $chr(9) $remove($gettok($3,1,47),$chr(91),x)
      }

      ; [#*] (*x|*) - *
      ; [#13] (0x|639.8Mb) - Packet name
      ; · P o l a r i s · O n e ·
      var %format = (*x|*) - *
      if (%format iswm $2-) {
        return $4- $chr(9) $remove($1,[,],$chr(35)) $chr(9) $remove($gettok($2,2,124),$chr(41)) $chr(9) $remove($gettok($2,1,124),$chr(40),x)
      }

      ;[#*] (*|*x) *..::*::..
      ;[#26] (1.38GB|0x) Description..::Pack Name::..
      var %format = (*|*x) *..::*::..
      if (%format iswm $2-) {
        return $deltok($gettok($3-,2-,58),-1,58) $chr(9) $remove($1,[,],$chr(35)) $chr(9) $remove($gettok($2,1,124),$chr(40)) $chr(9) $remove($gettok($2,2,124),$chr(41),x)
      }

      ;[#*] *..::*::.. Size..::*::.. Gets..::*::..
      ;[#8] [Type]..::Pack Name::.. Size..::700mb::.. Gets..::1::..
      var %format = *..::*::.. Size..::*::.. Gets..::*::..
      if (%format iswm $2-) {
        return $deltok($gettok($1-,2-,58),-5-,58) $chr(9) $remove($1,[,],$chr(35)) $chr(9) $gettok($1-,-4,58)) $chr(9) $gettok($1-,-2,58))
      }

      ;[#*] Description..::*::.. Size..::*::.. Downloads..::*::..
      ;[#1] Description..::File Name::.. Size..::776MB::.. Downloads..::0::..
      ;UPP
      var %format = Description..::*::.. Size..::*::.. Downloads..::*::..
      if (%format iswm $2-) {
        return $deltok($gettok($1-,2-,58),-5-,58) $chr(9) $remove($1,[,],$chr(35)) $chr(9) $gettok($1-,-4,58)) $chr(9) $gettok($1-,-2,58))
      }

      ;[#*] (*|*x) - Description:[*]
      ;[#42] (62.8kb|9x) - Description:[Pack name]
      var %format = (*|*x) - Description:[*]
      if (%format iswm $2-) {
        return $right($left($gettok($4-,2-,58),-1),-1) $chr(9) $remove($1,[,],$chr(35)) $chr(9) $remove($gettok($2,1,124),$chr(40)) $chr(9) $remove($gettok($2,2,124),$chr(41),x)
      }

      ;[#*] (*|*x) .:[*] 
      ;[#4] (697mb|0x) .:[Pack Name]
      var %format = (*|*x) .:[*]
      if (%format iswm $2-) {
        return $left($gettok($3-,2-,91),-1) $chr(9) $remove($1,[,],$chr(35)) $chr(9) $remove($gettok($2,1,124),$chr(40)) $chr(9) $remove($gettok($2,2,124),$chr(41),x)
      }
    }

    ; (*) [*x] - *M* -* 
    ; (02) [317x] - 349M - Packet name
    var %format = (*) [*x] - *M* -*
    if (%format iswm $1-) {
      return $6- $chr(9) $calc($remove($1,$chr(40),$chr(41),$chr(35))) $chr(9) $4 $chr(9) $remove($2,$chr(91),$chr(93),x)
    }

    ; *#?* *x [*?*] * 
    ; *#2 3x [0.5M] Packet name 
    ; T7XDCcT 
    var %format = ?#?* *x [*?*] *
    if (%format iswm $1-) && ($left($1,1) = *) {
      return $4- $chr(9) $remove($1,$chr(35),$chr(42)) $chr(9) $remove($3,[,]) $chr(9) $remove($2,x)
    }

    ;#* *x *B*
    ;#11 0x 50.1MB Packer Name 
    if (#* iswm $1) && (*x iswm $2) && (*b iswm $3) && ($4-) {
      return $4- $chr(9) $remove($1,$chr(35)) $chr(9) $3 $chr(9) $remove($2,x)
    }
    ;ĞĞ [#*] (*x|*) - *
    ;ĞĞ [#9] (0x|535.2Mb) - Packet name here
    ;Excursion
    var %format = ĞĞ *[#*] (*x|*) - *
    if (%format iswm $1-) {
      return $5- $chr(9) $remove($2,[,],$chr(35)) $chr(9) $remove($gettok($3,2,124),$chr(41)) $chr(9) $remove($gettok($3,1,124),$chr(40),x)
    }

    ;ĞĞ [#*] *x*b *
    ;ĞĞ [#9] 0x535.2Mb Packet name here
    ;Excursion
    var %format = ĞĞ [#*] *x*b*
    if (%format iswm $1-) && (x isin $3) && ($right($gettok($1-,1,160),1) = b) {
      return $iif($gettok($1-,2-,160),$v1,$4-) $chr(9) $remove($2,[,],$chr(35)) $chr(9) $gettok($gettok($3,2,120),1,160) $chr(9) $gettok($3,1,120)
    }
  }

  ;#8: (Description comes here), size: [5,6 megs], Filename comes here.tar
  var %format = #*: *, Size: [* *], *
  if (%format iswm $1-) {
    var %place = $findtok($2-,Size:,1,32)
    return $left($eval($+($,2-,%place),2),-1) -> $eval($+($,$calc(%place + 4),-),2) $chr(9) $remove($1,:,$chr(35)) $chr(9) $gettok($replace($remove($eval($+($,$calc(%place + 2),-,$calc(%place + 3)),2),[,]),$chr(44),$chr(46)),1-2,46)
  }

  ; #?* *?* :: *?*
  ; #1 File Mame.zip :: description
  ; eirc XDCC
  var %format = #?* *?* :: *?*
  if (%format iswm $1-) {
    return $2- $chr(9) $remove($1,$chr(35)) $chr(9) n/a $chr(9) n/a
  }

  ; Lists:
  ;

  ; (XDCC) Packs:(8) Trigger:(/msg BG|dowho XDCC list) Sends:(4/4) Queues:(1/25) Record:(1773.5KB/s) Note:(Xdcc bot of #gambler@irc.sony.com) =iroffer=
  ; (XDCC) * Trigger:(*) =iroffer=
  ; Iroffer
  var %format = (XDCC) * Trigger:(*) =iroffer=
  if (%format iswm $1-) {
    tokenize 32 $gettok($gettok($1-,$+($findtok($1-,$wildtok($1-,Trigger:*,1,32),1,32),-),32),2-,47)
    var %check = $gettok($1-,1,41)
    return List %check
  }

  ; [XDCC active] You have access to the following pools: Stellvia, Kyogoni. Use: /ctcp sssr XDCC LIST <poolname> to list XDCC Files for one XDCC pool. - SysReset 2.50
  ; [XDCC Active] * pools:* Use: * - SysReset *
  ; SysReset 2.50
  var %format = [XDCC Active] * pools:* Use: * - SysReset * 
  if (%format iswm $1-) {
    var %pools = $gettok($10-,1,46)
    var %check = $gettok($gettok($1-,$+($findtok($1-,$wildtok($1-,Use:*,1,32),1,32),-),32),2-,47)
    var %check = $gettok(%check,1,62)
    var %num = $numtok(%pools,32)
    var %a = 1
    while (%a <= %num) {
      addPacket $nick $+(List,%a) $replace(%check,<poolname,$iif(%a < %num,$left($gettok(%pools,%a,32),-1),$gettok(%pools,%a,32)))
      inc %a
    }
  }

  ; [XDCC Active] - Sends:[1/1] - Queues:[5/10] - Bytes Sent:[8.24GB] - Files Sent:[89] - List Trigger:[/ctcp Vtx-Nf2003 XDCC LIST DVD-RIPS!] - SysReset 2.53
  ; [XDCC Active] * Trigger:[*] - SysReset *
  ; SysReset 2.53
  var %format = [XDCC Active] * Trigger:[*] - SysReset *
  if (%format iswm $1-) {
    tokenize 32 $gettok($gettok($1-,$+($findtok($1-,$wildtok($1-,Trigger:*,1,32),1,32),-),32),2-,47)
    var %check = $gettok($1-,$+(1,-,$calc(1 + $regex($nick,$chr(93)) )),93)
    return List %check
  }
}
Alias -l XUsage {
  tokenize 32 $strip($1-)

  ;SysReset 2.53
  ; Usage: /ctcp Nick XDCC GET Blah!-Blah #<Pack number>
  if ($2 = Usage:) && (($3 = /ctcp) || ($3 = /msg)) {
    var %usage = $gettok($3-,$+(1-,$calc($numtok($3-,35) -1)),35)
    goto end
  }

  ;invision
  ; Type:/ctcp Nick XDCC Send #<Pack number> I-n-v-i-s-i-o-n
  if (Type: isin $2) && ((/ctcp isin $2-3) || (/msg isin $2-3)) {
    var %usage = $gettok($gettok($2-,2,58),$+(1-,$calc($numtok($3-,35) -1)),35)
    goto end
  }

  ; Every line that goes something like "To Request/Get a file...."
  var %check1 = *To request* file* type* $+(*,$chr(35),*)
  var %check2 = *To get* file* type* $+(*,$chr(35),*)
  var %check3 = *To download* file* type* $+(*,$chr(35),*)
  if (%check1 iswm $1-) || (%check2 iswm $1-) || (%check3 iswm $1-) {
    var %start = $+($findtok($1-,$matchtok($1-,type,1,32),1,32),-)
    var %end = $calc($findtok($1-,$matchtok($1-,$chr(35),$calc($numtok($1-,35) -1),32),1,32) -1)
    var %usage = $remove( $gettok($gettok($1-,$+(%start,%end),32),2-,47),")
    var %usage = $+(/.,%usage)
    goto end
  }

  ;excursion
  ;ĞĞ Syntax: /DCCALLOW +Nick And /CTCP Nick XDCC SEND #<Pack number>
  if ($3 = Syntax:) && (#<Pack number> isin $1-) {
    if (And isin $1-) {
      var %usage = $gettok($gettok($2-,$+($calc($findtok($2-,and,1,32) +1),-,$0),32),1,35)
      goto end
    }
    else {
      var %usage = $gettok($5-,$+(1-,$calc($numtok($3-,35) -1)),35)
      goto end
    }
  }

  ;Nightvision 2.2.3
  ; ğğ receive file: /ctcp BrooklynStarr XDCC send #<pack number> 
  if ($2-4 = ğğ receive file:) && (#<Pack number> isin $1-) {
    var %usage = $gettok($5-,$+(1-,$calc($numtok($3-,35) -1)),35)
    goto end
  }

  ;T7XDCCT
  ;* T7XDCCT SERVING - To request a file type: "/msg ]3[X|1010 XDCC send #x" *
  ;** T7XDCcT To request a file use:"/msg [3XDCc]122204 XDCC send #x" **
  if (T7XDCCT isin $1-) && (To request a file isin $1-) {
    var %usage = $gettok($gettok($gettok($1-,-6-,32),2,34),$+(1-,$calc($numtok($3-,35) -1)),35)
    goto end
  }

  ; ĞType:ğ[/ctcp B-XDCC-Frost XDCC Send #<pack number>]
  if (ĞType:ğ isin $1-) && (#<pack number> isin $1-) {
    var %usage $gettok($gettok($1-,2-,91),$+(1-,$calc($numtok($3-,35) -1)),35)
  }

  if (!%usage) return

  :end
  var %usage = $replace(%usage,/msg,/.msg,/ctcp,/.ctcp)
  hadd -m $+(XDCCb-,$gettok($network,1,46)) $+($nick,$chr(255),Usage) %usage
  return yeap
}
Alias -l fpack {
  tokenize 32 $strip($1-)
  var %network = $gettok($network,1,46)
  var %check = nope

  ; [Fserve Active] - Triggers:[/ctcp EMP-FS102 Anime & /ctcp EMP-FS102 Warez] - Users:[1/5] - Sends:[0/1] - Queues:[0/10] - Record CPS:[43.1kB/s by insanedesio] - Bytes Sent:[700.6MB] - Files Sent:[51] - Accesses:[42] - Upload Speed:[0B/s] - Current Bandwidth:[0B/s]
  ; SysReset 2.53
  if ([Fserve Active] isin $1-5) && ((Trigger:[ isin $1-) || (Triggers:[ isin $1-)) {
    var %triggers = $gettok($gettok($gettok($1-,2-,93),1-,32),2-,91)
    Xdccb-Fservtrigger 38 91 93 %triggers
    return yeap
  }

  ; [Fserve] Triggers:[/ctcp Max-sama 1 & /ctcp Max-sama Detective Conan & /ctcp Max-sama [ASS] Gun Frontier]  Sends:[1/2] Queues:[1/10] On server:[Anime] Note:[I using BT, so... it's slow.] Ğ~{Polaris CTCP}~ğ
  ; Polaris
  if (*[Fserve] Trigger*:[* iswm $1-2) {
    var %t-end = $findtok($1-,$wildtok($1-,sends:*,1,32),1,32)
    var %triggers = $gettok($gettok($gettok($eval($+($,1-,$calc(%t-end -1)),2),2-,93),1-,32),2-,91)
    var %topic = $eval($+($,%t-end,-),2) 
    Xdccb-Fservtrigger 38 91 255 %triggers
    if (%topic) hadd $+(XDCCb-,%network,-data) $+($nick,$chr(255),File ServT) %topic
    return yeap
  } 

  if (ĞĞ Server ğğ = $1-3) {
    ;ĞĞ Server ğğ Trigger-[/ctcp john_316 !pistons]- Used-[19619 cps]- Next.Send-[00:28:13]- Stole-[85.59Gb in 442 files]- Min.CPS-[10]- Record-[29.3Kb/s by chiefsmackahoe]- Sends-[1/1]- Queues-[2/150]- Entered-[1717 times]- Note-[jonjons movies]- Ğ ?Ş??�§??? ğ
    ;Excursion
    if ((*Trigger?[* iswm $1-) || (*Triggers?[* iswm $1-)) {
      var %triggers = $gettok($1-,2-,91)
      Xdccb-Fservtrigger 238 91 93 %triggers
      return yeap
    }

    ;ĞĞ Server ğğ Trigger<!Lots-more-mp3z> Used<0 cps> Next.Send<Open> Stole<1.61Gb in 264 files> Record<14.4Kb/s by brio> Sends<0/4> Queues<0/4> Entered<355 times> Note<Type Trigger To Get On Fserve> Ğ ?Ş??�§??? ğ
    ;Excursion
    if ((*Trigger<* iswm $1-) || (*Triggers<* iswm $1-)) {
      var %triggers = $gettok($1-,2-,60)
      Xdccb-Fservtrigger 238 60 62 %triggers
      return yeap
    }

    ;ĞĞ Server ğğ Trigger-{itha innu muthal}- Used-{42965 cps}- Next.Send-{05:36:28}-Stole-{592.22Gb in 1663 files}- Record-{44.9Kb/s by pks}- Sends-{2/2}- Queues-{2/10}-Entered-{7592 times}- Note-{!!!! NEW !!!! AKALE !! VAJRAM !! JALOLSAVAM !! CHATHIKKATHACHANDU !! Chakram !! Runway !!! Salperu ramankutty !!}- Ğ ?Ş??�§?on ğ
    ;Excursion
    if (($+(*Trigger,?,$chr(123),*) iswm $1-) || ($+(*Triggers,?,$chr(123),*) iswm $1-)) {
      var %triggers = $gettok($1-,2-,123)
      Xdccb-Fservtrigger 238 123 125 %triggers
      return yeap
    }
  }
  if (*File Server* Online* iswm $1-3) {
    ; File Server Online Triggers:Ğ/ctcp TMD-shorty m�-möVîz-ċ�-|{öö£ğ Sends:Ğ1/1ğ Queues:Ğ9/10ğ Accessed:Ğ2458 timesğ Online:Ğ0/4ğ RCPS:Ğ29524cps by Hakubaiğ Served:Ğ65601113132B in 451 filesğ Current BW:Ğ0cpsğ AQT:Ğ2hrs 35minsğ Serving:Ğ49 filesğ I-n-v-i-s-i-o-n 
    ; invision
    if (*Triggers:Ğ* iswm $1-) {
      var %triggers = $right($gettok($gettok($1-,1,187),4-,32),-10)
      var %topic = $gettok($1-,2-,187)
      var %a = 1
      while ($gettok(%triggers,%a,149)) { 
        var %pack = $v1
        addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %a File Server %pack 
        inc %a
      }
      if (%a > 0) hadd $+(XDCCb-,%network,-data) $+($nick,$chr(255),File ServT) %topic
      return yeap
    }

    ; (file server online) Triggers:[/ctcp [ow]MEMFIS MemfisMovz & /ctcp [ow]MEMFIS MemfisGamez & /ctcp [ow]MEMFIS MusicAlbums & /ctcp [ow]MEMFIS MemfisAppz] snagged:[11.47 gb in 195 files]  record:[51.2 kb/s by violated1] sends:[1/1] queues:[18/75] accessed:[775 times] on server:[The best of New Gamez, Movies, Music, and Appz!]
    ; Polaris
    if (*Trigger*:[* iswm $4-8) {
      var %triggers = $gettok($gettok($1-,$+($findtok($1-,$wildtok($1-,Trigger*,1,32),1,32),-),32),2-,91)
      Xdccb-Fservtrigger 38 91 93 %triggers
      return yeap
    }

    ;(File Servers Online) Trigger: /ctcp TMD-Alchemist Chemistry. Snagged: 19.80Gb in 81 files. Record CPS: 58.0Kb/s by Phoenix2001. Online: 0/5. Sends: 2/2. Queues: 33/50. Accessed: 1185 times. Note: Its on now... The Depot is Open. Ğ~{Polaris SE}~ğ
    ;Polaris SE
    if ($+(*Trigger*: *,*) iswm $4-8) && (Polaris isin $1-) {
      var %triggers = $gettok($1-,$+($calc($findtok($1-,$wildtok($1-,*Trigger*,1,32),1,32) +1),-),32)
      Xdccb-Fservtrigger 38 58 46 %triggers
      return yeap
    }
  }
  ; ĞĞ File Server ğğ TriggersĞ/ctcp WrEcKa let me peep ya HipHop Pics & wallpaper!  /ctcp WrEcKa hook me up witcha Albums & Singles!ğ| SendsĞ1/1ğ| QueuesĞ70/200 [304.2MB]ğ| OnlineĞ0/4ğ| RecordĞ62.4 Kbs by dankedğ| ServedĞ27.45GB in 12134 filesğ| FServe Note: -= *'Singles'*'Wallpaper'*Albums'*News*''` =-   �?p ??d
  if (ĞĞ File Server ğğ = $1-4) && ((*TriggerĞ* iswm $1-) || (*TriggersĞ* iswm $1-)) {
    var %triggers = $gettok($3-,2-,171)
    Xdccb-Fservtrigger 149 171 187 %triggers
    return yeap
  }

  ;(File Servers Online) Running:(6 Days) Trigger:(/ctcp GA-Bullfrog The PS2 Pad) Snagged:(141.38Gb in 3314 files)  Record:(28.6Kb/s by cell975) Sends:(1/1) Queues:(21/99) Accessed:(5155 times) On server:(Full NTSC DVDs) · P o l a r i s · O n e ·
  ;Polaris
  if ($+($chr(40),File Server*,$chr(41),*) iswm $1-3) && ($+(*Trigger*:,$chr(40),*) iswm $3-8) {
    var %triggers = $gettok($gettok($1-,$+($findtok($1-,$wildtok($1-,Trigger*,1,32),1,32),-),32),2-,40)
    Xdccb-Fservtrigger 38 40 41 %triggers
    return yeap
  }

  ;( File Server Online ) ( Up: 1wk 6days 9mins ) ( Trigger: /ctcp digiloco !movies ) ( Leeched: 103gb in 249 files ) ( Fastest: 26.3kb/s by AngShadow ) ( Sending: 2/1 ) ( Waiting: 11/15 ) ( New: DVD - Day After Tomorrow, Eternal Sunshine of the Spotless Mind, Immortel, The Deviants, Ladykillers, Van He
  if ($+($chr(40),*File Server*,$chr(41)) iswm $1-5) && (*Trigger*:* iswm $4-) {
    var %triggers = $gettok($1-,$+($calc($findtok($1-,$wildtok($1-,*Trigger*:*,1,32),1,32) +1),-),32)
    Xdccb-Fservtrigger 38 40 41 %triggers
    return yeap
  }

  ; (FServe Online) Triggers: /ctcp ancom !enterprise & /ctcp ancom !Movies. Sends: 1/1. Queues: 9/10. Priority Queues: 2/10. Bandwidth: 12.4Kb/S. Accessed: 6409. Note: My ISP has Problems, pls be patient and stay in channel or your queues will be deleted. New: Shrek-2,The girl next door, Spiderman2, Spartan, The last samurai, The fighting temptations, Ente
  if ($+($chr(40),FServe* Online,$chr(41),*) iswm $1-3) && (*Trigger*:* iswm $3-8) {
    var %triggers = $gettok($1-,$+($calc($findtok($1-,$wildtok($1-,*Trigger*:*,1,32),1,32) +1),-),32)
    Xdccb-Fservtrigger 38 40 46 %triggers
    return yeap
  }

  ; ~{Fserve}~ Trigger:~{/ctcp WG-666 shit to download!!!}~ Online:~{0/5}~ Sends:~{2/2}~ Queues:~{1/30}~ Sent:~{35.8 GB in 387 transfers}~ Record:~{15.0 KBPS}~ Average:~{10.6 KBPS}~ Desc:~{Want to become a server? Then join #warez-helpdesk!! Leech & Enjoy!!}~ ~{Garnaxbot f1.1.0}~
  ; Garnaxbot
  if (~{Fserve}~ Trigger:~ isin $1-3) {
    addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port 1 File Server $gettok($gettok($1-,3-,123),1,125)
    return yeap
  }

  ;[Fileserver Online] Running:[2 days] Trigger:[/ctcp Brat !BratStuff] Snagged:[26.16 gb in 65 files]
  if ([Fileserver Online] = $1-2) && (Trigger:[ isin $1-) {
    var %triggers = $gettok($gettok($1-,3-,93),2-,91)
    Xdccb-Fservtrigger 38 91 93 %triggers
    return yeap
  }

  ; ·File Server Online· Triggers..::/ctcp Ninja-Samwray stuff & /ctcp Ninja-Samwray mp3 & /ctcp Ninja-Samwray img::.. Upstream..::7.49kb/s::.. Bandwidth..::7.49kb/s::.. .Ğcontinuedğ.
  if (·File Server Online· = $1-4) && ((Trigger.. isin $1-) || (Triggers.. isin $1-)) {
    var %triggers = $gettok($1-,$+($calc($findtok($1-,$wildtok($1-,*Trigger*,1,58),1,58) +1),-),58)
    Xdccb-Fservtrigger 38 58 58 %triggers
    return yeap
  }
}
Alias -l ftppack {
  tokenize 32 $strip($1-)
  var %network = $gettok($network,1,46)
  var %login,%pass,%address,%Port

  ; ĞĞ FTP Up ğğ Address~[81.82.57.68]~ Port~[6969]~ l/p~[dancetrance : mp3zz]~ Max.Users~[1]~ Speed~[Cable]~ Note~[only the Best music. genre: dance / trance]~ Ğ ?Ş??�§??? ğ
  ;Excursion
  if (ĞĞ FTP Up ğğ isin $1-4) && (Address isin $1-) && (l/p isin $1-) {
    Var %login =  $gettok($gettok($1-,4,91),1,32) 
    var %pass = $gettok($gettok($1-,3,93),-1,32)
    var %address = $gettok($gettok($1-,1,93),-1,91)
    var %Port = $gettok($gettok($1-,2,93),-1,91)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $gettok($1-,4-,93)
    goto end
  }

  ; .:] (FTP Online) ZM4573R [IP: 80.163.76.234] [Port: 21] [Login: leech] [Pass: original] [Note: Do not Hammer! Mostly music.] (ak FTP-Ad) [:.
  if (.:] *FTP Online* iswm $1-4) && (IP: isin $1-) && (login: isin $1-) {
    Var %login = $gettok($gettok($1-,4,93),-1,32) 
    var %pass = $gettok($gettok($1-,5,93),-1,32)
    var %address = $gettok($gettok($1-,2,93),-1,32)
    var %Port = $gettok($gettok($1-,3,93),-1,32)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $gettok($1-,6-,93)
    goto end
  }

  ; FTP ONLiNE! [ xb0z.servebeer.com:65456 ][ l/p: leech/leech :: look/look :: upload/upload ][ Total Users: 3 of 3 ][ Current DL BW: 51 k/s :: UL BW: 0 k/s :: Total BW: 51 k/s ][ Set retries to 120s and stay in chan! ][ ..:: ATRAGoN ::.. ]
  ; Atragon
  if ($1-2 = FTP ONLiNE!) && (l/p isin $1-) && (][ isin $1-) {
    Var %login = $gettok($7,1,47) 
    var %pass = $gettok($7,2,47)
    var %address = $gettok($4,1,58)
    var %Port = $gettok($4,2,58)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $gettok($1-,3-,93)
    goto end
  }

  ; FTP Online  Dandos.no-ip.info:444 l/p:warez/request - Other Account's = (look/look) (upload/upload)  Max users:Ğ1 userğ Bandwidth:ĞDSLğ MOTD:ĞStay In Channel - Dont Hammerğ I-n-v-i-s-i-o-n
  ;invision
  if (FTP Online = $1-2) && (l/p: isin $1-) {
    Var %login = $gettok($gettok($4,2,58),1,47) 
    var %pass = $gettok($gettok($4,2,58),2,47)
    var %address = $gettok($3,1,58)
    var %Port = $gettok($3,2,58)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $5-
    goto end
  }

  ;  FTP Server Online!  xplicit.hopto.org:21 l/p:originalwarez/booba  Max users:Ğ2 usersğ Bandwidth:Ğ3mbitğ MOTD:ĞNBA LIVE 2004, Call of Duty, FIFA 2004 Simpsons Hit & Run, 1000s of mp3, movies...ğ I-n-v-i-s-i-o-n 
  ; invision
  if (FTP Server Online! = $1-3) && (l/p: isin $1-) {
    Var %login = $gettok($gettok($5,2,58),1,47) 
    var %pass = $gettok($gettok($5,2,58),2,47)
    var %address = $gettok($4,1,58)
    var %Port = $gettok($4,2,58)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $6-
    goto end
  }

  ;·FTP Online· Address..::freeiso.myftp.org::.. Port..::4545::.. Login..::free::.. Pass..::iso::.. Speed..::DSL::.. Max Users..::1::.. Note..::to share is to care...to take a look use account: look/look [retries at 120 sec][hammer and be banned][do not msg me about bans][you are responsible for what you leech from ftp]::.. .ĞU
  if (·FTP Online· isin $1-2) && (Login. isin $1-) {
    Var %login = $gettok($5,2,58) 
    var %pass = $gettok($6,2,58)
    var %address = $gettok($3,2,58)
    var %Port = $gettok($4,2,58)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $7-
  }
  ;=(FTP Online)= WeeDSm0ker Host Ğ68.194.68.217ğ Port Ğ6060ğ Login Ğfreeğ Pass Ğshitzğ Note ĞCAMERON-DIAZ SEX FILM-final , PLUS MUSIC ===ğ WaNt To JoInCoMe To #xdcc-recruits Ğ==== TELLS YOUR FRIENDS #XDCC ON ELITEğ =(ak FTP-Ad)=
  if ($1-2 == =(FTP Online)=) && (Host isin $1-) && (Login isin $1-) {
    var %login = $gettok($gettok($1-,4,171),1,187)
    var %pass = $gettok($gettok($1-,5,171),1,187)
    var %address = $gettok($gettok($1-,2,171),1,187)
    var %port = $gettok($gettok($1-,5,171),1,187)
    hadd -m $+(XDCCb-,%network,-data) $+($nick,$chr(255),FTPm) $gettok($1-,5,187)
  }
  :end
  if (%address) && (%login) && (%pass) && (%port) {
    if (*your*nick* iswm %login) var %login = $me
    if (*your*nick* iswm %pass) var %pass = $me
    var %pack = FTP Site: $+(%login,:,%pass,@,%address,:,%port)
    addPacket $nick $server $iif($chan,$chan,$comchan($nick,1)) $port %pack
    return yeap
  }
}
Alias -l Xdccdata {
  tokenize 32 $strip($1-))
  var %network = $gettok($network,1,46)
  var %hash = $+(XDCCb-,%network,-data)
  var %maxcps = $hget(%hash,$+($nick,$chr(255),MaxCps))
  var %maxcps = $Xdccb-Calcsize(%maxcps)
  if ($1 = **) && (($3-4 = packs **) || ($3-4 = pack **)) {
    if ($5 != 0) hadd -m %hash $+($nick,$chr(255),Queue) Free
    else hadd -m %hash $+($nick,$chr(255),Queue) $left($11,-1)
    if (Record: == $eval($+($,$calc($0 -1)),2)) {
      var %new-maxcps $eval($+($,$0),2)
      if (%maxcps < $Xdccb-Calcsize(%new-maxcps)) hadd -m %hash $+($nick,$chr(255),MaxCps) %new-maxcps
    }
    return yeap
  }
  if (** Bandwidth Usage ** = $1-4) && (Record: isin $5-) {
    var %new-maxcps $eval($+($,$0),2)
    if (%maxcps < $Xdccb-Calcsize(%new-maxcps)) hadd -m %hash $+($nick,$chr(255),MaxCps) %new-maxcps
    return yeap
  }
  if (XDCC Server Active = $1-3) && (Sends:Ğ* iswm $4) && (Queues:Ğ* iswm $5) {
    var %place = $gettok($4,2,171)
    if ($gettok(%place,1,47) < $left($gettok(%place,2,47),-1)) hadd -m %hash $+($nick,$chr(255),Queue) Free
    else hadd -m %hash $+($nick,$chr(255),Queue) $gettok($gettok($5,2,171),1,187)
    return yeap
  }
  if (Current BW:Ğ* iswm $1-) && (Record CPS:Ğ* iswm $4-5) {
    var %new-maxcps = $gettok($5,2,171) $6
    if (%maxcps < $Xdccb-Calcsize(%new-maxcps)) hadd -m %hash $+($nick,$chr(255),MaxCps) %new-maxcps
    return yeap
  }

  if ($1-2 = [XDCC Active]) && (Sends:* iswm $4) {
    if ($gettok($gettok($4,2,91),1,47) < $left($gettok($gettok($4,2,91),2,47),-1)) hadd -m %hash $+($nick,$chr(255),Queue) Free
    else hadd -m %hash $+($nick,$chr(255),Queue) $left($gettok($6,2,91),-1)
    return yeap
    ;No max cps
  }
  if ($1-3 = ĞĞ XDCC ğğ) && (sends~[* iswm $4) && (Queues~[* iswm $7) {
    if ($gettok($4,2,91) < $gettok($6,1,93)) hadd -m %hash $+($nick,$chr(255),Queue) Free
    else hadd -m %hash $+($nick,$chr(255),Queue) $+($gettok($7,2,91),/,$gettok($9,1,93))
    return yeap
    ;No max cps 
  }
  return
}
