Top

Download files


mIRC Code
+ 0 likes
Please Register to submit score.
Bookmark and Share
Average Score  0.0 (of 0 scores)
Date Added  Aug 21, 2006
Last Updated  Aug 22, 2006
Tags  download  get  http  internet  socket 

Introduction

Lets you download files from the internet. Supports cancelling, pausing and resuming downloads.

See comments (text between /* and */) in code.

Grab the Code

/*
**
** /download by hixxy (hixxy@mirc.net) for mIRC 6.17 or above.
**
**
** What the script does
** ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
**
** This script will let you download files from the internet using mIRC.
**
** To use some one of the script's features you will need to install SSL for mIRC.
** For help installing OpenSSL please take a look at this page: http://www.mirc.co.uk/ssl.html
**
** How to load
** ŻŻŻŻŻŻŻŻŻŻŻ
**
** You can load this script by typing /load -rs <path to download.mrc>. If you saved the file in your mIRC directory you can just do /load -rs download.mrc
** You can also just copy/paste it into remote from a website and then hit the OK button.
**
** How to use
** ŻŻŻŻŻŻŻŻŻŻ
**
** NOTE: You can use this to download from either HTTP or FTP servers.
**
** The syntax is one of the following.
** /download <-cpr> <name>
** /download [-eo] <name> <url> <file>
**
** The -cpr switches stand for cancel, pause and resume respectively. You can only use these on existing downloads.
**
** The -e switch means you want to create an SSL socket.
** The -o switch means you want to overwrite <file> if it exists rather than spitting out an error.
**
** The script files off various signals as it is downloading the file. These are all sent to the 'download' signal with parameters being:
**
** begin - when the download begins.
** cancel - when the download is cancelled.
** end - when the download finishes.
** error <error code> <error message> - when there's a socket error.
** notfound <file> - could not find the requested file.
** pause - when the download is paused.
** progress <size> - when the snippet has downloaded another chunk of the file. <size> is the amount of bytes downloaded.
** resume - when the download is resumed.
** size <size> - the size of the file has been acquired.
**
** FTP only signals:
**
** cannotassignaddress - the server sent a 425 error.
** requireslogin - the server does not allow anonymous access.
**
** Contact
** ŻŻŻŻŻŻŻ
**
** If you have a feature suggestion, bug report or question, please send an email to hixxy@mirc.net
** If you got the script from a scripting website and I (hixxy) submitted the code, you may also leave feedback on the script's comment page.
**
*/
 
alias -l raisemessage {
  if ($line($active,0)) && (($show) || ($1 == -e)) { linesep -a }
  echo $colour(info) -a $+ $iif($1 != -e,q $1-,$chr(32) $2-)
  if ($show) || ($1 == -e) { linesep -a }
  halt
}
 
