Server query script a la serverspy

News for the main page
User avatar
Edge100x
Founder
Founder
Posts: 12219
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Server query script a la serverspy

Post by Edge100x » Wed Aug 27, 2003 11:46 pm

We have created a server query script to make it easy to add current information on your server's status to your website. We now also use this script on the status page in the control panel.

To take advantage of our script yourself, simply add code like the following to a webpage that we host:

Code: Select all

<iframe src="http://rentals.nuclearfallout.net/query/stat.pl?id=chernobyl" width=400 height=600 frameborder=0 />
You would need to replace the value of "id" with your server's identifier (your login name for the control panel). That code there would produce this output.

You can also customize the output to match your site, because every part of the page the script generates can be controlled by a stylesheet. The default stylesheet is here -- you can right-click and select "Save As" to save it to your hard drive. After editing it, upload the file to your webspace. You can specify the customized stylesheet when you call our script by using the "style" parameter. For instance, if I were to create my own stylesheet named "white.css" and upload it to my webspace, I could use this in my webpage instead of what was given above:

Code: Select all

<iframe src="http://rentals.nuclearfallout.net/query/stat.pl?id=chernobyl&style=white" width=400 height=600 frameborder=0 />
In fact, I did copy default.css to a new file, white.css, and changed the background color to white, got rid of the server information block and player list heading, changed some colors, altered the spacing in the player table, and doubled the image size, all by editing that file. The resulting stylesheet is here and would give this output.

You can even get rid of everything but a couple of lines if you want, to fit just the essentials in a small spot on your site. For example, this, which uses my minimal.css stylesheet.

This site provides more information on iframe options (such as specifying the width and height, or taking away the scrollbar). You could also use a standard frame instead of an iframe, if you prefer.

Advanced users may prefer to retrieve the status information via a script and embed it directly into their page, instead of bothering with frames. For example, this short Perl script would do that:

Code: Select all

#!/usr/bin/perl

use LWP::Simple;

print qq|
Content-type: text/html

<html>
<head>
  <title>Example script with server status inclusion</title>
</head>
<body>
This is Chernobyl's server status:<p />
|;

getprint "http://rentals.nuclearfallout.net/query/stat.pl?id=chernobyl&style=white&no-body=1";

print "<p /><i>Copyright (c) 2003 Nuclearfallout Enterprises, Inc.</i>";
That script's output would look something like this.

You'll note that in the code fragment we used another parameter -- "no-body". A "1" for that parameter indicates to our query script that no <body> tag should be included in the page output, and it is needed because placing two body tags in one document can be unnecessary and problematic.

A PHP version of that script would look like this:

Code: Select all

<html>
<head>
  <title>Example script with server status inclusion</title>
</head>
<body>
This is Chernobyl's server status:<p />

<?php
echo(implode("", file("http://rentals.nuclearfallout.net/query/stat.pl?id=chernobyl&style=white&no-body=1")));
?>

<p /><i>Copyright (c) 2003 Nuclearfallout Enterprises, Inc.</i>
And would give the same output.
Last edited by Edge100x on Thu Aug 28, 2003 9:33 pm, edited 7 times in total.

crab
This is my homepage
This is my homepage
Posts: 105
Joined: Tue May 13, 2003 7:54 am

Post by crab » Thu Aug 28, 2003 10:02 am

Thanks for doing this. This is much better than the serverspy because you don't have to deal with those dumbass popups. I took serverspy off my sight because I hate popups so much and I couldn't stand to be responsible for them on someone else's computer.

I did have an issue using this code though. When I used the code for a site hosted by nfo, it didn't work, and my site is hosted by nfo. However, when I used the code for a site hosted elsewhere it worked perfectly.

http://myclan.nuclearfallout.net

User avatar
dL-Templisk
This is my homepage
This is my homepage
Posts: 118
Joined: Sat Jul 26, 2003 8:56 pm
Location: California, USA
Contact:

Post by dL-Templisk » Thu Aug 28, 2003 10:38 am

I don't use NFo's website at all, but was using the script and I can't get the style to work right, I added &style=white for example and it'd use the one you have up, then I tried &style=custom and uploaded a custom css to my site for NFo but it didn't register at all, it used default settings (white background black text etc.)

User avatar
Edge100x
Founder
Founder
Posts: 12219
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Post by Edge100x » Thu Aug 28, 2003 11:30 am

Templisk: Make sure the .css file is in the same directory you are calling the script from -- otherwise it won't be able to find it.

Crab: My instructions were incorrect and you have to always use it with the http://rentals part, sorry about that.

Does anyone have suggestions for modifications to the default.css file? I'd be happy to add more of them for people to choose from, or to change the default to look more interesting.

User avatar
dL-Templisk
This is my homepage
This is my homepage
Posts: 118
Joined: Sat Jul 26, 2003 8:56 pm
Location: California, USA
Contact:

Post by dL-Templisk » Thu Aug 28, 2003 3:55 pm

It's much too wide. You should try a black/blue and black/red and a few variations of grey.(backgrounds) Those seem to be the most commonly used colors on the net. Other than that it looks pretty good, nice work :)

User avatar
Edge100x
Founder
Founder
Posts: 12219
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Post by Edge100x » Thu Aug 28, 2003 5:07 pm

Well, it's width can be easily adjusted with the css file, as can the colors. Do you have a modified file ready that I could consider putting in its place instead? :D

User avatar
dL-Templisk
This is my homepage
This is my homepage
Posts: 118
Joined: Sat Jul 26, 2003 8:56 pm
Location: California, USA
Contact:

Post by dL-Templisk » Thu Aug 28, 2003 5:10 pm

I was just talking about the default one, most of the sites I've seen use navbars with a width of 150 or less, mine is 150 and resizing everything didn't help no matter where I put the modified css. Where do I put the css anyways? I put the iframe on my site, http://www.thedarklegacy.net/beta.php and I changed the iframe source to match the css' name but it doesn't seem to change at all even with the css on my site and on the NFo site...

If you want, I'll mess around with a few versions of it and email them to rentals@nuclearfallout.net they probably won't be really good but will give you a general idea of what I meant =P

User avatar
dL-Templisk
This is my homepage
This is my homepage
Posts: 118
Joined: Sat Jul 26, 2003 8:56 pm
Location: California, USA
Contact:

Post by dL-Templisk » Thu Aug 28, 2003 5:39 pm

I fixed it, I have a request though instead of showing IP as darklegacy.nuclearfallout.net:27015 can we choose generic IP? 66.117.18.16:27015? I can't find anything in the css that would control it. And is there a way to get rid of specific parts of the information table such as "Currently Locked?"

User avatar
Edge100x
Founder
Founder
Posts: 12219
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Post by Edge100x » Thu Aug 28, 2003 7:27 pm

I'll work on adding additional options to the stylesheet to control those.

User avatar
Edge100x
Founder
Founder
Posts: 12219
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Post by Edge100x » Thu Aug 28, 2003 9:49 pm

Done. IP can be displayed now and each section in the first table can be eliminated.

User avatar
Nick|NFo
Former staff
Former staff
Posts: 2252
Joined: Sun Mar 30, 2003 1:56 pm
Location: 127.0.0.1

Post by Nick|NFo » Fri Sep 05, 2003 12:46 am

hmm I was playing with it and I couldnt get it to call my own css file, either locally just viewing the file on my hard drive, or on the internet on my webspace :/

kept going to the white background with black lettering

User avatar
dL-Templisk
This is my homepage
This is my homepage
Posts: 118
Joined: Sat Jul 26, 2003 8:56 pm
Location: California, USA
Contact:

Post by dL-Templisk » Fri Sep 05, 2003 5:05 am

it worked for me when I put at the end:
&style=http://www.thedarklegacy.net/style.css

Maybe you have to specify the exact location o_O

User avatar
Nick|NFo
Former staff
Former staff
Posts: 2252
Joined: Sun Mar 30, 2003 1:56 pm
Location: 127.0.0.1

Post by Nick|NFo » Fri Sep 05, 2003 7:59 am

dL-Templisk wrote:it worked for me when I put at the end:
&style=http://www.thedarklegacy.net/style.css

Maybe you have to specify the exact location o_O
ya I was thinking of doing that, then I said, it must be something Im doing wrong

User avatar
Nick|NFo
Former staff
Former staff
Posts: 2252
Joined: Sun Mar 30, 2003 1:56 pm
Location: 127.0.0.1

Post by Nick|NFo » Fri Sep 05, 2003 9:09 am

is there anyway to get the ping working to our server perhaps?

It said it works for bf194, q3 etc, not cs?

Also: cant get the show ip working :/ I deleted the display:none in it

Code: Select all

row-ip { }
thats what it looks like, but no IP shows :( everything else works

User avatar
Nick|NFo
Former staff
Former staff
Posts: 2252
Joined: Sun Mar 30, 2003 1:56 pm
Location: 127.0.0.1

Post by Nick|NFo » Fri Sep 05, 2003 9:34 am

rawr!!

I fixed the server ip, had to delete some stuff with the key-ip etc etc

anyways, think we can have the ping similar to the locations link perhaps?

Post Reply