Jump to content

Server Status Check


sam240

Recommended Posts

I got this code off of this forum

<?php
$ip="{$_GET['ip']}";
$port="{$_GET['port']}";
header('Content-type: image/png');
if(!$sock=@fsockopen($ip,"$port", $num, $error, 5)) {
readfile('image/offline.png');
} else {
readfile('image/online.png');
}
?>

I'm able to check the status by going to

 http://domain.com/statuscheck.php?ip=google.com&port=80

and it works fine. But I would like to show the status on my index.html page without having to click on a link. Is there anyway Please help. :'(

thank you in Advance.

Link to comment
Share on other sites

you could do it two ways:  first would be to write a script that looks for your key word. (i went to the page but got a 404 error, so don't know if it's "online" or whatever). you could assign the result to a variable and echo it with fancy colors.  If your key word isn't found, you would call your failure word.

 

The second way would be to strip the page away completely and only leave what it prints on it's own.

 

Either way, once you do the regex script, you'll need to call it with an include whereever you want it.

Link to comment
Share on other sites

i'm going to take a stab at your page not being .php extension, but rather .htm(l).  the page extension isn't telling your server to process anything, just display html code.  you have two options: 1) change the page extension to .php or 2) modify your .htaccess file and add this or these lines to it:

AddType application/x-httpd-php .html 
AddType application/x-httpd-php .htm

 

If the site is new and doesn't have a lot of links to it already, just use php.  Else, modify your htaccess file.

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.