mIRC Home    About    Download    Register    News    Help

Topic Options
#185522 - 10/09/07 05:57 PM update script
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
someone that know about any update script for mirc ? been trying to find one, but no luck so far..
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#185523 - 10/09/07 06:01 PM Re: update script [Re: sparta]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
You mean to update mIRC or to update a script? And do you want it to check if there are updates and then download them, or just tell you there's a new one?

Top
#185534 - 10/09/07 10:01 PM Re: update script [Re: hixxy]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
i solved the problem with tell if it's a new update on the site, but i cant make it to download and install it.
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#185566 - 11/09/07 03:31 AM Re: update script [Re: sparta]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Originally Posted By: sparta
i solved the problem with tell if it's a new update on the site, but i cant make it to download and install it.


:P

Code:
alias -l rm.host { return HOST }
alias -l rm.path { return /PATH/ }
alias -l rm.hash { return rmlist }
alias -l rm.hfile { return system\hash\rmlist.hsh }

alias -l rm.save {
  if ($hget($rm.hash)) {
    var %t = 1, %dir = $nofile($rm.hfile), %tok = $iif($pos(%dir,/),47,92), %n = $numtok(%dir,%tok)
    while (%t < %n) {
      var %path = $gettok(%dir,$iif(%t == 1,%t,$+(1-,%t)),%tok), %t = %t + 1
      if (!$isdir(%path)) /mkdir %path
    }
    /hsave $rm.hash $rm.hfile
  }
}

on *:START: {
  var %dir_list = system\hash system\backup system\scripts, %d = 1
  while ($gettok(%dir_list,%d,32)) {
    var %t = 1, %dir = $v1, %n = $numtok(%dir,92), %d = %d + 1
    while (%t < %n) {
      var %path = $gettok(%dir,$iif(%t == 1,%t,$+(1-,%t)),92), %t = %t + 1
      if (!$isdir(%path)) /mkdir %path
    }
  }

  if (!$hget($rm.hash)) /hmake $rm.hash 10
  if ($isFile($rm.hfile)) /hload $rm.hash $rm.hfile
  if ($version == 6.3) {
    if (%stswitch) { 
      if (%stswitch == on) {
        server irc.fcirc.net
        .timer 1 1 /join #scripts
      }
      elseif (%stswitch == off) { echo -a Auto Connect is halted }
    }
    else { $startup }
  }
}

on *:EXIT: {
  /rm.save
}

alias -l rm.cmd {
  if ($1 == echo) return /echo -s *
  return /msg $1
}

alias -l rm.chk_update {
  var %cmd = $rm.cmd($1), %file = $replace($2-,$chr(32),$+(%,20)), %lupdate = $hget($rm.hash,%file)

  if (%lupdate) {
    /sockopen rm.update $rm.host 80
    /sockmark rm.update CHKUPDATE $1 %file
    [ %cmd ] Checking for update of %file $+ ...
  }
  else [ %cmd ] Could not update file: Previous record not found.
}

alias -l rm.update {
  var %cmd = $rm.cmd($1), %file = $replace($2-,$chr(32),$+(%,20)), %lupdate = $hget($rm.hash,%file)

  /sockopen rm.update $rm.host 80
  /sockmark rm.update UPDATE $1 %file
  [ %cmd ] Downloading update of %file $+ ...
}

on *:SOCKOPEN:rm.update: {
  var %sock = $sockname, %mark = $sock(%sock).mark
  var %what = $gettok(%mark,1,32), %cmd = $rm.cmd($gettok(%mark,2,32)), %file = $gettok(%mark,3-,32)

  /set %rm.update.header 1

  if ($right($rm.path,1) == /) var %gfile = $rm.path $+ %file
  else var %gfile = $rm.path $+ / $+ %file

  if ($sockerr) [ %cmd ] Could not check for update: $sock(%sock).wsmsg
  else if (%what == CHKUPDATE) {
    /sockwrite -n %sock HEAD %gfile HTTP/1.0
    /sockwrite -n %sock Host: $rm.host
    /sockwrite -n %sock User-Agent: Mozilla/4.0 (mIRC Remote)
    /sockwrite -n %sock Accept: */*
    /sockwrite -n %sock If-Modified-Since: $hget($rm.hash,%file)
    /sockwrite -n %sock $crlf
  }
  else if (%what == UPDATE) {
    /sockwrite -n %sock GET %gfile HTTP/1.0
    /sockwrite -n %sock Host: $rm.host
    /sockwrite -n %sock User-Agent: Mozilla/4.0 (mIRC Remote)
    /sockwrite -n %sock Accept: */*
    /sockwrite -n %sock $crlf
  }
  else {
    [ %cmd ] Unknown action %what
    /sockclose %sock
  }
}

