私はいくつかの関数を追加しました:
<?php
function port($Host, $Port = '')
{
if (strstr($Host, ':'))
{
if (strstr($Host, '/'))
{
$Output = substr($Host, strpos($Host, ':') +1, (strpos($Host, '/') -1) - strpos($Host, ':'));
}
else
{
$Output = substr($Host, strpos($Host, ':') +1);
}
}
if ((isset($Output)) and ($Output != ''))
{
return $Output;
}
else
{
if ($Port != '')
{
return $Port;
}
}
}
function server($Host)
{
if (strpos($Host, '//'))
{
$Host = substr($Host, strpos($Host, '//') +2);
}
if(strstr($Host,"/"))
{
$Host = substr($Host, 0, strpos($Host, "/"));
}
if(strstr($Host,":"))
{
$Host = substr($Host, 0, strpos($Host, ":"));
}
return $Host;
}
$Host = $_GET['ip'];
$Host = server($Host);
$churl = @fsockopen($Host, 80, $errno, $errstr, 10);
if (!$churl) {
echo("<div><b>Offline</b></div>");
}
else
{
echo("<div><b>Online</b></div>");
}
?>