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
https://forums.phpfreaks.com/topic/230286-server-status-check/
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
https://forums.phpfreaks.com/topic/230286-server-status-check/#findComment-1185922
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
https://forums.phpfreaks.com/topic/230286-server-status-check/#findComment-1186001
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.