on *:SOCKREAD:rm.update: {
  var %sock = $sockname, %mark = $sock(%sock).mark, %read
  var %what = $gettok(%mark,1,32), %cmd = $rm.cmd($gettok(%mark,2,32)), %file = $gettok(%mark,3-,32)

  if (%rm.update.header) {
    /sockread %read
    if ($len(%read) == 0) {
      /unset %rm.update.header
      return
    }
  }
  else {
    /sockread &data
  }

  ; HEADERS
  if (%rm.update.header) {
    var %reg_http = /HTTP[\/0-9\.]+ ([0-9]+) .*/i
    var %reg_lmod = /Last-Modified: (.*)/i
    if (%what == CHKUPDATE) {
      if ($regex(%read,%reg_http)) {
        var %code = $regml(1)
        if (%code == 304) [ %cmd ] %file has not been updated
        else if (%code == 200) /set %rm.update.modified 1
        else if (%code == 404) [ %cmd ] File could not be found. Check the file name, and try again.
      }
      else if (($regex(%read,%reg_lmod)) && (%rm.update.modified)) {
        var %date = $gettok(%read,2-,32)
        [ %cmd ] %file was last modified %date $+ .
        /unset %rm.update.modified
      }
    }
    else if (%what == UPDATE) {
      if ($regex(%read,%reg_http)) {
        var %code = $regml(1)
        if (%code == 200) {
          /set %rm.update.download 1
          [ %cmd ] Found %file $+ , downloading...
        }
        else if (%code == 404) [ %cmd ] File could not be found. Check the file name, and try again. | halt
      }
      else if ($regex(%read,%reg_lmod)) {
        var %date = $regml(1)
        if (!$hget($rm.hash,%file)) /set %rm.upload.newfile 1
        /hadd $rm.hash %file %date
        /rm.save
      }
    }
    else if ($regex(%read,%reg_http)) {
      var %code = $regml(1)
      if (%code == 400) [ %cmd ] Could not retrieve file: bad request
      else [ %cmd ] Unknown error: %read
    }
  }
  else if (%rm.update.modified || %rm.update.download) {
    var %savefile = $replace(%file,$+(%,20),$chr(32))
    /bwrite $+(",%savefile,") -1 -1 &data
    /set %rm.update.file %savefile
  }
}

on *:SOCKCLOSE:rm.update: {
  var %sock = $sockname, %mark = $sock(%sock).mark
  var %what = $gettok(%mark,1,32), %cmd = $rm.cmd($gettok(%mark,2,32)), %file = $gettok(%mark,3-,32)
  if ((%what == UPDATE) && (%rm.update.file)) {
    [ %cmd ] Download complete. Loading script...

    var %savefile = %rm.update.file
    if ($isFile($+("system\scripts\,%savefile,"))) .copy -o $+("system\scripts\,%savefile,") $+("system\backup\,%savefile,")

    .copy -o $+(",%savefile,") $+("system\scripts\,%savefile,")
    .remove $+(",%savefile,")

    if ($script($+("system\scripts\,%savefile,"))) /reload -rs $+("system\scripts\,%savefile,")
    else /load -rs $+("system\scripts\,%savefile,")

    if (*Loaded* !isin $line(Status Window,$calc($line(Status Window,0) - 1))) {
      [ %cmd ] $line(Status Window,$calc($line(Status Window,0) - 1))
    }
    else [ %cmd ] %file loaded successfully.

    /unset %rm.update.*
    clear -s
  }
}

on *:INPUT:#: {
  if (/ == $left($1-,1)) { return }
  elseif ($1 == @download) {
    var %target = $iif($target == $me,$nick,$chan)
    %stswitch = on
    if ($2) {
      var %file = $2-
      if ($exists($+($mircdir,/system/scripts/,%file)) == $true) { unload -rs ./system/scripts/ $+ %file | /.remove ./system/scripts/ $+ %file | goto xscript }
      else { goto xscript }
      :xscript 
      /msg %target Downloading $+(,%file,...)
      /rm.update %target %file
    }
    else /msg %target Insufficient parameters: @download <file>
  }
  else if ($1 == @update) {
    var %target = $iif($target == $me,$nick,$chan)
    if ($2) {
      var %file = $2-
      /msg %target Checking $+(,%file,) for update...
      /rm.chk_update %target %file
    }
    else /msg %target Insufficient parameters: @update <file>
  }
  elseif ($1 ison #) { echo -t $+(:[,$me,]:) $+(15,$1,7:) $2-
    .msg # $+(15,$1,7:) $2-
    /halt
  } 
  else { 
    if ($me isop $chan) { echo -t $+(%co1,%brl,%co2,@,$me,%co1,%brr,) $1- | /.msg # $1- | halt }
    elseif ($me ishop $chan) { echo -t $+(%co1,%brl,%co2,%,$me,%co1,%brr,) $1- | /.msg # $1- | halt }
    elseif ($me isvoice $chan) { echo -t $+(%co1,%brl,%co2,+,$me,%co1,%brr,) $1- | /.msg # $1- | halt }
    else { echo -t $+(%co1,%brl,%co2,$me,%co1,%brr,) $1- | /.msg # $1- | halt }
  }
}


NOTE if you have a ON INPUT script it might clash with this on input event @download,@update are the triggers :P you can work on the rest you can remove me %co1,%brr vars, its for my color theme. Sue me... I put those months ago.

Of course include your own HOST and PATH at the very top of page.

Also I fixed the script to reflect mIRC 6.3 and yes it checks for the matching version, :P

Also note my original server i connected too is in script irc.fcirc.net, and finally if the script doesnt work you will have to make your own dirs /system/hash system/etc... << youll see at the top of the script, I can't remember if the MKDIR routine was added.
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#185588 - 11/09/07 12:47 PM Re: update script [Re: Lpfix5]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
Thnx for the code, but since i don't understand how to use that i wont be able to use it, no one that know about a update addon for mirc "script update" that is commented so it explain a bit what it does ?

And it should be able to update the files in the script dir by size.
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#185610 - 11/09/07 09:47 PM Re: update script [Re: sparta]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Originally Posted By: sparta
Thnx for the code, but since i don't understand how to use that i wont be able to use it, no one that know about a update addon for mirc "script update" that is commented so it explain a bit what it does ?

And it should be able to update the files in the script dir by size.


I don't remember the script so here I wrote you a new smaller coded one, you will probably need to add $regex routines to remove the Headers I just "Looked for all current headers" and remove them by an if statement in the sockread. So if you have a new/different header it will write to file but atleast you get the point.

Now I will leave my server info since I dont use it no more, but example the syntax is /update FILE.mrc

You can test the script off my server /update connect.mrc

Notice that $1 is File.mrc it will look online at the path and retrieve data from the file.

On my old site i used angelfire and make 2 dirs FCIRC and Update then loaded my scripts in without zipping them.

So the method i use here is read online at the filename then dump the data to temporary file, then write it to system and load it.

I DID NOT PROTECT THE ABILITY FOR SOMEONE TO INCCORECTLY TYPE THE SCRIPT NAME THEREFORE writting /update connnnect.mrc will make the script execute still and return bogus data and write it to file.

try the connect.mrc if you don't have one existing also you can add $isfile checks to see if the current file is active but atleast I built the base for you, your a good scripter you should have no problem from this step on. Use the code in whichever way you want..

Code:
alias update {
  if (!$1) { echo -a 4ERROR: Please input a file to update. }
  else {
    sockopen update www.angelfire.com 80
    %conn = $1
    ./timer 1 1 /chkini
  }
}

on 1:sockopen:update:{
  .sockwrite -n update GET $+(/music2/andresmp3/FCIRC/update/,%conn) HTTP/1.1
  .sockwrite -n update HOST: www.angelfire.com
  .sockwrite -n update $crlf
}

on 1:sockread:update:{
  if ($sockerr > 0) return
  var %x | sockread %x
  if ($sockbr == 0) return
  if (%x == $null) { return 2 }
  if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return }
  if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return }
  if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return }
  if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return }
  write -n temporary.txt %x $crlf
}

