...

View Full Version : fsockopen - Status



Jake:)
10-21-2009, 05:31 PM
Hello,

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 :(


<?php
$ip = "youriphere";
$port = "yourporthere";
$start = microtime(true);
if (!$sock = @fsockopen($ip, $port, $num, $error, 5))
echo '<B><FONT COLOR=red>Offline</b></FONT>';
else{
$howlong = microtime(true) - $start;
echo '<B><FONT COLOR=lime>Online</b></FONT> time: ' . $howlong . ' seconds';
fclose($sock);
}
?>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 :)

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




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

Jake:)
10-21-2009, 08: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