Zorgon

Zorgon

Joined
Sep 15, 2007

Activity Stream

Zorgon commented on a Page, Very Very simple vote script.  -  Oct 17, 2007

... It\'s a very short script. It\'s not long at all.
It\'s exactly what the maker said.. it\'s very, VERY simple and, quite frankly, rather useless.. But a good effort nonetheless.

 Respond  

/*
I edited this so that it\'ll support quotations around the filename. It seems to work fine. I hope you don\'t mind. I\'m also unsure about the policies about posting edited versions of code on this site.. but anyway, for anyone who wants it: (tested on mIRC 6.3 using Hawkee\'s noprofile.gif image, and some image of a fuzzy cat eating a plant)

For the noprofile.gif image:
/download http://www.hawkee.com/images/noprofile.gif \"no profile.gif\" echo -a Completed download. Check the mIRC directory.
*/

alias download {
;Detect host
var %hostn = $iif(*: !iswm $geturl($1,1),1,2), %sock = $+(download,$1)

;Error checks
if ($sock(%sock)) {
erroutput Script is already downloading $1
return
}
var %2 = $iif($left($2,1) == \",$gettok($2-,1,34),$2)
var %3- = $iif($left($2,1) == \",$gettok($2-,2-,34),$3-)
if ($file(%2)) {
erroutput File %2 already exists
return
}

;Everything ready to go
sockopen %sock $geturl($1,%hostn) 80
sockmark %sock $false $geturl($1,%hostn) $iif($geturl($1,$+($calc(%hostn + 1),-)),$+(/,$v1),/) $replace(%2,$chr(32),^_^) %3-
}
on :SOCKOPEN:download:{
var %a = sockwrite -n $sockname

;Nessecary requests
%a GET $getmark($sockname,3) HTTP/1.1
%a Host: $getmark($sockname,2)

;Connection: close to force the sockclose event
%a Connection: close

;Just-to-make-sure requests:
%a Accept: /
%a Accept-Charset:
%a Accept-Encoding:

%a Accept-Language: *
%a Content-Type: application/octet-stream
%a User-Agent: Mozilla/5.0

%a $crlf
}
on :SOCKREAD:download:{
;First read the headers, and if the header is send, binary write to the specified file
var %header, &binvar
if ($getmark($sockname,1)) {
sockread &binvar
bwrite $qt($replace($getmark($sockname,4),^_^,$chr(32))) -1 -1 &binvar
}
else sockread %header
$iif((!%header) && (!$getmark($sockname,1)),sockmark $sockname $true $getmark($sockname,2-))
}
on :SOCKCLOSE:download:$iif($getmark($sockname,5-),$v1)

;Local aliases
alias -l geturl return $gettok($1,$$2,47)
alias -l getmark return $gettok($sock($1).mark,$$2,32)
alias -l erroutput echo $color(info) -ae * /download error: $$1-

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.