View Single Post
Old 7th March 2006, 18:08   #49
darik
Junior Member
 
Join Date: Mar 2006
Location: AL
Posts: 5
Hey guys. I been readin this form and I I really dont know to use this script.
<?php
// This is the function....
function sc_status($server, $port, $file) {
$cont = "";
$ip = gethostbyname($server);
// 3 is the timeout in seconds
$fp = fsockopen($ip, $port, $errno, $errstr, 3);
if (!$fp)
{
return "<img src='http://img.photobucket.com/albums/v209/djjonni/off.png' alt='Server is DOWN'>";
}
else
{
$com = "GET $file HTTP/1.1\r\nAccept: */*\r\nAccept-Language: de-ch\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\nHost: $server:$port\r\nConnection: Keep-Alive\r\n\r\n";
fputs($fp, $com);
while (!feof($fp))
{
$cont .= fread($fp, 500);
}
fclose($fp);
$cont = substr($cont, strpos($cont, "\r\n\r\n") + 4);
//return $cont;
}
$parts = explode(',', $cont);
$status = $parts['1'];
if ($status == '0') {
return "<img src='http://img.photobucket.com/albums/v209/djjonni/off.png' alt='Server is DOWN'>";
} else {
return "<img src='http://img.photobucket.com/albums/v209/djjonni/air.gif' alt='Server is UP'>";
}

}

// This is what you would call...
echo sc_status('213.48.102.230', '9234', '/7.html');
?>

What do I do to make this script work? Do I need to do this in linux or just delete the html code and put the script in there and name it .php or some other exstention? Let me know guys! You seem very inteligent in this field. Thanks Darik
darik is offline   Reply With Quote