BatDev
Active Member
- Apr 20, 2012
- 110
- 25
You can use this to see if a port is online / offline on an IP / Domain
PHP:
<?php
class StatusTest {
function GetStatus($ip, $port) {
$status = array("<font color='red'>OFFLINE</font>", "<font color='green'>ONLINE</font>");
$fp = @fsockopen($ip, $port, $errno, $errstr, 2);
if (!$fp) {
return $status[0];
} else {
return $status[1];
}
}
}
// How to use the class & function
//Variable->Function('IP','PORT');
$Status = new StatusTest(); // Declares the class we are using into a variable
$Status->GetStatus('127.0.0.1','80'); // Calls the function we are using will either display online or offline
?>