我来个简单点儿的Server Checker....
:
<?php
class getip
{
var $hosts = array(
'PayCenter' => 'www.paycenter.com.cn:80',
'DNS1 IP' => 'ns.xinnetdns.com:53|udp',
'DNS2 IP' => 'ns.xinnet.cn:53|udp',
'Oray IP' => 'www.oray.net:80',
'Sina IP' => 'www.sina.com.cn:80',
'SOHU IP' => 'www.sohu.com:80',
);
var $r = array();
function getip()
{
foreach($this->hosts as $k => $v)
{
$v=explode(":",$v);
$ipp = gethostbyname($v[0]);
$err = $this->sockcheck($ipp,$v[1]);
$this->r[] = "{$k}:".$ipp.$err."
";
}
}
function sockcheck($ipp,$type)
{
$type=explode("|",$type);
if($type[1]!='udp')
{
$fp = @fsockopen($ipp, $type[0], $errno, $errstr, 1);
}
else
{
$fp = @fsockopen("udp://".$ipp, $type[0], $errno, $errstr, 1);
}
if (!$fp) {
return " Err($errno)";
} else {
fclose($fp);
return " Pass!";
}
}
function output($remote)
{
foreach($this->r as $v)
{
echo $v;
}
echo "Custem IP:".$remote;
}
}
$ip = new getip();
$ip->output($REMOTE_ADDR);
?>