试试看这个判断ICQ是否在线的代码好用吗?
类别: PHP教程
<?
function get_status($uin)
{
$fp = fsockopen ("wwp.icq.com", 80, &$errno, &$errstr, 30);
if(!$fp)
{
echo "$errstr ($errno)<br>/n";
}
else
{
fputs($fp, "GET /scripts/online.dll?icq=$uin&img=5 HTTP/1.0/n/n");
$do = 'yes';
while(!feof($fp))
{
$line = fgets ($fp,128);
$do = ($do == 'yes')?'yes':(eregi("^GIF89", $line))?'yes':'no';
//echo $line;
if($do == 'yes')
{
if(ereg("@", $line))
{
return 'online';
}
elseif(ereg("狩", $line))
{
return 'offline';
}
elseif(ereg("S", $line))
{
return 'disabled';
}
}
}
fclose($fp);
}
return 'unknown!';
}
$uin="72485936"; // sonymusic 的ICQ,呵呵。
echo get_status($uin);
// offline
// HTTP/1.0 200 OK Content-type: image/gif GIF89a(?杂tR??螗#%狩` ?0? 祠??Wb?螭?缒unknown
// online
// HTTP/1.0 200 OK Content-type: image/gif GIF89a(?杂tR ??螗#%?@ ?0?U祠??WB?螭???unknown
?>
function get_status($uin)
{
$fp = fsockopen ("wwp.icq.com", 80, &$errno, &$errstr, 30);
if(!$fp)
{
echo "$errstr ($errno)<br>/n";
}
else
{
fputs($fp, "GET /scripts/online.dll?icq=$uin&img=5 HTTP/1.0/n/n");
$do = 'yes';
while(!feof($fp))
{
$line = fgets ($fp,128);
$do = ($do == 'yes')?'yes':(eregi("^GIF89", $line))?'yes':'no';
//echo $line;
if($do == 'yes')
{
if(ereg("@", $line))
{
return 'online';
}
elseif(ereg("狩", $line))
{
return 'offline';
}
elseif(ereg("S", $line))
{
return 'disabled';
}
}
}
fclose($fp);
}
return 'unknown!';
}
$uin="72485936"; // sonymusic 的ICQ,呵呵。
echo get_status($uin);
// offline
// HTTP/1.0 200 OK Content-type: image/gif GIF89a(?杂tR??螗#%狩` ?0? 祠??Wb?螭?缒unknown
// online
// HTTP/1.0 200 OK Content-type: image/gif GIF89a(?杂tR ??螗#%?@ ?0?U祠??WB?螭???unknown
?>
- 上一篇: 在WAP站点用GD(1.8版以上)生成WBMP
- 下一篇: 如何恢复MYSQL的ROOT口令
-= 资 源 教 程 =-
文 章 搜 索