Paragon mIRC Stats Version 4.5

 

Topics:

The concept



Right, so you're interested in making a mIRC Stats webpage for yourself. In this tutorial like documentation I'm going to explain the basics into doing this, I say basics because virtually anything can be done with it, within the limitations of mIRC and HTML ofcourse..

Basicly, a mIRC Stats webpage exists of two files (not counting files such as images). One file, which has the .msw extention, holds some information about the page; it's name, the author, etc.. The other file, which can have any extention you like with exeption of .msw, contains the actual webpage.
The webpage is scripted, meaning it's contained in an alias (which you specify in the .msw file) and you can use all mIRC's commands and identifiers, but ofcourse it's best to stick to what you actually need. The alias is called everytime someone accesses or refreshes the page, so it's important you don't slow it don't too much, this can be done by scripting multiple pages so not everything is loaded at once for example.

All webpages are stored in the webpage folder inside mIRC Stats' own folder. In there, each webpage has it's own folder, to prevent filename collisions.

The .msw file.



This is the file which holds the information about your webpage. It's simply a text file, but with the .msw extention, so it can be listed by mIRC Stats.

Each type of information is stored on a seperate line, you're allowed to leave lines blank if you want to, and lines starting with a semicolor (;) will be treated as a comment and thus ignored.
The line starts with a keyword, which specifies what kind of info you're giving, after that comes the information. Note that the items are not case sensetive.

Here are the items:
  • Name - This is the name of the webpage.
  • Author - The name or nickname of the page's author.
  • Email - E-mail address of the author.
  • Website - Website for the page or author.
  • Description - A brief description of the page.
  • Version - The version of the page. A new version of the same page should always have a value that is greater than (>) the previous version's value.
  • MSVersion - The version of mIRC Stats the page is created for. This way the user can see if the page is fully supported. Unless big changes are made in mIRC Stats, it will probably still always be loadable, disregarding what version it was made for.
  • Script - The filename of a mIRC script which contains the alias with the webpage in it.
  • Alias - This is the alias mIRC Stats must call to show the webpage (NOTE: must not be an existing alias, make it as unique as possible!).
For example:
Name Example
Author Voice of Power
Email marckuiper@hotmail.com
Website none
Description This is an example description, blah blah blah.
Version 1.0
MSVersion 4.5
Script example.mrc
Alias statswebexample

Building a basic page



Ok, after creating the 'supportive file', it's time to build the actual webpage. Here's a few basic things you should know:
  • To make this, you need atleast basic mIRC scripting knowledge.
  • Also some HTML knowledge would be helpfull.
  • Just like the other, this file too is a simple text file, just as any mIRC script is, this file will be loaded into mIRC's remote section.
  • If you intend on actually sending code to the user connecting to the page, use the /sw command, which is explained below.
  • Most data (counters and system info) is returned by $sinfo. But some data, such as server info and HDD info, has to be scripted, full examples given below.
  • The file can contain additional aliases for you to use, make those local to prevent collision problems. Obviously the main alias should not be local.
  • Any of mIRC /aliases and $identifiers can be used.

Since everything is basicly scripted in mIRC, you cannot just place all HTML in the file, and expect the data to be sent to the user connecting to the page. You will need to use a command for this: /sw. This command stands for mIRC's /sockwrite, and all you need to know about it really is that it sends the data to the user.

Let us begin with a simple test, to see how everything works. If you don't know much about scripting, I'd advise you to follow every step I take closely.
The following example would be your script file. As you can see everything's inclosed in the alias provided in the .msw file, and it's a combination of HTML and mIRC scripting. I've provided comments in green.

; the alias
alias statswebexample {
    ; this data is sent to the user
    sw <html>
    sw blablabla
    sw </html>
}


If you'd load this as a webpage, and then connect to your ip (ofcourse after using /statsweb), you'd see 'blablabla'. You've just created the most basic type of webpage possible.

Ofcourse we don't intend on keeping it this simple, we want to show statistics, and if possible in a nice looking interface too. So let us add some information using $sinfo:

alias statswebexample {
    sw <html>
    sw <head>
    ; this is the title of the webpage. though you don't have to, you can see I've added the window title information
   
; which you can set in the config dialog, using $sinfo
    ; NOTE: as with all mIRC identifiers, you need to enclose it with spaces, otherwise everything after it will not be sent
   
sw <title> Example webpage: $sinfo(p,wintitle) </title>
    sw </head>

    sw <body>
    ; just like the title, once again don't forget about the spaces, just try it to see what shows up now
    sw Nickname: $sinfo(p,nick) <br>
    sw Full name: $sinfo(p,fullname) <br>
    sw </body>

    sw </html>
}


That already looks a lot more interesting doesn't it? All you need to do now practicly is build some kind of table around it and use more of the features of $sinfo, voila!
But again there's more we want, and more we CAN do. For instance you might want to add a box in which you show the time and such. But if you remember correctly, and you do, you can disable that in the config dialog. So you have to live up to that.
I'll no longer include the entire alias, just the part which is significant for the example:

; this code has been directly extracted from the default webpage
; as you can see, you can use if statements, this one checks wether to show the time or not
; as explained in the documentation for $sinfo, showtime returns $true or $false
if ($sinfo(p,showtime)) {
    sw <table width="300" class="bar">
    sw <tr><td colspan=2>Time:<hr></td></tr>
    sw <tr><td width=100>Hour:</td><td> $sinfo(t,time) </td></tr>
    sw <tr><td>Date:</td><td> $sinfo(t,date) <br><br></td></tr>
    sw <tr><td>Total online:</td><td> $sinfo(t,totalonline) </td></tr>
    sw <tr><td>mIRC uptime:</td><td> $sinfo(t,mirc) </td></tr>
    sw <tr><td>System uptime:</td><td> $sinfo(t,system) </td></tr>
    sw </table>
}


This would look something like this:

Time:
Hour: 20:31:48 (+1 GMT)
Date: Saturday 15/11/2003

Total online: 15hrs 20mins 24secs
mIRC uptime: 7hrs 43mins 40secs
System uptime: 8hrs 9mins 35secs

Multiple pages in one



Now that you understand the basics of how to make a webpage (I gave only few examples, but you know what you can do with $sinfo now), it is time to explain how to create multiple pages. Because I can understand you may not want everything gathered on a single page.

This is where the $1 parameter comes in. When mIRC Stats calls for the alias, it will also send some extra data along with it. Which is, as with all mIRC scripting, stored in $1.

Say, for example, someone connects to your page. This would mean the url would be something like: http://192.168.0.24:80/ (example ip). In this case, $1 would be '/'. And as you can see, a '/' is placed after the ip address.

Now, you place a link on your page, and you call it something like "/info". In this case, if someone clicks on the link, the url would become http://192.168.0.24:80/info. And $1 will be '/info'.

If you understand this, you know the rest is very simple, just make an if statement which checks what value $1 has. For example:

if ($1 == /info) {
    sw This is where all kind of information goes.
}
elseif (/blah* iswm $1) {
    sw Different info is stored here.
}
else {
    sw This would be displayed when the user first connects to the page.
}


This way you can prevent from loading times being too long, or a page getting simply too big. Plus it adds more interactivity to it all.

Ofcourse with this you can fake filenames, such as .php. And you can also make stuff like /file.php?id=172&view=1 for example, whatever you want..

Scripting servers information



This is the most difficult part of the webpage, and a higher knowledge of mIRC scripting is needed for this. The case is, it's not practical to let this data be returned by $sinfo, or any other home made alias.

There's multiple ways for displaying all of the data for the server; all at once, a list of servers and when selected new lists of channels and query's (and their data) emerges, and probably more...

Since it's would be a bit boring for me to cough up everything you'd need to do to script all of this, I will just keep it a bit more basic. To begin with, a way to list the servers (in a table for instance), which is easy enough:

