iShare — File Browser

iSharev0.9 / iSharev0.9 / iShare v0.9 / System / ScriptFiles / _setup.mrc

_setup.mrc — 22.68 KB — Download this file

;############################.:iShare 0.9:.###################################
;
;Please do not edit anything here if you dont know what you are doing :)
;And if you do know what you are doing, please let me know at baresteffen@gmail.com if you plan
;on using any of the stuff I have written :)
;############################.:iShare 0.9:.###################################
alias j join #$1-
dialog _set {
  title iShare 0.9 - Setup
  size -1 -1 194 114
  option dbu
  box iShare - Setup:, 101, 2 4 186 90
  button Next, 2, 150 97 37 12
  button Back, 3, 110 97 37 12
  text , 1, 7 14 176 46
  edit "", 5, 67 65 85 10, hide autohs
  edit "", 6, 67 77 85 10, hide autohs
  text "Download folder:", 7, 7 65 52 8, hide
  text "Shared Folder", 8, 7 79 40 8, hide
  button "...", 9, 154 64 12 10, hide
  button "...", 10, 154 78 12 10, hide
  text Enable sharing?, 102, 8 60 48 8, hide
  radio "Yes", 11, 10 70 22 10, hide
  radio "No", 12, 40 70 22 10, hide
  combo 13, 8 51 61 45, size drop, hide
  text "kb\s", 14, 79 52 25 8, hide
  check "Auto hide search channel?", 15, 12 72 80 10, hide
  check "Auto connect on start?", 16, 98 72 92 10, hide
  text "iShare v0.9 - superhelt", 17, 3 97 68 8, disable
}
alias _set dialog -m _Set _set
on 1:dialog:_Set:init:0: {
  .dll dll\mdx.dll SetMircVersion $version
  .dll dll\mdx.dll MarkDialog $dname
  .dll dll\mdx.dll SetFont 1,102,11,12,15,16,17,7,8,9,10,5,6,2,3 13 400 Verdana
  did -c _set 15,16,12
  did -a _set 13 10
  did -a _set 13 20
  did -a _set 13 30
  did -a _set 13 40
  did -a _set 13 50
  did -a _set 13 60
  did -a _set 13 70
  did -a _set 13 80
  did -a _set 13 90
  did -a _set 13 100
  did -a _set 13 120
  did -a _set 13 150
  did -a _set 13 200
  did -a _set 13 300
  did -a _set 13 500
  did -a _set 13 1000
  did -a _set 13 1500
  did -a _set 13 2000

}

on 1:dialog:_set:sclick:*: { 
  if ($did == 3) { 
    _setup $calc(%_setup - 1)
  }

  if ($did == 2) {
    if (%_setup < 6) {
      _setup $calc(%_setup + 1)
    }
    if (%_setup.save == 1) _setup save
  }
  if ($did == 9) { var %x123 $sdir(c:\,Choose a download directory!) | if (!%x123) did -ar _set 5 $mircdirdownload | else if (%x123) did -ar _Set 5 %x123 }
  if ($did == 10) { var %x1234 $sdir(c:\,Choose a shared directory!) | if (!%x1234) did -ar _set 6 $mircdirdownload | else if (%x1234) did -ar _Set 6 %x1234 }

}