alias download {
  var %overwrite, %ssl
  if ($isid) { raisemessage -e * /download: Should be called as a command }
  if ($0 < 3) && (!$istok(-c -p -r,$1,32)) { raisemessage -e * /download: Insufficient parameters }
  if (-* iswm $1) {
    if ((c isincs $1) || (p isincs $1) || (r isincs $1)) && (!$sock(download_ $+ $2)) { raisemessage -e * /download: No such download ' $+ $2' }
    if (c isincs $1) {
      if ($isfile($gettok($sock(download_ $+ $2).mark,3-,32))) { .remove $qt($gettok($sock(download_ $+ $2).mark,3-,32)) }
      if (http:* iswm $gettok($sock(download_ $+ $2).mark,2,32)) {
        sockclose download_ $+ $2
        .signal download $2 cancel
        raisemessage * /download: Cancelled download ' $+ $2'
      }
      elseif (ftp:* iswm $gettok($sock(download_ $+ $2).mark,2,32)) {
        sockclose download_ $+ $2
        sockclose ftp_download_ $+ $2
        sockclose ftpc_download_ $+ $2
        .signal download $2 cancel
        raisemessage * /download: Cancelled download ' $+ $2'
      }
    }
    elseif (p isincs $1) {
      if (http:* iswm $gettok($sock(download_ $+ $2).mark,2,32)) && (!$sock(download_ $+ $2).pause) {
        sockpause download_ $+ $2
        .signal download $2 pause
        raisemessage * /download: Paused download ' $+ $2'
      }
      elseif (ftp:* iswm $gettok($sock(download_ $+ $2).mark,2,32)) && (!$sock(download_ $+ $2).pause) {
        sockpause download_ $+ $2
        if ($sock(ftpc_download_ $+ $2)) { sockpause ftpc_download_ $+ $2 }
        .signal download $2 pause
        raisemessage * /download: Paused download ' $+ $2'
      }
    }
    elseif (r isincs $1) {
      if (http:* iswm $gettok($sock(download_ $+ $2).mark,2,32)) && ($sock(download_ $+ $2).pause) {
        sockpause -r download_ $+ $2
        .signal download $2 resume
        raisemessage * /download: Resumed download ' $+ $2'
      }
      elseif (ftp:* iswm $gettok($sock(download_ $+ $2).mark,2,32)) && ($sock(download_ $+ $2).pause) {
        sockpause -r download_ $+ $2
        if ($sock(ftpc_download_ $+ $2)) { sockpause -r ftpc_download_ $+ $2 }
        .signal download $2 resume
        raisemessage * /download: Resumed download ' $+ $2'
      }
    }
    if (e isincs $1) { var %ssl = $true }
    if (o isincs $1) { var %overwrite = $true }
    tokenize 32 $2-
  }
  if ($sock(download_ $+ $1)) { raisemessage -e * /download: Download exists ' $+ $1' }
  if ($isfile($3-)) && (!%overwrite) { raisemessage -e * /download: File exists ' $+ $3-' }
  if ($nopath($3-) == $null) { raisemessage -e * /download: No filename supplied ' $+ $3-' }
  if ($nofile($3-) $+ $mkfn($nopath($3-)) != $3-) { raisemessage -e * /download: Filename not valid $+(',$nopath($3-),') }
  if (%ssl) && (!$sslready) { raisemessage -e * /download: SSL not ready }
  if (http:* !iswm $2) && (ftp:* !iswm $2) { raisemessage -e * /download: Invalid URL }
  var %port = $iif(http:* iswm $2,80,21)
  while (!$portfree(%port)) { inc %port }
  sockopen $iif(%ssl == $true,-e) download_ $+ $1 $gettok($2,2,47) %port
  sockmark download_ $+ $1 $false $2-
  raisemessage * /download: Downloading $2 to $3-
}
 