; once again extracted from the default webpage
sw <table width="96%" class="bar">
; the header of the table
sw <tr><td>Server<hr></td><td>Network<hr></td><td>Nick<hr></td><td>Chans<hr></td><td>Query's<hr></td><td>More Info<hr></td></tr>
; this will check if you're connected at all, and if you're disconnected it will display that in the table
if ($scon(1).status == disconnected) { sw <tr><td>Not connected</td><td>-</td><td>-</td><td>-</td><td>-</td><td>-</td></td> }
; a few local variables for the while loop
var %s1 = $scon(0),%s2 = 1
; while loop which will loop through all connections
while (%s2 <= %s1) {
    ; checks if you're connected to the Nth server
    if ($scon(%s2).status == connected) {
    ; changes the active connection for the script (in other words identifiers and such will work for the Nth server)
        scon %s2
    ; will add various informations about the server, such as it's url, the network, your nick..
        sw <tr><td><a href="irc:// $+ $server $+ /"> $server </a></td><td> $iif($network,$ifmatch,unknown) </td><td> $me </td><td> $chan(0) </td><td> $query(0) </td><td><a href="/servers/?id= $+ %s2 $+ ">Click!</a></tr>
    }
    inc %s2 1
}
sw </table><hr>


This might look very complicated, but just paste it into your webpage and you'll see it's just a very long line (because of all the table cells and all).
As you can see I've used identifiers such as $scon, $chan and $query to retrieve some information about the servers. And /scon to switch through the servers. See mIRC's help file for a more detailed documentation for them.

You've probably already seen how the default webpage works. If so, you know you have to click the 'Click!' link to get more info about the selected server and a list of the open channels and query's. When clicking it you are linked to an url with the id of the server in it, so you can list various stuff for that connection, such as server information (but also anything you want..).

I will not provide any extensive examples here, as you can see how everything works in one of the webpages. But I will give a list on what identifiers you can use in order to list the info: See the mIRC help file for more detailed descriptions.

For the channel information, you can use $chan(0) to loop them, and the $nick and $chan identifiers to retrieve information about them. See mIRC's help file or other webpages for more info.

For the query informtaion, you can use $query(0) to loop them, and the $query and $comchan identifiers to retrieve information about them. Again see mIRC's help file or the other webpages.

Just fool around with it a bit, and use the $1 parameter wisely. You'll see it isn't that hard to figure out.

Scripting HDD information



There is one more part that will need to be fully scripted, and that's the HDD information. Again a while loop is needed, and the $disk identifier is used to retrieve the information.
I wont provide a full example of how you can handle everything along with the total size (you'll have to store the information somehow then), instead I'll give the easiest way of getting some information about then. The rest can be seen in the other webpages.

; the loop will start at ascii character 67, which is C. and it will go on till 90, which is Z
var %l = 67
while (%l <= 90) {
    ; checks if the disk exists, using $chr
    if ($disk($chr(%l))) {
        ; setting the free space to %f, and the size to %s, since those a used often in the next line
        var %f = $disk($chr(%l)).free,%s = $disk($chr(%l)).size
        ; the disk's symbol and label (C: (SYSTEM))
        sw $chr(%l) $+ : ( $+ $iif($disk($chr(%l)).label,$disk($chr(%l)).label,No label) $+ )
        ; the type of the disk (fixed, cdrom, removable, remote)
        sw $disk($chr(%l)).type
        ; the full size of the disk
        sw $bytes(%s,3).suf
        ; the ammount of space used
        sw $bytes($calc(%s - %f),3).suf
        ; the ammount of space left
        sw $bytes(%f,3).suf
        ; the ammount of space left, in a percentage
        sw $round($calc((%f / %s)*100),1) $+ %
    }
    inc %l
}

Other usefull tips



Here are some things you should note when making a webpage, or just some handy tips:
  • Never use /halt, it will screw up. Use /return instead if you really want to stop displaying of the page.
  • Also, do not close the socket yourself, let mIRC Stats do that for you.
  • A webpage should not contain the mIRC on LOAD and on UNLOAD events. There is no need.
  • Try not to make too large pages, you will experience lag everytime someone refreshes your page then.
  • Try to live up to the showing or not of various aspects of the page. So if someone disables the showing of the system stats, it's not displayed anyway.
  • You can show how long it took to generate the page by putting at the beginning: var %ticks = $ticks, and at the end: $calc(($ticks - %ticks) /1000) secs.
  • You can use any mIRC alias you like, try to experiment.
  • You can also put additional aliases in the file, but make those local to prevent problems.
  • The main alias in not local.
If you feel like something is missing, or something isn't explained well enough, just contact me about it and I will look into it.



Paragon mIRC Stats Contact