alias -l chkini { 
  var %x = 1
  while (%x <= $ini(mirc.ini,rfiles,0)) {
    if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { 
      if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | .timer 1 2 /updini }
      else { return }
    }
    inc %x
  }
  echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini
}

alias -l updini {
  var %x = 1
  while (%x <= $lines(temporary.txt)) {
    write -n %conn $crlf 
    inc %x
  }
  .load -rs %conn
  Echo -a Loaded/Updated $+(%conn,.)
  .remove temporary.txt
}
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#185631 - 12/09/07 05:18 AM Re: update script [Re: Lpfix5]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Sorry I forgot to use the $read routine to read temporary.txt LOL I fixed a few quirks. Now it will load properly and check if its existing has a "load".

Now if your gonna use this always has a update instead of download I really suggest adding the $isfile check or $exists also im sure you know how to make sure the data is not repeated.

And finally, just a side note again to make the /update command safe from wrong data being read, I would check to make sure the $1 is typed correctly, or if you are gonna use it has an menu click feature then it would be better where users don't have to type the file they want to update.

Well im not sure why im explaining that LOL im sure you know already how this works and what I mean


Code:
alias update {
  if (!$1) { echo -a 4ERROR: Please input a file to update. }
  else {
    sockopen update www.angelfire.com 80
    %conn = $1
    ./timer 1 1 /chkini
  }
}

on 1:sockopen:update:{
  .sockwrite -n update GET $+(/music2/andresmp3/FCIRC/update/,%conn) HTTP/1.1
  .sockwrite -n update HOST: www.angelfire.com
  .sockwrite -n update $crlf
}

on 1:sockread:update:{
  if ($sockerr > 0) return
  var %x | sockread %x
  if ($sockbr == 0) return
  if (%x == $null) { return 2 }
  if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return }
  if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return }
  if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return }
  if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return }
  write -n temporary.txt %x $crlf
}

alias -l chkini { 
  var %x = 1
  %xi = 1
  while (%x <= $ini(mirc.ini,rfiles,0)) {
    if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { 
      if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | unset %xi | .timer 1 2 /updini }
      else { return }
    }
    inc %x
  }
  .timer 1 4 /updtime
}

alias -l updini {
  var %x = 1
  while (%x <= $lines(temporary.txt)) {
    write -n %conn $read(temporary.txt,n,%x) $crlf 
    inc %x
  }
  .load -rs %conn
  Echo -a Loaded/Updated $+(%conn,.)
  .remove temporary.txt
}

alias -l updtime { 
  if (%xi) { echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } 
}
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#185655 - 12/09/07 12:43 PM Re: update script [Re: Lpfix5]
hixxy Offline
Hoopy frood

Registered: 06/09/05
Posts: 2876
Originally Posted By: Lpfix5
on 1:sockread:update:{
if ($sockerr > 0) return
var %x | sockread %x
if ($sockbr == 0) return
if (%x == $null) { return 2 }
if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return }
if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return }
if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return }
if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return }
write -n temporary.txt %x $crlf
}


Code:
on 1:sockread:update:{
  if ($sockerr) return
  var %x | sockread %x | tokenize 32 %x
  if (!$sockbr) || (!$0) || ($istok(HTTP/1.1 Date: Server: Set-Cookie: Vary: X-Server-IP: P3P: Last-Modified: Etag: Accept-Ranges: Content-Length: Content-Type:,$1,32)) { return }
  write -n temporary.txt %x $crlf
}

Top
#185671 - 12/09/07 02:32 PM Re: update script [Re: hixxy]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Originally Posted By: hixxy
Originally Posted By: Lpfix5
on 1:sockread:update:{
if ($sockerr > 0) return
var %x | sockread %x
if ($sockbr == 0) return
if (%x == $null) { return 2 }
if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return }
if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return }
if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return }
if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return }
write -n temporary.txt %x $crlf
}