alias _setup { 

  if (($1 == 1) && ($dialog(_Set))) {
    %_setup.save = 0  
    did -ar _set 1  $_message(setup,m1) $crlf $crlf $_message(setup,m2)
    did -h _set 11,12,102,5,6,7,8,9,10  
    did -b _set 3
    set %_setup 1
  }
  if (($1 == 2) && ($dialog(_Set))) {
    did -ar _set 1  $_message(setup,m3) $crlf $crlf $_message(setup,m4)
    did -v _set 5,6,7,8,9,10  
    did -h _set 11,12,102
    did -e _set 3  
    set %_setup 2
  }

  if (($1 == 3) && ($dialog(_Set))) {
    if ($did(_set,6).text) .timer 1 1  _wait 
    if ($did(_set,6).text) .timer 1 2  _shrfiles
    did -ar _set 1  $_message(setup,m5) $crlf $crlf $_message(setup,m6)  
    did -h _set 5,6,7,8,9,10,13,14 
    did -v _set 11,12,102
    set %_setup 3
  }
  if (($1 == 4) && ($dialog(_Set))) {
    did -ar _set 1  $crlf $_message(setup,m7)
    did -h _set 11,12,5,6,7,9,10,15,16,102  
    did -v _set 13,14
    set %_setup 4
  }
  if (($1 == 5) && ($dialog(_Set))) {
    did -ar _set 1  $_message(setup,m8) $crlf $crlf $_message(setup,m9)
    did -h _set 13,14
    did -v _set 15,16
    did -ar _set 2 Next
    set %_setup 5
    set %_setup.save 0
  }


  if (($1 == 6) && ($dialog(_Set))) {
    did -ar _set 1  $_message(setup,m10) $crlf $crlf $_message(setup,m11)
    did -h _set 15,16
    did -ar _set 2 Finish
    set %_setup 6
    .timer 1 1 set %_setup.save 1  
  }
  if (($1 == save) && ($dialog(_set))) { 
    + config folderc 0
    if ($did(_set,5).text) + dirs downdir $did(_set,5).text
    if ($did(_set,6).text) + dirs shareddir $did(_set,6).text

    if (!$did(_set,5).text) + dirs downdir $mircdirdownload
    if (!$did(_set,6).text) + dirs shareddir $mircdirdownload
    if ($did(_set,11).state == 1) + config Share! on
    if ($did(_set,11).state !== 1) + config Share! off
    if ($did(_set,13).text) + sys speed $did(_set,13).text
    if (!$did(_set,13).text) + sys speed 50 
    if ($did(_set,15).state == 1) { + config hide 1 }  
    if ($did(_set,16).state == 1) { + config autoconn on }  
    if (!$did(_set,15).state == 1) { + config hide 0 }  
    if (!$did(_set,16).state == 1) { + config autoconn off }  
    + config start 1
    dialog -x _set
    .timer 1 1 _setup.complete   
    + config folderc 1
    _shrfiles
  }


}

alias _setup.complete {
  nfo title Setup - Complete
  nfo 1 Setup summary:
  nfo 2 
  nfo 3 Autoconnect/Autohide searchchannel: $-(config,autoconn) $+ / $+ $replace($-(config,hide),1,on,0,off)
  nfo 4 Sharing: $iif($-(config,Share!) == on,$+($_shrfiles2(files),$chr(32),files,$chr(32),$chr(40),$_shrfiles2(size),$chr(41)),Disabled)
  nfo 5 $_message(setup,m12)
  did -e _nfo 6 
  set %disco2 2
}

alias _gtspd { 
  %x = 1
  %tot.spd = 0
  %y = $get(0)
  while (%y >= %x) {
    if ($get(%x).status == active)  {
      var %x1 $get(%x).cps | set %tot.spd $calc(%tot.spd + %x1) 
      inc %x
    }
  if ($get(%x).status !== active) inc %x   }

  return $bytes(%tot.spd).suf
  unset %tot.spd %x %y %x1
}
alias _outspd { 
  %x = 1
  %tot.spd = 0
  %y = $send(0)
  while (%y >= %x) {
    if ($send(%x).status == active)  {
      var %x1 $send(%x).cps | set %tot.spd $calc(%tot.spd + %x1) 
      inc %x
    }
  if ($send(%x).status !== active) inc %x   }

  return $bytes(%tot.spd).suf

}

alias _tot.spd {
  if ($dialog(srd)) {
    dialog -t srd $_logo(v) $iif($get(1),- Download: $_gtspd,) $iif($send(1),- Upload: $_outspd,)
  }
}

dialog _wait {
  title - $_logo -

  size -1 -1 167 48
  option dbu
  text "Getting folder information... ", 1, 10 9 124 13

  text The script may freeze for a short time but will return to normal when filelisting is complete! Please wait!, 2, 10 20 131 25

}
alias _wait { if ($dialog(_wait)) dialog -x _wait | else if (!$dialog(_wait)) dialog -m _wait _wait }

on 1:dialog:_wait:init:0: {
  .dll dll\mdx.dll SetMircVersion $version
  .dll dll\mdx.dll MarkDialog $dname
  .dll dll\mdx.dll SetFont 1 20 400 Verdana
  .dll dll\mdx.dll SetFont 2 15 400 arial
  dll dll\mdx.dll SetColor 1 text $rgb(204,0,51)
  dll dll\mdx.dll SetColor 822 text $rgb(0,255,102) 

}


