Server Status Checker

07/16/2013 13:27 AndreiStanilaAK#1
Hi ePvP, i need a status checker for a darkorbit server, i need something like in this thread:
[Only registered and activated users can see links. Click Here To Register...]
Please, if you could help me, thanks.
07/16/2013 18:30 Brendan Jordan#2
google "server status checker"
07/17/2013 08:23 AndreiStanilaAK#3
Quote:
Originally Posted by M3BF05B View Post
google "server status checker"
Thanks for nothing, i already searched and for something but don't work.
07/20/2013 07:35 PizzaGuy#4
Quote:
Originally Posted by AndreiStanilaAK View Post
Thanks for nothing, i already searched and for something but don't work.
Took 30 seconds to write up an example, knock yourself out.

Code:
<?php

$fp = fsockopen("127.0.0.1", 80, $errno, $errstr, 3);
if (!$fp) {
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-offline-icon.png'>";
} else {
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-online-icon.png'>";
}

?>
Replace 127.0.0.1 with the servers IP, and 80 with the port of the server to check for.
07/20/2013 10:31 AndreiStanilaAK#5
Quote:
Originally Posted by PizzaGuy View Post
Took 30 seconds to write up an example, knock yourself out.

Code:
<?php

$fp = fsockopen("127.0.0.1", 80, $errno, $errstr, 3);
if (!$fp) {
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-offline-icon.png'>";
} else {
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-online-icon.png'>";
}

?>
Replace 127.0.0.1 with the servers IP, and 80 with the port of the server to check for.
It's possible to make that check more than 1 port? i mean, for 80, 443 and 3306?
And ... Thanks for help.
07/20/2013 17:29 GodHacker#6
Quote:
Originally Posted by AndreiStanilaAK View Post
It's possible to make that check more than 1 port? i mean, for 80, 443 and 3306?
And ... Thanks for help.
Code:
<?php

$fp = fsockopen("127.0.0.1", 80, $errno, $errstr, 3);
if (!$fp) {
  echo "127.0.0.1:80"
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-offline-icon.png'>";
} else {
  echo "127.0.0.1:80"
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-online-icon.png'>";
}

$fp = fsockopen("127.0.0.1", 443, $errno, $errstr, 3);
if (!$fp) {
  echo "127.0.0.1:443"
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-offline-icon.png'>";
} else {
  echo "127.0.0.1:443"
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-online-icon.png'>";
}

$fp = fsockopen("127.0.0.1", 3306, $errno, $errstr, 3);
if (!$fp) {
  echo "127.0.0.1:3306"
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-offline-icon.png'>";
} else {
  echo "127.0.0.1:3306"
  echo "<img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/32/status-online-icon.png'>";
}
?>
I think thatīs ok... but i didnīt know it because i canīt PHP (i have start to learn it for ~3 weeks)
07/20/2013 17:30 MrSm!th#7
#moved
07/20/2013 19:52 マルコ#8
No, It's not ok. Why would there be functions in PHP if you do not use them?
Also you do not close the connections in case they opened successfully.

PHP Code:
/**
 * Ping IP @ Port
 * 
 * @param string $ip The IP of the computer you want to ping
 * @param integer $port The port that should be pinged
 * 
 * @return boolean
 */
function ping($ip$port 22)
{
    
$serror 0;
    
$serrorstr 0;
    
$ps = @fsockopen($ip$port$serror$serrorstr1);
    if(!
$ps)
    {
        return 
false;
    }
    else
    {
        
fclose($ps);
        return 
true;
    }

BTW, it's not good to open the database port to the world. You should better close that port and only connect to it locally on the remote machine.
07/21/2013 10:18 AndreiStanilaAK#9
Quote:
Originally Posted by マルコ View Post
No, It's not ok. Why would there be functions in PHP if you do not use them?
Also you do not close the connections in case they opened successfully.

PHP Code:
/**
 * Ping IP @ Port
 * 
 * @param string $ip The IP of the computer you want to ping
 * @param integer $port The port that should be pinged
 * 
 * @return boolean
 */
function ping($ip$port 22)
{
    
$serror 0;
    
$serrorstr 0;
    
$ps = @fsockopen($ip$port$serror$serrorstr1);
    if(!
$ps)
    {
        return 
false;
    }
    else
    {
        
fclose($ps);
        return 
true;
    }

BTW, it's not good to open the database port to the world. You should better close that port and only connect to it locally on the remote machine.
There should be "$ip = "127.0.0.1" and $port = "443" " for example?
07/21/2013 11:19 Thr!ce#10
Quote:
Originally Posted by AndreiStanilaAK View Post
There should be "$ip = "127.0.0.1" and $port = "443" " for example?

PHP Code:
if (ping("127.0.0.1"443))
    echo 
"Yay";
else echo 
"Nay"
?
07/22/2013 09:54 AndreiStanilaAK#11
Quote:
Originally Posted by Thr!ce View Post
PHP Code:
if (ping("127.0.0.1"443))
    echo 
"Yay";
else echo 
"Nay"
?
Thanks for help.
#CloseRequest
07/22/2013 20:45 xxfabbelxx#12
closed as requested