Code:
on 1:sockread:update:{
  if ($sockerr) return
  var %x | sockread %x | tokenize 32 %x
  if (!$sockbr) || (!$0) || ($istok(HTTP/1.1 Date: Server: Set-Cookie: Vary: X-Server-IP: P3P: Last-Modified: Etag: Accept-Ranges: Content-Length: Content-Type:,$1,32)) { return }
  write -n temporary.txt %x $crlf
}


cool hixxy, i forgot about $istok, I rarely use the $***tok commands

Can anyone test the script for sparta, he's getting some errors and im not receiving any errors he even said im missing a bracket and I double checked the code.
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#185681 - 12/09/07 05:06 PM Re: update script [Re: Lpfix5]
sparta Offline
Planetary brain

Registered: 22/02/03
Posts: 3432
Loc: Sweden/Borlänge
The error i get with this code is:

* /: not connected to server

between / and : i got a new line $crlf chr, and i cant solve this, if i try remove the $crlf and test the script "one by one", then i get diffrent errors but not a clean update, it also for some reason miss the last } in the code, been testing this code over and over again, and still no go smirk the code i have in my test file is:
Code:
on *:load: { 
  echo -a Moooooooooooooooooooo
}

but when i get the file from the server, then it looks like:
Code:
on *:load: { 
  echo -a Moooooooooooooooooooo

and there is the missing bracket..

and this is what i find in the temporary.txt:
Code:
on *:load: { 

echo -a Moooooooooooooooooooo 

and one strange thing is that in the txt file it's no space between the the on *:load: { and the echo, but when i paste it here it get one empty line, maybe something to do with that?

by the way, mirc version 6.21 .. OS windows XP SP2.


Edited by sparta (12/09/07 05:12 PM)
_________________________
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }

Top
#185692 - 12/09/07 07:05 PM Re: update script [Re: sparta]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Originally Posted By: sparta
The error i get with this code is:

* /: not connected to server

between / and : i got a new line $crlf chr, and i cant solve this, if i try remove the $crlf and test the script "one by one", then i get diffrent errors but not a clean update, it also for some reason miss the last } in the code, been testing this code over and over again, and still no go smirk the code i have in my test file is:
Code:
on *:load: { 
  echo -a Moooooooooooooooooooo
}

