;mIRC Update Checker v2.0
;by Soul_Eater
;/download alias by ^andy, has been modified.
;Syntax:
;/mircupd check
;<<--checks version of mIRC.
;/mircupd list
;<<--retrieves the list of whats new in mIRC
;/mircupd get
;<<--downloads the newest copy of mIRC
alias -l input1 { var %x $input(Your copy of mIRC is up to date!,oi,Status) }
alias -l input2 {
if ($input(The latest copy of mIRC available is %mu-num Update?,yi,Status)) { mircupd get }
}
;on *:start:mircupd check
alias mircupd {
unset %sockread*
sockopen mirc www.mirc.co.uk 80
set %mu-r $1
}
ON *:SOCKOPEN:mirc:{
if ($sockerr) {
echo -s $sock($sockname).wsmsg
return
}
if (%mu-r == check) { sockwrite -n $sockname GET /index.html HTTP/1.1 }
if (%mu-r == list) { set %mu-x 0 | sockwrite -n $sockname GET /whatsnew.txt HTTP/1.1 | window -a @MU-List }
if (%mu-r == get) { sockwrite -n $sockname GET /get.html HTTP/1.1 }
sockwrite -n $sockname Host: www.mirc.co.uk $+ $str($crlf,2)
}
ON *:SOCKREAD:mirc:{
if ($sockerr) {
sockclose mirc
return
}
sockread %sockread
if (%mu-r == list) {
if (%sockread) {
if (%mu-x >= 9) {
aline @MU-List %sockread
}
inc %mu-x
}
}
if (%mu-r == check) {
if (*<B>mIRC* iswm %sockread) {
if (%mu-num) { sockclose $sockname }
set %mu-num $gettok($remove($gettok(%sockread,3,62),</B),2,32)
if ($version == %mu-num) { .timer -m 1 0 input1 }
if ($version < %mu-num) { .timer -m 1 0 input2 }
}
}
if (%mu-r == get) {
if (*cabinet* iswm %sockread) && (*older* !iswm %sockread) { set %mu-fn $remove($gettok(%sockread,2,62),</B) }
if (%mu-fn isin %sockread) { set %mu-fd $gettok(%sockread,2,34) }
}
}
ON *:SOCKCLOSE:mirc:{
if (%mu-r == list) { unset %sockread* %mu-* }
if (%mu-r == get) { download %mu-fd }
else { unset %sockread* %mu-* }
}
alias -l download {
if ($sock(dl)) {
echo $colour(info text) @download *** already downloading; please wait.
return
}
sockopen dl $gettok($1,2,47) 80
}
on *:sockopen:dl:{
if ($sockerr) {
echo $colour(info text) @download *** error $sock($sockname).wsmsg when downloading
return
}
write -c %mu-fn
unset %downloadlength %downloadready
window -c @download
sockwrite -n $sockname GET $+(/,$gettok(%mu-fd,3-,47)) HTTP/1.0
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Host: $gettok(%mu-fd,2,47) $+ $str($crlf,2)
sockwrite -n $sockname
}
on *:sockread:dl:{
if (%downloadready != 1) {
var %header
sockread %header
while ($sockbr) {
if (Content-length: * iswm %header) {
%downloadlength = $gettok(%header,2,32)
if (* !iswm $window(@download)) window @download
echo $colour(info text) @download *** file size: %downloadlength bytes
}
elseif (* !iswm %header) {
%downloadready = 1
%downloadoffset = $sock($sockname).rcvd
break
}
sockread %header
}
}
sockread 4096 &d
while ($sockbr) {
if (* !iswm $window(@download)) window @download
echo $colour(info text) @download *** received: $round( $calc(100 * ($sock($sockname).rcvd - %downloadoffset) / %downloadlength) ,1) $+ %
bwrite %mu-fn -1 -1 &d
sockread 4096 &d
}
}
on *:sockclose:dl:{
echo $colour(info text) @download *** done downloading %mu-fn
run %mu-fn
}
menu @download {
Stop Downloading:sockclose dl | .remove %mu-fn
Close Window:window -c @download
}