mIRC Home    About    Download    Register    News    Help

Print Thread
#6240 12/01/03 11:21 AM
R
rserewrew
rserewrew
R
My question is:
If i do a new release of my script I just want the script [on start] check if there is a new version of thew script online [http://....] and in case of positive reply ask for the download, in case of a negative reply puts an echo [no new version]...

Can any1 help me?

#6241 12/01/03 12:31 PM
T
theRat
theRat
T
/help sockets
www.google.com and search for http protocol rfc

#6242 12/01/03 12:49 PM
R
rserewrew
rserewrew
R
i know a little sockets, but if i had knew how to do the script...

#6243 12/01/03 03:49 PM
Joined: Dec 2002
Posts: 1,253
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,253
The simplest way to do what you want is to put a version text file on your web site that just contains a line that has the version number (or build number) <space> URL link to the file, followed by a blank line. It's a simple matter to then open a socket to your web site, GET that file and compare the value found against the current version/build that's in use, stored inside your script somewhere, such as in a variable, in an .ini file or in a hash table entry.
Code:

on *:START: sockopen VersionCheck.YourScriptName www.mysite.com 80
on *:SOCKOPEN:VersionCheck.YourScriptName: sockwrite -n $sockname GET /path/to/MyVersion.txt
on *:SOCKREAD:VersionCheck.YourScriptName:{
  var %version
  sockread %version
  tokenize 32 %version
  if ($1 &gt; %Version.MyScript) echo 4 -ati2 * A newer version exists. Download it at $2
  sockclose $sockname
}

MyVersion.txt
12345 http[/b]://www[/b].mysite.com/downloads/MyScript-12345.zip
<blank line>

#6244 12/01/03 05:15 PM
R
rserewrew
rserewrew
R
thank you!!!!

#6245 15/01/03 10:14 AM
N
N3xo
N3xo
N
Good script!
But if there is a new versione i'd like it opens a dialog in wich i have "new script! do you want to download it?" with 2 buttons, "yes" and "no".

If i click yes it have to download the new script.

Is it possible?

#6246 15/01/03 10:25 AM
Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Something like:
Code:
on *:START: sockopen VersionCheck.YourScriptName www.mysite.com 80
on *:SOCKOPEN:VersionCheck.YourScriptName: sockwrite -n $sockname GET /path/to/MyVersion.txt
on *:SOCKREAD:VersionCheck.YourScriptName:{
  var %version  
  sockread %version  
  tokenize 32 %version  
  sockclose $sockname
  if ($1 &gt; %Version.MyScript) {
    if ( $input(YourScriptName has been updated $+ $chr(44) goto the website?,y,Update available) == $true ) {
      run http://website.com/download.html
    }
  }
}

#6247 15/01/03 03:01 PM
Joined: Dec 2002
Posts: 1,253
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,253
Since that on SOCKREAD is a running event, you can't halt it to ask for input; you would have to put the $input inside an alias and call the alias (using the URL as a parameter to that alias) on a timer to get it "out of the event." I would also suggest storing the new script URL in your script somewhere in case they don't wish to upgrade right then - they could click on an upgrade button somewhere and have it download the script. smile

#6248 15/01/03 03:09 PM
Joined: Dec 2002
Posts: 3,015
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,015
Mmm? It worked for me fine..only problem was I had to put /sockclose first.


Link Copied to Clipboard