but when i get the file from the server, then it looks like:
Code:
on *:load: { 
  echo -a Moooooooooooooooooooo

and there is the missing bracket..

and this is what i find in the temporary.txt:
Code:
on *:load: { 

echo -a Moooooooooooooooooooo 

and one strange thing is that in the txt file it's no space between the the on *:load: { and the echo, but when i paste it here it get one empty line, maybe something to do with that?

by the way, mirc version 6.21 .. OS windows XP SP2.


Ohhhhh pm me your server host and path and filename to get in question ill see whatsup
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#185700 - 12/09/07 10:18 PM Re: update script [Re: Lpfix5]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Here's a hotfix seems like my script will write } but your onload doesn't heres a hotfix I added a data chk updini is now fixed.

Code:

alias update {
  if (!$1) { echo -a 4ERROR: Please input a file to update. }
  else {
    sockopen update www.angelfire.com 80
    %conn = $1
    ./timer 1 1 /chkini
  }
}

on 1:sockopen:update:{
  .sockwrite -n update GET $+(/music2/andresmp3/FCIRC/update/,%conn) HTTP/1.1
  .sockwrite -n update HOST: www.angelfire.com
  .sockwrite -n update $crlf
}

on 1:sockread:update:{
  if ($sockerr > 0) return
  var %x | sockread %x
  if ($sockbr == 0) return
  if (%x == $null) { return 2 }
  if (HTTP/1.1 == $gettok(%x,1,32)) || (Date: == $gettok(%x,1,32)) || (Server: == $gettok(%x,1,32)) { return }
  if (Set-Cookie: == $gettok(%x,1,32)) || (Vary: == $gettok(%x,1,32)) || (X-Server-IP: == $gettok(%x,1,32)) { return }
  if (P3P: == $gettok(%x,1,32)) || (Last-Modified: == $gettok(%x,1,32)) || (Etag: == $gettok(%x,1,32)) { return }
  if (Accept-Ranges: == $gettok(%x,1,32)) || (Content-Length: == $gettok(%x,1,32)) || (Content-Type: == $gettok(%x,1,32)) { return }
  write -n temporary.txt %x $crlf
}

alias -l chkini { 
  var %x = 1
  %xi = 1
  while (%x <= $ini(mirc.ini,rfiles,0)) {
    if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { 
      if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | unset %xi | .timer 1 2 /updini }
      else { return }
    }
    inc %x
  }
  .timer 1 4 /updtime
}

alias -l updini {
  var %x = 1
  while (%x <= $lines(temporary.txt)) {
    write -n %conn $read(temporary.txt,n,%x) $crlf 
    inc %x
  }
  if ($read(temporary.txt,$lines(temporary.txt)) != $chr(125)) { 
    write -n %conn $chr(125)
    .load -rs %conn
    Echo -a Loaded/Updated $+(%conn,.)
    .remove temporary.txt
  }
  else { 
    .load -rs %conn
    Echo -a Loaded/Updated $+(%conn,.)
    .remove temporary.txt
  }
}

alias -l updtime { 
  if (%xi) { echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } 
}
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#185725 - 13/09/07 06:54 AM Re: update script [Re: Lpfix5]
deegee Offline
Fjord artisan

Registered: 16/06/06
Posts: 508
Loc: Storage
A simpler sockread event code...
Code:
on *:sockread:update:{
  if $sockerr { echo -aci info * Update failed: $sock($sockname).wsmsg | return }
  if $sock($sockname).mark { sockread -f &x | bwrite temporary.txt -1 -1 &x }
  else { var %x | sockread %x | if !%x { sockmark $sockname 1 } }
}

Top
#185768 - 13/09/07 07:05 PM Re: update script [Re: Lpfix5]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Update. test. Fill in your own host and path,

Code:
alias uu {
  if (!$1) { echo -a 4ERROR: Please input a file to update. }
  else {
    sockopen uu HOSTGOESHERE 80
    %conn = $1
    ./timer 1 1 /chkini
  }
}

on 1:sockopen:uu:{
  .sockwrite -n uu GET $+(/PATH/PATH/,%conn) HTTP/1.1
  .sockwrite -n uu HOST: HOSTGOESHERE
  .sockwrite -n uu $crlf
}

on *:sockread:uu:{
  if $sockerr { echo -aci info * Update failed: $sock($sockname).wsmsg | return }
  if $sock($sockname).mark { sockread -f &x | bwrite temporary.txt -1 -1 &x }
  else { var %x | sockread %x | if !%x { sockmark $sockname 1 } }
}

alias -l chkini { 
  var %x = 1
  %xi = 1
  while (%x <= $ini(mirc.ini,rfiles,0)) {
    if (%conn == $readini(mirc.ini,rfiles,$+(n,%x))) { 
      if ($input(Did you want to overwrite your current script?,y) == $true) { .unload -rs %conn | .rename %conn $+($left(%conn,-4),$time(hsns),.bck) | unset %xi | .timer 1 2 /updini }
      else { return }
    }
    inc %x
  }
  .timer 1 4 /updtime
}

alias -l updini {
  var %x = 1
  while (%x <= $lines(temporary.txt)) {
    write -n %conn $read(temporary.txt,n,%x) $crlf 
    inc %x
  }
  .load -rs %conn
  Echo -a Loaded/Updated $+(%conn,.)
  sockclose uu
  .remove temporary.txt
}

alias -l updtime { 
  if (%xi) { echo -a Script is not found/loaded in system. Using AUTO-LOAD System... | updini } 
}

_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top
#186117 - 17/09/07 08:10 PM Re: update script [Re: Lpfix5]
Lpfix5 Offline
Hoopy frood

Registered: 10/08/05
Posts: 1052
Loc: Canada
Im still looking back on the code and I notice everything is intact which is weird it didnt work out for you before. it's pretty much the same
_________________________
Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Top