Miscellaneous
|
|
|
|
<?php
/*
ICQ status checker function - returns 0 when $uin is offline, 1 when online and 2 when
the status indicator is deactivated, 3 on error
by Stefan Dengscherz, 2003 -- http://lock.at -- sd@lock.at
*/
function icqstatus($uin)
{
// establish a connection to the icq status server
$fp = fsockopen("status.icq.com",80,&$errno,&$errstr,8);
// error, can't connect to icq status server
if (!$fp) return 3;
// http request - online.gif
$request = "HEAD /online.gif?icq=".$uin."&img=5 HTTP/1.0rn"
."Host: wwp.icq.comrn"
."Connection: closernrn";
// send request
fputs($fp, $request);
// parse sent data
do
{
$response = fgets($fp,1024);
}
while (!feof($fp) && !stristr($response,"Location"));
// close connection
fclose($fp);
// return status depending on sent redirection string
// online
if (strstr($response,"online1")) return 1;
// offline
elseif (strstr($response,"online0")) return 0;
// deactivated
elseif (strstr($response,"online2")) return 2;
// error
else return 3;
}
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|