FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Server Status





jarred89
Hello, I am putting a ftp server on my site where members can upload there pics but i wont have the server on all the time i was wondering if there was a simple script like so if the server is up a green dot will be there but if the server was down there would be a red dot. Thanks
DX-Blog
Code:
<?php
//Server domain/ip:port
    $server='google.com:80';
//Split up port and ip
    $split=explode(':',$server);
    $ip=$split[0];
    $port=(empty($split[1]))?'80':$split[1];//If no port use 80
    $server=$ip.':'.$port;
//Try to connect to the server, 1 time
$fp = @fsockopen($ip, $port, $errno, $errstr, 1);
if($fp){//worked, server online             
    echo $server.' is online';
    fclose($fp);
}
else{//Failed, server offline
    echo $server.' is offline';
}
?>
jarred89
so what do i edit to make it to my server?
DX-Blog
Razz, ok to start you will have to edit the $server variable.

Atm it checks the google.com webserver, but you will have to change that to your ftp server. Seeing as to how the standard port for ftp is 21 you would in example get:
$server = your_ip_here:21

If you are using a different port, then just change the number to that.

Now there are 2 more things for you to edit and that's where now is written:
echo $server.' is online';

and where is written:
echo $server.' is offline';

Just change them to what you desire to be displayed. If it would be an image file as you suggested change it to something like:

first (server online status):
echo "<img src=\"online.jpg\" />";

second (server offline status):
echo "<img src=\"offline.jpg\" />";


Or wherever you would place your images or how you would name them. Basically open for you to customize in whatever way you would like and would feel it would suit your site.
jarred89
thanks for help! Laughing
Related topics
Server Status
Checking Server Status, Ping a Server (lots of purposes)
Home Server Status Indicator
[RESOLVED] Server Load
Server Status.
Server status script
Frihost server status checker
Checking server status (ports) using PHP
Current server status
New Server Status page
How about adding server load to the server status script?
Server Status & Server 3
Server Status Page? Coming back anytime soon?
Is there new Server Status Gif
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.