on *:sockopen:download_*:{
  if ($sockerr) {
    .signal download $mid($sockname,10) error $sock($sockname).wserr $sock($sockname).wsmsg
    return
  }
  if (http:* iswm $gettok($sock($sockname).mark,2,32)) {
    sockwrite -n $sockname GET / $+ $gettok($gettok($sock($sockname).mark,2,32),3-,47) HTTP/1.1
    sockwrite -n $sockname Host: $gettok($gettok($sock($sockname).mark,2,32),2,47)
    sockwrite -n $sockname Accept: */*
    sockwrite -n $sockname Connection: close
    sockwrite -n $sockname User-Agent: mIRC/ $+ $version
    sockwrite -n $sockname
  }
}
on *:sockread:download_*:{
  if (http:* iswm $gettok($sock($sockname).mark,2,32)) {
    if ($gettok($sock($sockname).mark,1,32) == $false) {
      var %data
      sockread %data
      if (*404 not found* iswm %data) {
        .signal download $mid($sockname,10) notfound / $+ $gettok($gettok($sock($sockname).mark,2,32),3-,47)
        sockclose $sockname
        return
      }
      if (%data == $null) {
        sockmark $sockname $true $gettok($sock($sockname).mark,2-,32)
        .signal download $mid($sockname,10) begin
      }
      elseif (content-length: * iswm %data) { .signal download $mid($sockname,10) size $gettok(%data,2,32) }
    }
    else {
      sockread -f &data
      bwrite $qt($gettok($sock($sockname).mark,3-,32)) -1 -1 &data
      .signal download $mid($sockname,10) progress $sockbr
    }
  }
  else {
    var %data
    sockread %data
    tokenize 32 %data
    if ($1 == 150) { .signal download $mid($sockname,10) size $mid($gettok($1-,-2,32),2,-1) }
    elseif ($1-2 == 200 PORT) { sockwrite -n $sockname TYPE I }
    elseif ($1-2 == 200 TYPE) { sockwrite -n $sockname RETR $gettok($gettok($sock($sockname).mark,2,32),-1,47) }
    elseif ($1 == 220) { sockwrite -n $sockname USER anonymous }
    elseif ($1 == 226) {
      .signal download $mid($sockname,10) end
      sockclose $sockname
      sockclose ftp_ $+ $sockname
      sockclose ftpc_ $+ $sockname
    }
    elseif ($1 == 230) {
      if ($deltok($gettok($gettok($sock($sockname).mark,2,32),3-,47),-1,47) != $null) { sockwrite -n $sockname CWD / $+ $v1 }
    }
    elseif ($1 == 250) {
      socklisten ftp_download_ $+ $mid($sockname,10) 3762
      sockmark ftp_download_ $+ $mid($sockname,10) $sock($sockname).mark
      sockwrite -n $sockname PORT $replace($sock(ftp_download_ $+ $mid($sockname,10)).ip,.,$chr(44)) $+ ,14,178
    }
    elseif ($1 == 331) { sockwrite -n $sockname PASS ftpd }
    elseif ($1 == 425) {
      .signal download $mid($sockname,10) cannotassignaddress
      sockclose $sockname
    }
    elseif ($1 == 530) {
      .signal download $mid($sockname,10) requireslogin
      sockclose $sockname
    }
    elseif ($1 == 550) {
      .signal download $mid($sockname,10) notfound / $+ $gettok($gettok($sock($sockname).mark,2,32),3-,47)
      sockclose $sockname
    }
  }
}
on *:socklisten:ftp_download_*:{
  sockaccept ftpc_ $+ $mid($sockname,5)
  sockmark ftpc_ $+ $mid($sockname,5) $sock($sockname).mark
  .signal download $mid($sockname,14) begin
}
on *:sockclose:download_*:{ .signal download $mid($sockname,10) end }
on *:sockread:ftpc_*:{
  sockread -f &data
  while ($sockbr) {
    bwrite $qt($gettok($sock($sockname).mark,3-,32)) -1 -1 &data
    .signal download $mid($sockname,15) progress $sockbr
    sockread -f &data
  }
}
 
on *:load:{
  if ($version < 6.17) {
    !.echo -q $input(This script was created for mIRC version 6.17 or later $+ $chr(44) you are using $version,dho,Invalid version)
    .unload -rs $script
  }
}

Comments

  (10)  RSS
Bigmomma
Comments: 30
 
mIRC Snippet:  Download files
Posted on Aug 22, 2006 2:26 am
I'm gonna use this for my DGIRCv4.0 or v3.0
I'll put in the credits.txt that the download system is yours,
I promise
Bigmomma
Comments: 30
 
mIRC Snippet:  Download files
Posted on Aug 22, 2006 2:26 am
oops I'd like to add this:
I'm gonna use this for my Update system of DGIRCv4.0 or v3.0
I'll put in the credits.txt that the download system is yours,
I promise
Bigmomma
Comments: 30
 
mIRC Snippet:  Download files
Posted on Aug 22, 2006 2:44 am
I use an FTP with my update system:

if (http:* !iswm $2) || (ftp:* !iswm $2) { raisemessage -e * /download: Invalid URL }

Still no worky
hixxy
Comments: 28
 
mIRC Snippet:  Download files
Posted on Aug 22, 2006 10:46 am
FTP is a completely different protocol to FTP. This is for HTTP downloads only.
hixxy
Comments: 28
 
mIRC Snippet:  Download files
Posted on Aug 22, 2006 6:22 pm
Now lets you download from FTP servers.
Fixed a bug where the script would try to use /noop if you were using a version earlier than 6.17. Now uses /!.echo -q
Freckle
Comments: 38
 
mIRC Snippet:  Download files
Posted on Aug 25, 2006 3:32 am
awesome hixxy
Freckle
Comments: 38
 
mIRC Snippet:  Download files
Posted on Aug 25, 2006 3:42 am
it only says /download: downloading *********************************** to test
hixxy
Comments: 28
 
mIRC Snippet:  Download files
Posted on Aug 25, 2006 6:30 am
Did it not download the file?
Freckle
Comments: 38
 
mIRC Snippet:  Download files
Posted on Aug 25, 2006 7:38 am
I dont think so
hixxy
Comments: 28
 
mIRC Snippet:  Download files
Posted on Aug 25, 2006 3:53 pm
Find out if it does and then post back. Download it to somewhere you'll remember.

If it doesn't download tell me the URL of the file you're trying to download and your mIRC version please.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  
Bottom