Jump to content

Server Status Checker Help :(


Username:

Recommended Posts

I'm making a server status checker for a game, and it mostly works. But, it always displays as offline. Here is my code.

 

<?php	
     $status = GetServerStatus('24.68.198.193',43594); // IP or Hostname Goes Here
     function GetServerStatus($site, $port) {
          $fp = @fsockopen($site, $port, $errno, $errstr, 2);
          if (!$fp) { 
               $imagepath="off.png"; //OFFLINE IMAGE LINK!
               $image=imagecreatefrompng($imagepath);
               header('Content-Type: image/png');
               imagepng($image);
          } else { //ONLINE Status
               $imagepath="on.png"; //ONLINE IMAGE LINK!
               $image=imagecreatefrompng($imagepath);
               header('Content-Type: image/png');
               imagepng($image);
          }
     }
?>

 

 

I made sure 43594 port was open and that the IP was correct

http://www.dcfilms.org/status.php

 

Thanks in advance!

Link to comment
Share on other sites

Just move the call to your function under the actual function:

 

<?php
     function GetServerStatus($site, $port) {
          $fp = @fsockopen($site, $port, $errno, $errstr, 2);
          if (!$fp) { 
               $imagepath="off.png"; //OFFLINE IMAGE LINK!
               $image=imagecreatefrompng($imagepath);
               header('Content-Type: image/png');
               imagepng($image);
          } else { //ONLINE Status
               $imagepath="on.png"; //ONLINE IMAGE LINK!
               $image=imagecreatefrompng($imagepath);
               header('Content-Type: image/png');
               imagepng($image);
          }
     }
     $status = GetServerStatus('24.68.198.193',43594); // IP or Hostname Goes Here
?>

Link to comment
Share on other sites

Just move the call to your function under the actual function:

 

<?php
     function GetServerStatus($site, $port) {
          $fp = @fsockopen($site, $port, $errno, $errstr, 2);
          if (!$fp) { 
               $imagepath="off.png"; //OFFLINE IMAGE LINK!
               $image=imagecreatefrompng($imagepath);
               header('Content-Type: image/png');
               imagepng($image);
          } else { //ONLINE Status
               $imagepath="on.png"; //ONLINE IMAGE LINK!
               $image=imagecreatefrompng($imagepath);
               header('Content-Type: image/png');
               imagepng($image);
          }
     }
     $status = GetServerStatus('24.68.198.193',43594); // IP or Hostname Goes Here
?>

I'm doing my best not to come off as stupid, but this code still doesn't work and I think this may be to my host using a firewall.

 

...Or me being tired.

Link to comment
Share on other sites

Remove the "@" before the fsockopen call and see if it's generating any errors.

"The image “http://statuschecker.comule.com/status.php” cannot be displayed, because it contains errors."

And again, it displays, ONLY online again.

 

EDIT:

I changed the permissions to 777 and now it only displays "Online"

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.