RMS Home | Guide Writing | Test Server | New Servers | Latest Reviews

Author Topic: Server Status for Website - Need help  (Read 5640 times)

0 Members and 1 Guest are viewing this topic.

Offline lacroserocks

Server Status for Website - Need help
« on: Jul 11, 2006, 01:33 PM »
Ive looked all over the internet for a simple script to show the server status on my PHP-Nuke website ( http://here2obliterate.com ).

I found one that works pretty good but I had to do some major editing to the script in order to show all 3 servers ( login, char, and map ).

I got it working and it worked like a charm. But now for some reason, it keeps showing that the servers are offline even though I can get on the server. I have checked the port forwarding, refreshed page, closed browser and reloaded page with both IE and Firefox, but it still shows that its offline.

Does anyone know how to fix it or have any suggestions for a better one that works?

Also, ratemyserver.net has a server status and it works for my server showing that its Online. Is it possible for me to get that script/files?


Heres what im using right now that doesnt work anymore:
Code: [Select]
<?php
$live 
"live.gif";
$dead "dead.gif";
$link $_GET['link'].":";
$s_link str_replace("::"":"$link);
list(
$addr,$port)= explode (':',"$s_link");
if (empty(
$port)){
$port 6900;
}
$churl = @fsockopen(server($addr), $port$errno$errstr20);
             if (!
$churl){
 //echo $errstr;
                
header("Location: $dead");
                }
             else {
             
  header("Location: $live");             
  }
function 
server($addr){
         if(
strstr($addr,"/")){$addr substr($addr0strpos($addr"/"));}
         return 
$addr;
}
?>


And i have 3 versions of this file ( one for each port ) on my website.

Then I use this HTML code to show it:
Code: [Select]
<tr>
    <td><font>Login</font></td>
    <td><img src="login_status.php?link=66.57.29.197"></td>
</tr>

And I have 2 more using the 3 different files: login_status.php , char_status.php , map_status.php

And I have 2 pictures (red and green poring) showing that its online or ofline.

It used to work but now it doesnt.

So can anyone get me a script that works better or tell me how to fix this?
« Last Edit: Dec 03, 2009, 04:59 PM by Relics »

Advertisement

Offline yC

Re: Server Status for Website - Need help
« Reply #1 on: Jul 11, 2006, 09:34 PM »
I took out few things that I found can be ignored and came up with this simplier version:

Code: [Select]
<?php
$live 
"live.gif";
$dead "dead.gif";
$link $_GET['link'];

if (empty(
$port)){
$port 6900;
}
$churl = @fsockopen($link$port$errno$errstr5);
 
if (!
$churl){
    
header("Location: $dead");
}else {
    
header("Location: $live");             
}

?>


it should work, u can just try it with:

login_status.php?link=66.57.29.197

without the port parameter, it will use the default port 6900, if u need to check other ports u use:

login_status.php?link=66.57.29.197&port=6121
login_status.php?link=66.57.29.197&port=5121
...etc

i also recommend a lower time for timeout,
"$churl = @fsockopen($link, $port, $errno, $errstr, 5);" 
that 5 there is how long should the script give up trying to connect, u had 20 seconds which means if server is down it will take 20 seconds for it to show the status...well that's a preference you might want to change to whatever you like.

The reason that your script stopped working...could it be you have a different format of IP or URL in the link= parameter than u used to have?  Because it looks like your script is designed to handle URL instead of a simple IP address.  Since you have a simple IP address, you don't need all the other fancy stuff.
« Last Edit: Jul 11, 2006, 09:43 PM by yC »

Offline lacroserocks

Re: Server Status for Website - Need help
« Reply #2 on: Jul 12, 2006, 09:19 PM »
well i dont know what happened but i hadnt changed anything. I went away for a 10 day vacation and came back to find it not working.

but ill try your way. Thanks.