sam240 Posted March 11, 2011 Share Posted March 11, 2011 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 More sharing options...
Mahngiel Posted March 11, 2011 Share Posted March 11, 2011 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 More sharing options...
sam240 Posted March 11, 2011 Author Share Posted March 11, 2011 http://hostious.com/sstatus.php?ip=hostious.com&port=80 This is the actual link here. I'm don't know much php to be able to do that. So I'm guess its not a quick thing Link to comment https://forums.phpfreaks.com/topic/230286-server-status-check/#findComment-1185930 Share on other sites More sharing options...
Mahngiel Posted March 11, 2011 Share Posted March 11, 2011 that's much simpler than what I had seen the first time - a page with a bunch of shit on it. you can just <?php include('yourlink');?> wherever you want it. Link to comment https://forums.phpfreaks.com/topic/230286-server-status-check/#findComment-1185936 Share on other sites More sharing options...
sam240 Posted March 11, 2011 Author Share Posted March 11, 2011 I placed it under Body of .html file it didn't show anything. Link to comment https://forums.phpfreaks.com/topic/230286-server-status-check/#findComment-1185962 Share on other sites More sharing options...
Mahngiel Posted March 11, 2011 Share Posted March 11, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.