alias _stbr.init {
  dll dll/hOS.dll AddStatusBar noxptheme 
  dll dll/hOS.dll SBSetPanels 250 400 500 700 855 -1
}
alias _stbr {
  .dll dll\hOS.dll SBSetData 2 +c 1 $chr(2) Down: $+ $chr(2) $+ $chr(3)  $+ 3  $_gtspd 
  .dll dll\hOS.dll SBSetData 3 +c 1 $chr(2) Up: $+ $chr(2) $+ $chr(3)  $+ 4 $_outspd
  .dll dll\hos.dll SBSetData 1 +c 1 $chr(2) $iif($server,Server:  $+ $chr(2) $chr(3) $+ 2 $_srv(serv)  $_ne  ,Server: $chr(2) $chr(3) $+ 4 Not Connected))
  .dll dll\hos.dll SBSetData 4 +c  $iif($-(config,Share!) == On, $chr(2) $+ Sharing: $chr(2) $+ $chr(3) $+ 3  $_shrfiles2(files) files $+($chr(40),$_shrfiles2(size),$chr(41)), $chr(2) Sharing: $+ $chr(2) $chr(3) $+ 4 Disabled)
  if (($server && ($_getchancount > 0))) {   .dll dll\hos.dll SBSetData 5 +c $chr(2) Users: $chr(2) $chr(3) $+ 2 $_getchancount }
  if (!$_getchancount) { .dll dll\hos.dll SBSetData 5 +c $chr(2) Users: $chr(2) $chr(3) $+ 2 0 }

  .dll dll\hos.dll SBSetData 6 +c $chr(2)  14,15  $_logo(v) by superhelt
}

;whois report
alias _whois {
  if ($2) {
    if (!$dialog(_whois)) dialog -md _whois _whois
    did -ar _whois $1-
  }
}
#raw off
raw *:*: {
  if ($numeric == 312) { if (%wnick) _whois 8 $remove($address($mask(%wnick,1),10),*!) |  %x = $2 |  _whois 12 $3   } 
  if ($numeric == 317) { _whois 10 $duration($3) }
  if ($numeric == 311) { set %x $1 |  _whois 8 $4- }
  if ($numeric == 319) { _whois 9 $3- | dialog -t _whois $_logo - Whois central  }

  halt


}
#raw end



on 1:dialog:_whois:init:0: {
  dll dll\mdx.dll SetMircVersion $version
  dll dll\mdx.dll MarkDialog $dname

  dll dll\mdx.dll SetFont 3,4,5,6,7,8,9,10,11,12,2,3,1 13 400 Verdana
  dll dll\mdx.dll SetColor 7,8,9,10,12 text $rgb(0,102,204)
  dll dll\mdx.dll SetColor 3,4,5,6,11 text $rgb(0,51,102)
  dll dll\mdx.dll SetColor 1 text $rgb(153,0,0)
  did -e _whois 2

}
dialog _whois {
  title "Whois - Getting whois results..."
  size -1 -1 234 110

  option dbu
  box Whois report, 1, 4 4 227 86
  button Close, 2, 4 95 37 12, default ok disable
  text Nick, 3, 9 20 25 8
  text Address:, 4, 9 34 25 8
  text Channels:, 5, 9 48 28 8
  text Idle:, 6, 9 62 25 8
  text , 7, 55 20 171 8
  text  ,8, 55 34 171 8
  text , 9, 55 48 171 8
  text , 10, 55 62 171 8
  text Server:, 11, 9 75 25 8
  text , 12, 55 75 171 8
}




alias mtitle { dll " $+ dll\mtitle.dll $+ " mtitle $1- }
alias mtitlebar { return $dll( " $+ dll\mtitle.dll $+ " , mtbar , 0 ) }

alias mChan { if ($1 ischan) { mSet $1 Channel: -[ $+ $1 $+ ]- Population: -[ $+ $nick($1,0) $+ ]- Modes: -[ $+ $iif( $chan($1).mode , $chan($1).mode , n/a ) $+ ]- Topic: -[ $+ $iif( $chan($1).topic , $ifmatch , none) $+ ]- } }
alias mSet { if ($1 ischan) { dll " $+ dll\mtitle.dll $+ " mchan $window($1).hwnd $strip($2-) } }
alias _cc.chk { 
  %x = $network
  if  (%x == EFNet) { mset #ishare!search $_message(help,m26) }
}

alias _rndUser { 
  var %x $rand(1000,999999999)
  var %y $right($me,-1) 
  if (%y isnum) { nick $+(i,%x) }
}

alias _ver.read { 
  if ($dialog(_upd)) {
    .rename update.txt update.ini
    did -r _upd 7
    did -a _upd 7 :: Update summary :: $crlf 
    did -a _upd 7 $str(_,27) $crlf $crlf
    did -a _upd 7 Connection: Success $crlf
    did -a _upd 7 Update needed: Yes $crlf
    if ($readini(update.ini,info,author)) + update author $readini(update.ini,info,author)
    if ($readini(update.ini,info,install)) + update Install $readini(update.ini,info,install)
    if ($readini(update.ini,info,source1)) + update size $readini(update.ini,info,source1)
    if ($readini(update.ini,info,source1)) + update source1 $readini(update.ini,info,source1)
    if ($readini(update.ini,info,source2)) + update source2 $readini(update.ini,info,source2)
    if ($readini(update.ini,info,size)) + update size $readini(update.ini,info,size)
    if ($readini(update.ini,info,version) == $_logo(.))  { did -ar _upd 5 $_ver(.)  | did -ar _upd 7 Connection: Success $crlf | did -a _upd 7 Update needed: No $crlf $crlf | did -a _upd 7 $crlf | did -a _upd 7 $str(_,27) $crlf $crlf | did -a _upd 7 Your version is up to date! $crlf $crlf | did -ar _upd 5 $remove($_logo(v),iShare)  | did -a _upd 7  $str(¯,27)   | did -f _upd 9 | goto end  }
    if ($readini(update.ini,info,desc)) + update desc $readini(update.ini,info,desc)
    if ($readini(update.ini,info,desc2)) + update desc2 $readini(update.ini,info,desc2)
    if ($readini(update.ini,info,desc3)) + update desc3 $readini(update.ini,info,desc3)
    if ($readini(update.ini,info,desc4)) + update desc4 $readini(update.ini,info,desc4)
    if ($readini(update.ini,info,version)) + update Version $readini(update.ini,info,version)
    if (!$readini(update.ini,info,version)) + update Version n/a
    if ($readini(update.ini,info,sdesc)) + update sdesc $readini(update.ini,info,sdesc)
    if (!$readini(update.ini,info,sdesc)) + update sdesc N/A
    did -ar _upd 5 $-(update,version) 
    did -e _upd 10 
    if (!$-(update,Install)) did -a _upd 7 Install instructions included: No $crlf
    if (!$-(update,Install)) did -a _upd 7 Install instructions included: Yes  $crlf
    if ($-(update,size)) did -a _upd 7 Size: $bytes($-(update,size)).suf $crlf
    if ($-(update,author)) did -a _upd 7 Author: $-(update,author) $crlf
    if ($-(update,source1)) did -a _upd 7 Source: $-(update,source1) $crlf
    did -ar _upd 5 $-(update,version)
    did -a _upd 7 $str(_,27) $crlf $crlf
    if ($-(update,desc)) did -a _upd 7 $replace($-(update,desc),@space@,$crlf)
    if ($-(update,desc2)) did -a _upd 7 $replace($-(update,desc2),@space@,$crlf)
    if ($-(update,desc3)) did -a _upd 7 $replace($-(update,desc3),@space@,$crlf)
    if ($-(update,desc4)) did -a _upd 7 $replace($-(update,desc4),@space@,$crlf)
    unset %vr %ii %x 
    did -f _upd 10
    did -e _upd 10
    dll dll\mdx.dll SetColor _upd 5 text $rgb(255,0,0)

  }
  ;  .remove update.ini

  :end

}
alias ver2 {

  sockclose update
  .remove update.ini
  sockopen update ludrio.com 80

}
on *:sockopen:update:{ 
  if ($sock(update).status == active)  {
    sockwrite -n $sockname GET /ishare/ishare.html HTTP/1.1 
    sockwrite -n $sockname Accept: */* 
    sockwrite -n $sockname Host: ludrio.com
    sockwrite -n $sockname $crlf
  }
}

on *:sockread:update:{ 

  if ($dialog(_upd)) {
    sockread &g
    bwrite update.txt -1 &g


    sockclose update
    _ver.read  
    did -c _Upd 7 1

  }
}


on *:dialog:_upd:sclick:*: { 
  if ($did == 6) { did -ar _upd 7 Checking for updates.. | ver2 | did -b _upd 6 }
  if ($did == 9) { if ($did(_upd,8).state == 1) + config updstart 1 | else + config updstart 0  }
  if ($did == 10) { if (($-(update,source1) && ($-(update,source2)))) { if (!$dialog(dw)) dialog -m dw dw did -b _upd 10  | dialog -x _upd }

  }
}

on *:dialog:_upd:init:0: {

  if ($-(sys,vr2)) did -ar _upd 3 $-(sys,vr2)
  if (!$-(sys,vr2)) did -ar _upd 3 n/a

  .dll dll\mdx.dll SetMircVersion $version
  .dll dll\mdx.dll MarkDialog $dname
  dll dll\mdx.dll SetFont $dname 2,4 14  400 Arial
  dll dll\mdx.dll SetFont $dname 6,8,10 12 400 Verdana

  dll dll\mdx.dll SetFont $dname 9 13 400 Verdana
  dll dll\mdx.dll SetFont $dname 7 13 400 Verdana
  dll dll\mdx.dll SetColor $dname 3,5 text $rgb(0,153,51)

  dll dll\mdx.dll SetColor 822 background  $rgb(255,255,255)
  dll dll\mdx.dll SetColor 822 textbg $rgb(255,255,255)
  dll dll\mdx.dll SetColor 822 text $rgb(50,100,200)

  dll dll\mdx.dll SetColor $dname 7 text $rgb(50,100,200)
  dll dll\mdx.dll SetColor $dname 7 textbg $rgb(255,255,255)
  dll dll\mdx.dll SetColor $dname 7 background $rgb(255,255,255)

  dll dll\mdx.dll SetColor $dname 2,4 text $rgb(0,0,204)
  if ($-(config,updstart) == 1) did -c _upd 8
  did -a _upd 7 $crlf $crlf $_message(imp,m1)
}

alias upd { if (!$dialog(_upd)) dialog -m _upd _upd }
dialog _upd {
  title "iShare - Update Central"
  size -1 -1 227 131
  option dbu
  box "", 1, 4 4 221 124
  text "Current version", 2, 10 13 41 8
  text , 3, 55 13 28 8, right
  text "Newest version:", 4, 10 26 42 8
  text , 5, 55 26 28 8, right
  button "Check for updates now", 6, 9 61 65 11
  edit Click "Check for updates now" to see if you are using the newest edition of $_logo , 7, 102 10 118 113, multi vsbar read
  check "Check for updates on start", 8, 10 44 82 8
  button "&Ok", 9, 10 112 37 12, ok
  button "Download", 10, 9 75 65 11, disable
}

;download manager

dialog dw {
  title Download manager
  size -1 -1 320 131
  option dbu
  text Elapsed time:, 4, 138 16 67 8
  text Data recived:, 5, 138 26 67 8
  text Connection type:, 6, 138 36 68 8
  edit 0, 8, 222 16 58 10, read right
  edit 0, 9, 222 26 58 10, read right
  edit 0, 10, 222 36 58 10, read right
  box Update info:, 1, 4 6 126 107
  text Version update:, 2, 10 17 39 8
  text Author:, 3, 10 27 37 8
  text Source:, 7, 10 37 32 8
  text Size:, 11, 10 47 41 8
  edit , 12, 66 16 58 10, read right
  edit , 13, 66 26 58 10, read right
  edit , 14, 66 36 58 10, read right
  edit , 15, 66 46 58 10, read right
  box "Transfer:", 16, 134 6 179 107
  text "Port:", 17, 138 47 27 8
  edit 0, 18, 222 46 58 10, read right
  text Speed:, 32,  138 56 68 8
  edit 0kbs, 33, 222 56 58 10, read right
  button &Start download, 19, 4 116 50 12
  button &Open file, 30, 60 116 50 12, disable
  button &Installation help , 34, 120 116 60 12, disable
  text File:, 20, 138 72 32 8
  text , 21, 184 75 118 8
  text , 22, 138 85 164 8
  text Description:, 23, 10 57 48 8
  edit , 24, 46 58 78 50, read multi autovs vsbar
  text Status:, 26, 138 96 46 8
  text , 27, 170 96 110 16
}
on *:dialog:dw:init:0:{  
  dll dll\mdx.dll SetMircVersion  $version
  dll dll\mdx.dll MarkDialog $dname
  dll dll\mdx.dll SetControlMDX $dname 22 ProgressBar smooth > dll\ctl_gen.mdx
  dll dll\mdx.dll SetColor $dname 24,12,13,14,15,8,9,10,18,33 text $rgb(50,100,200)
  dll dll\mdx.dll SetColor $dname 24,12,13,14,15,8,9,10,18,33 textbg $rgb(255,255,255)
  dll dll\mdx.dll SetColor $dname 24,12,13,14,15,8,9,10,18,33 background $rgb(255,255,255)
  dll dll\mdx.dll SetFont $dname 34,24,12,13,14,15,8,9,10,18,2,3,7,11,23,1,20,21,23,26,27,4,5,6,17,32,33 13 400 Verdana
  dll dll\mdx.dll SetFont $dname 19,30 13 400 Arial
  ;Update info 
  if ($-(update,version)) did -a dw 12 $-(update,version)
  if ($-(update,source1)) did -a dw 14 $-(update,source1)
  if ($-(update,author)) did -a dw 13 $-(update,author)
  if ($-(update,size)) did -a dw 15 $bytes($-(update,size)).suf
  if ($-(update,sdesc)) did -a dw 24 $replace($-(update,sdesc),@space@,$crlf)
}
on 1:Dialog:dw:sclick:*: {
  if ($did == 34) { ishare help | did -c help 1 18 | %x = Updates | did -ar help 6 %x 
    did -ar help 7  $readini(system\help.ini,topics,%x)
    did -ar help 2 $readini(system\help.ini,Help,%x) 
    did -c help 2 1
  }
  if ($did == 30) {  if ($-(update,file))  run $-(update,file) }
  if ($did == 19) { 

    if ($did(dw,19) == &Start download) {
      if (($-(update,source1)) && ($-(update,source2))) {
      download $-(update,source1) $-(update,source2) } 
    }
    if ($did(dw,19) == &Cancel download) { sockclose %sock | did -ar dw 27 Download stopped. Deleting files.. | .remove $remove(%sock,dl.) | did -ar dw 27 Download stopped. Deleted file | did -ar dw 19 &Start download | unset %sock }

  }
} 

;  BIG thanks to oMri^^ from mircscripts.org for this! Thanks! :)
;  This helped me alot and saved from alot of work!
;
;
alias download {
  var %socket $+(dl,$chr(46),$nopath($2))
  if (!$sock(%socket)) {
    sockopen %socket $1 80
    sockmark %socket HEAD $1 $2
    if ($dialog(dw)) did -ar dw 27 Starting download..
  }
  else { goto end }
  :end
}

alias percent return $+($round($calc((100 / $2) * $1),2),%)

on *:SOCKOPEN:dl.*:{
  if ($sockerr) { if ($dialog(dw)) did -ar dw 27 Error downloading file... | return }
  hadd -m ticks $sockname $ticks
  var %file = $nopath($gettok($sock($sockname).mark,3,32)), %fullfile = $+(",$mircdir,%file,"), %sckr = sockwrite -n $sockname, %^ = $gettok($sock($sockname).mark,3,32)
  if ($dialog(dw)) { did -ar dw 27 Contacting source...  |       did -ar dw 19 &Cancel download
  }
  write -c %fullfile
  %sckr GET $iif(left(%^,1) != $chr(47),$chr(47) $+ %^,%^) HTTP/1.0
  %sckr HOST: $gettok($sock($sockname).mark,2,32)
  %sckr ACCEPT: *.*
  %sckr $crlf
  set %sock $sock($sockname)
}

on *:SOCKREAD:dl.*:{
  if ($sockerr) {
    if ($dialog(dw)) did -ar dw 27 ERROR: $sock($sockname).wsmsg
    return
  }
  var %a
  :begin
  if ($gettok($sock($sockname).mark,1,32) == head) { sockread %a }
  else { sockread &b }
  if ($sockbr) {
    tokenize 32 $sock($sockname).mark
    if ($1 == HEAD) {
      if (%a) {
        if ($gettok(%a,1,32) == Content-Length:) { var %totsize = $gettok(%a,2,32) }
      }
      else {
        if ($dialog(dw)) did -ar dw 27 Starting download...
        sockmark $sockname GET $2- %totsize
      }
    }
    elseif ($1 == GET) {
      if ($dialog(dw))  did -ar dw 33 $bytes($calc($sock($sockname).rcvd / $sock($sockname).to)).suf  
      if ($dialog(dw))  did -ar dw  8 $sock($sockname).to seconds
      if ($dialog(dw))  did -ar dw 10  $sock($sockname).type
      if ($dialog(dw))  did -ar dw 18  $sock($sockname).port
      if ($dialog(dw)) did -ar dw 21 $nopath($gettok($sock($sockname).mark,3,32))
      if ($dialog(dw)) did -ar dw 27 Downloading... 
      var %file = $+(",$mircdir,$nopath($3),"), %cursize = $file(%file).size
      var %totsize = $gettok($sock($sockname).mark,4,32)
      if ($dialog(dw)) did -ar dw 9 $bytes(%cursize).suf 
      if ($dialog(dw)) did -a dw 22 $remove($percent(%cursize,%totsize),$chr(37))
      bwrite %file -1 &b
    }
    goto begin
  }
}

on *:SOCKCLOSE:dl.*:{
  unset %sock 
  var %ticks = $calc(($ticks - $hget(ticks,$sockname)) /1000)
  + update file $nopath($gettok($sock($sockname).mark,3,32)) 

  if ($dialog(dw)) did -ar dw 27 Download of $nopath($gettok($sock($sockname).mark,3,32)) completed in %ticks seconds.
  if ($dialog(dw)) did -ar dw 22 100
  if ($dialog(dw)) {  did -b dw 19
    did -e dw 30,34 

  }
  if (!$dialog(dw)) { echo -s $+([,$time,]) Download of $nopath($gettok($sock($sockname).mark,3,32)) completed in %ticks seconds
    echo -s $+([,$time,])  Open your iShare directory $+($chr(40),$mircdir,$chr(41)) and run the  $nopath($gettok($sock($sockname).mark,3,32)) . Just unzip the file into your iShare directory and click Yes to overwrite all the files!
  }
}


;nickname options
dialog _nick {
  title "iShare - Nickname Central"
  size -1 -1 166 89
  option dbu
  box Nickname options:, 1, 5 2 159 72
  radio Use our own nick, 3, 10 16 53 10
  radio Random nick, 4, 10 30 50 10
  edit , 2, 66 16 50 10, autohs
  text Select to either use your own nickname or let iShare make you a random nickname each time you start the script. , 5, 10 47 150 23
  button Ok, 6, 5 76 36 10, default ok
  button Cancel, 7, 46 76 36 10, cancel
  text "Ex: i4646741", 8, 66 31 42 8
}

alias _nick dialog -m _nick _nick
on 1:dialog:_nick:init:0: {
  .dll dll\mdx.dll SetMircVersion $version
  .dll dll\mdx.dll MarkDialog $dname
  .dll dll\mdx.dll SetFont $dname 3,4,6,7,8,2 12 400 verdana
  .dll dll\mdx.dll SetFont $dname 5,1 13 400 verdana
  .dll dll\mdx.dll SetColor $dname 5 text $rgb(51,102,204)
  did -a _nick 2 $me
  if ($-(config,uoNick) == 1) did -c _nick 3
  else { did -c _nick 4 | did -b _nick 2 }
}
on 1:dialog:_nick:sclick:*: {
  if ($did == 3) { did -e _nick 2  }
  if ($did == 4) { did -b _nick 2  }
  if ($did == 6) { if (($did(_nick,3).state == 1) && ($did(_nick,2).text)) {  + config uonick 1 | nick $did(_nick,2).text } | if ($did(_nick,4).state == 1) { + config uonick 0 | %x = $+(i,$rand(1111,999999)) | nick %x | unset %x } }

}

dialog _pr {
  title 0
  size -1 -1 116 17
  option dbu
  text , 2, 8 17 99 10
  text , 1, 8 5 100 8
}


on 1:dialog:_pr:init:0: { 
  .dll dll\mdx.dll MarkDialog $dname
  .dll dll\mdx.dll SetMircVersion $version
  .dll dll\mdx.dll SetControlMDX $dname 2 ProgressBar smooth > $ctl
  dll dll\mdx.dll SetFont $dname 1 13 400 Arial
  dll dll\mdx.dll SetDialog _pr bgcolor $rgb(255,255,255)
  dll dll\mdx.dll SetColor _pr 1,2 textbg $rgb(255,255,255)
  dll dll\mdx.dll SetColor _pr 1,2 background $rgb(255,255,255)
  dll dll\hstylus.dll x_desabilitar $dialog(_pr).hwnd

}

alias _prS { 
  if (($1) && ($dialog(_pr))) {
    if ($1 isnum) did -a _pr 2 $1
    if ($1 !isnum) did -ar _pr 1 $1-  
  }
}