Digital Paint Discussion Board

Paintball 2: The Game => Paintball 2 Discussion => Topic started by: Smokey on July 09, 2007, 03:11:57 PM

Title: Server Status Script For Websites.
Post by: Smokey on July 09, 2007, 03:11:57 PM
I have made a small script for clans and other groups to display server status on their websites.

The information can be included in your page via an iframe, or a
Code: [Select]
<?PHP  file_get_contents("http://www.zilla-clan.net/dpq/?ip=12.34.56.789&port=27910");
?>
The source is available upon Request.

Usage: http://www.zilla-clan.net/dpq/?ip=SERVERIP&port=SERVERPORT

Example:
http://www.zilla-clan.net/dpq/?ip=70.85.9.178&port=27922

The look of it (link color, font) can be modified by adding the desired style to a div class called "stats" to your CSS.
 ;)
Title: Re: Server Status Script For Websites.
Post by: T3RR0R15T on July 09, 2007, 03:54:52 PM
Nice, can u make the playerlist too?
Title: Re: Server Status Script For Websites.
Post by: y00tz on July 09, 2007, 03:57:08 PM
Awesome Smokey :D :D

I made something like this but it requires PHP5... something a lot of servers don't run yet.
Title: Re: Server Status Script For Websites.
Post by: Smokey on July 09, 2007, 04:14:47 PM
Awesome Smokey :D :D

I made something like this but it requires PHP5... something a lot of servers don't run yet.
Well, the whole point of this is that clans who don't have php enabled websites (lol) or don't know how to use it and such can just use that :)

As for the playerlist, meh. I'll see what I can come up with :)
Title: Re: Server Status Script For Websites.
Post by: KnacK on July 09, 2007, 04:46:51 PM
Good Job Smokey.
Title: Re: Server Status Script For Websites.
Post by: Smokey on July 09, 2007, 05:13:28 PM
Doesn't load lekky :)

Edit:
webSPELL version: 4.01.02
PHP version: 4.4.1
MySQL version:

ERROR: Can not connect to MySQL-Server
Title: Re: Server Status Script For Websites.
Post by: lekky on July 09, 2007, 05:36:55 PM
:P

http://qehs.indiereview.co.uk/webspell/index.php?site=server_stats

It's a dajoob so I wondered if it was you?
Title: Re: Server Status Script For Websites.
Post by: Smokey on July 09, 2007, 06:02:23 PM
:P

http://qehs.indiereview.co.uk/webspell/index.php?site=server_stats

It's a dajoob so I wondered if it was you?
Whats the direct URL? It probably is mine though, lol.
Title: Re: Server Status Script For Websites.
Post by: Zorchenhimer on July 09, 2007, 06:13:38 PM
http://qehs.indiereview.co.uk/webspell/index.php?site=server_stats

You might want to strip the funnames for the player list. Those make it hard to read.
Title: Re: Server Status Script For Websites.
Post by: Smokey on July 09, 2007, 06:54:47 PM
http://qehs.indiereview.co.uk/webspell/index.php?site=server_stats

You might want to strip the funnames for the player list. Those make it hard to read.
Yea, I'm going to figure out a way to do that and include it in this.
Title: Re: Server Status Script For Websites.
Post by: Cobo on July 09, 2007, 07:05:55 PM
Take a look at the server browser code. Since it basicly does what you want to do with every server.
Title: Re: Server Status Script For Websites.
Post by: jitspoe on July 09, 2007, 08:14:54 PM
Code: [Select]
$char_remap =
        "\0---_*t.N-\n#.>**".
        "[]@@@@@@<>.-*---".
        " !\"#\$%&'()*+,-./".
        "0123456789:;<=>?".
        "@ABCDEFGHIJKLMNO".
        "PQRSTUVWXYZ[\\]^_".
        "`abcdefghijklmno".
        "pqrstuvwxyz{|}~<".
        "(=)^!OUICCR#?>**".
        "[]@@@@@@<>*X*---".
        " !\"#\$%&'()*+,-./".
        "0123456789:;<=>?".
        "@ABCDEFGHIJKLMNO".
        "PQRSTUVWXYZ[\\]^_".
        "`ABCDEFGHIJKLMNO".
        "PQRSTUVWXYZ{|}~<";


// strip out the garbage characters such as color codes
// and map extended ascii to something readable...
function strip_garbage ($instr) {
        $outstr = "";
        $len = strlen($instr);
        global $char_remap;
        for ($i = 0; $i < $len; $i++) {
                $c = ord($instr[$i]);
                switch ($c) {
                case CHAR_COLOR:
                        $i++;
                        break;
                case CHAR_ITALICS:
                case CHAR_UNDERLINE:
                case CHAR_ENDFORMAT:
                        break;
                default:
                        $outstr .= $char_remap[$c];
                }
        }
        return $outstr;
}

Title: Re: Server Status Script For Websites.
Post by: Smokey on July 10, 2007, 11:58:51 AM
Eww, What are you using to format your code? Thats ugly stuff :)


But thanks <3
Title: Re: Server Status Script For Websites.
Post by: Eiii on July 10, 2007, 04:29:07 PM
It might be nice if you included the values of CHAR_ITALICS, etc.
Title: Re: Server Status Script For Websites.
Post by: Cobo on July 10, 2007, 06:38:55 PM
Easy to do on php, but pretty hard on c, for what I know.
Title: Re: Server Status Script For Websites.
Post by: jitspoe on July 10, 2007, 08:54:04 PM
Good point, Eiii:

Code: [Select]
define("CHAR_ENDFORMAT", 133);
define("CHAR_UNDERLINE", 134);
define("CHAR_ITALICS", 135);
define("CHAR_COLOR", 136);

Smokey: What's ugly, tab indents? :P  My PHP coding style is pretty compact.  I have a lot more whitespace in C code since it's usually harder to follow.

Cobo: I think the C version of this function may actually be simpler.
Title: Re: Server Status Script For Websites.
Post by: Cobo on July 10, 2007, 09:40:49 PM
:-\ Well, I dont even know how to make part of a word in italics/underline/color on c. Just a whole word. In PHP that just means adding something like <i> tags.

Title: Re: Server Status Script For Websites.
Post by: Smokey on July 10, 2007, 10:04:06 PM
Smokey: What's ugly, tab indents? :P  My PHP coding style is pretty compact.  I have a lot more whitespace in C code since it's usually harder to follow.
The whitespace is the ugly part. :)


Source: http://zilla-clan.net/dpq/source.php
Title: Re: Server Status Script For Websites.
Post by: Cobo on July 10, 2007, 10:18:24 PM
Oh... I just noticed that Eiii meant the definitions of the characters :P
Silly me.  :-[
Title: Re: Server Status Script For Websites.
Post by: sk89q on July 11, 2007, 01:51:31 PM
By the way, never include() an external URL in PHP. It will actually execute any PHP code on that page, and you obviously can realize the risk if the server maintainer turns evil or the server is hacked.

file_get_contents() is the way to go (or fsockopen(), feof(), fread(), fclose() if your version of PHP is that old).
Title: Re: Server Status Script For Websites.
Post by: Smokey on July 11, 2007, 01:57:36 PM
By the way, never include() an external URL in PHP. It will actually execute any PHP code on that page, and you obviously can realize the risk if the server maintainer turns evil or the server is hacked.

file_get_contents() is the way to go (or fsockopen(), feof(), fread(), fclose() if your version of PHP is that old).
Thats what i meant, file_get_contents()
Thanks! :)