View Single Post
Old 01-16-2007, 12:15 PM   · #8
lee101
NamePros Regular
 
Name: Lee
Location: United Kingdom
Trader Rating: (8)
Join Date: Mar 2006
Posts: 344
NP$: 2.90 (Donate)
lee101 is a jewel in the roughlee101 is a jewel in the roughlee101 is a jewel in the rough
Updated Version

Hi,
Here's a slightly updated version of the script I posted before, I've made it more customisable so that you can format the output however you want.
PHP Code:
<?php
/*
    Server Status Script
    Created by: Lee Findlow
    Contact:     leefindlow@gmail.com
    Website:     http://conceptsublime.com
*/

//Standard 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)
    );

//Functions
    
function ServerCheck($server = 'localhost', $port = '80'){
        
//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);
    }

//Function to check all services in the $services array
    
function CheckAll(){
        
//Check All Services
        
global $services;
        foreach(
$services as $name => $server){
            foreach(
$server as $host => $port){
                
$status[$name] = ServerCheck($host,$port);
            }
        }
        return
$status;
    }
    
?>

This returns the services as an array, when you use the function CheckAll().
An example usage is
PHP Code:
<?php
include('file.php');
foreach(
CheckAll() as $service => $stat){
echo
$service.' - '.$stat.'<br />';
}

It returns 1/true if the service is online, and 0/false if it isn't

Thanks,
Lee


Please register or log-in into NamePros to hide ads
__________________
http://bypasstopsite.com - Submit your proxy!
http://biggertwitter.com - Make twitter a bit bigger!
Currently Developing - Linux Screenshots
lee101 is offline   Reply With Quote
Site Sponsors
Traffic Down Under Hunting Moon Buy Flash Arcade Game Script
Advertise your business at NamePros
All times are GMT -7. The time now is 04:19 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.