downloader?
Posted by w.e
Friday, November 25, 2005
Description: title


menu * {
  Download:dialog -m download download
}
alias mdx_fullpath { return $+(",D:\mIRC\mdx.dll,") }
alias mdx { dll $mdx_fullpath $1- }
alias mdxinit {
  dll $mdx_fullpath SetMircVersion $version
  dll $mdx_fullpath MarkDialog $dname
}
dialog download {
  size -1 -1 335 163
  title "Dialog"
  button "positioner",1001,0 0 0 0
  text "Download URL:",1,6 6 78 17
  text "30 0 100",2,5 69 325 15
  edit "",3,5 25 326 21
  button "Download",4,4 47 60 19
  list 5,5 88 325 70,extsel size
  button "Cancel",6,137 47 60 19
  button "Done",7,271 47 60 19, cancel  ok
}
on *:dialog:download:init:*:{
  mdxinit
  mdx SetControlMDX $dname 1001 positioner  minbox > D:\mIRC\dialog.mdx
  mdx SetControlMDX $dname 2 ProgressBar > D:\mIRC\ctl_gen.mdx
  did -a download 2 0 0 100
  var %u $findfile(downloads,*.*,0,did -a download 5 $nopath($1-))
}
on *:dialog:download:sclick:4:{
  download $did(download,3)
}
on *:dialog:download:sclick:6:{
  sockclose downloadx
}
alias refreshfiles {
  did -r download 5
  var %u $findfile(downloads,*.*,0,did -a download 5 $nopath($1-))
}
on *:dialog:download:dclick:5: {
  run $mircdir $+ downloads\ $+ $did(download,5).seltext
}
alias download {
  unset %totallines
  unset %l
  if ($left($1,7) == http://) {
    if ($1) {
      if (!$2) {
        set %fileext $gettok($remove($1,http://),$gettok($remove($1,http://),0,47),47)
        set %beg $gettok($remove($1,http://),1,47)
        set %end $gettok($remove($1,http://),2-,47)
        sockclose initiate
        sockopen initiate %beg 80
        sockclose downloadx
        sockopen downloadx %beg 80
      }
      else {
        echo -a too much info
      }
    }
    else {
      echo -a Too little information was supplied.
    }
  }
  else {
    echo -a Invalid syntax. Please include http:// at the beginning of your url.
  }
}
on *:SOCKOPEN:initiate:{
  sockwrite -n $sockname GET / $+ %end HTTP/1.1
  sockwrite -n $sockname Host: %beg
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname User-Agent: Mozilla/3.0 (compatible)
  sockwrite -n $sockname Authorization: Basic <uu-encoded>
  sockwrite -n $sockname $crlf
}
on *:sockread:initiate:{
  sockread %z
  if (Content-Length: isin %z) {
    set %llength $remove(%z,content-length:,$chr(32))
  }
}


on *:SOCKOPEN:downloadx:{
  sockwrite -n $sockname GET / $+ %end HTTP/1.1
  sockwrite -n $sockname Host: %beg
  sockwrite -n $sockname Connection: close
  sockwrite -n $sockname User-Agent: Mozilla/3.0 (compatible)
  sockwrite -n $sockname Authorization: Basic <uu-encoded>
  sockwrite -n $sockname $crlf
}

on *:sockread:downloadx:{
  did -a download 2 $sock(downloadx).rcvd 0 %llength
  if ($gettok($sock($sockname).mark,2,32)) {
    sockread &b
    while ($sockbr) {
      bwrite $mircdir $+ downloads\ $+ %fileext -1 -1 &b
      sockread &b
    }
    if ($sock($sockname).rcvd >= $gettok($sock($sockname).mark,1,32)) {
      sockclose $sockname
      refreshfiles
    }
  }
  else {
    var %c
    sockread %c
    if (-Length: isin %c) sockmark $sockname $gettok(%c,2,32)
    if (!%c) sockmark $sockname $sock($sockname).mark 1
  }
}


..have MDX.dll !!!!!
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world