View Full Version : fsockopen - Status

10-21-2009, 04:31 PM

At the moment, I have pulled together a simple PHP Script which tells the person viewing the page HOW LONG the page takes to load etc, I have gone brain dead now :(

$ip = "youriphere";
$port = "yourporthere";
$start = microtime(true);
if (!$sock = @fsockopen($ip, $port, $num, $error, 5))
echo '<B><FONT COLOR=red>Offline</b></FONT>';
$howlong = microtime(true) - $start;
echo '<B><FONT COLOR=lime>Online</b></FONT> time: ' . $howlong . ' seconds';
?>I want it to look like this page http://www.spamsite.co.uk/status.php

So, after x seconds the page would state it as SLOW
after y seconds the page would state it as DOWN
after z seconds the page would state it as ACTIVE

Help is appreciated :)

10-21-2009, 06:04 PM
Maybe something like...

if($howlong > 60) {
$message = "Site Down";
elseif($howlong > 30) {
$message = "Slow";
else {
$message = "Active";
print $message

10-21-2009, 07:17 PM
Could you add that to the original code, that way I can't go wrong :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum