Thread: Server Status PHP Code

Results 1 to 2 of 2
  1. #1 Server Status PHP Code 
    Banned

    Join Date
    Oct 2009
    Age
    28
    Posts
    1,579
    Thanks given
    4
    Thanks received
    23
    Rep Power
    0
    I need a good server status code that I can use for my server. I want it to say 'Online' if it's online and 'Offline' if its offline. No images needed. I want to put this on my forums home page or on my shoutbox (vBulletin). Will rep for any help, thanks .
    Reply With Quote  
     

  2. #2  
    Registered Member [Mash]'s Avatar
    Join Date
    Jul 2010
    Posts
    40
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    I'm not sure if this might help, but I just Googled something and found this:
    Code:
    <?php
    /*
        Server Status Script
        Created by: Lee Findlow
        Contact:     [email protected]
        Website:     http://conceptsublime.com
    */
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Server Status Script</title>
    </head>
    
    <body>
    <?php
    //Page Variables
        $online='<td style="background-color:#00FF00; padding:5px;">Online</td>';
        $offline='<td style="background-color:#FF0000; padding:5px;">Offline</td>';
    //Functions
        function servercheck($server,$port){
            //Check that the port value is not empty
            if(empty($port)){
                $port=80;
            }
            //Check that the server value is not empty
            if(empty($server)){
                $server='localhost';
            }
            //Connection
            $fp=@fsockopen($server, $port, $errno, $errstr, 1);
                //Check if connection is present
                if($fp){
                    //Return Alive
                    return 1;
                } else{
                    //Return Dead
                    return 0;
                }
            //Close Connection
            fclose($fp);
        }
    //Ports and Services to check
    $services=array(
        'HTTP (Port 80)' => array('localhost' => 80),
        'HTTPS (Port 443)' => array('localhost' => 443),
        'FTP (Port 21)' => array('localhost' => 21),
        'MySQL (Port 3306)' => array('localhost' => 3306),
        'SMTP (Port 25)' => array('localhost' =>  25),
        'POP3 (Port 110)' => array('localhost' =>  110),
        'Internet Connection' => array('google.com' => 80)
    );
    ?>
    <table>
    <?php
    //Check All Services
    foreach($services as $name => $server){
    ?>
        <tr>
        <td><?php echo $name; ?></td>
    <?php
        foreach($server as $host => $port){
            if(servercheck($host,$port)){ echo $online; }else{ echo $offline; }
        }
    ?>
        </tr>
    <?php
    }
    ?>
    </table>
    </body>
    </html>
    Live Demo:
    PHP Server Status
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •