Online/Offline

sk1tL1L

New Member
Messages
59
Reaction score
0
Points
0
hey Guys,
i've got my own admin panel for my site. And i was wondering if theres a script i can get if services are offline/online.
Eg.
HTTP: Online!
FTP: Offline

It will be great if you have one of these.

Cheers
 

sk1tL1L

New Member
Messages
59
Reaction score
0
Points
0
Re: Online/OfflineH

but is there a script? Thats what i'm really looking for
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Re: Online/OfflineH

Use this:
PHP:
<?php

function serviceStatus(66.232.109.231, $port) {
   $handle = @fsockopen($ip, $port, $errno, $errstr, 30);
   if (!$handle) {
      $string = 'Down';
   } else {
      $string = 'Online';
      @fclose($handle);
   }
   return $string;
}

echo $string;

?>

Change $port to a port, and change Online and Offline to w/e you want, use HTML code here too;)
 
Last edited:

Fedlerner

Former Adm & Team Manager
Community Support
Messages
12,934
Reaction score
6
Points
38
I changed the $port to the port 80 (HTTP) and i'm getting this error:
Code:
Parse error: syntax error, unexpected T_DNUMBER, expecting '&' or T_VARIABLE in /home/fedlerne/public_html/x10/includes/status.php on line 3
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
You have to use that function like this:
PHP:
<?php
function serviceStatus($ip = "66.232.109.231", $port = 80){
   $handle = @fsockopen($ip, $port, $errno, $errstr, 30);
   if (!$handle) {
      $string = 'Down';
   } else {
      $string = 'Online';
      @fclose($handle);
   }
   return $string;
}

echo serviceStatus();
?>

The $ip and $port vars in the function are the default ones, but you can override them by setting them in function call eg.:
PHP:
echo serviceStatus("123.123.123.123",8080);
 

Fedlerner

Former Adm & Team Manager
Community Support
Messages
12,934
Reaction score
6
Points
38
Thanks Torch!
That worked :)
 

Brandon

Former Senior Account Rep
Community Support
Messages
19,181
Reaction score
28
Points
48
Thatnks Torch, i was busy doing other things posting and forgot it was a function.
 
Top