Die folgende Funktion zeigt an ob eine ICQ Benutzer online/offline ist.
Testen kann man dies mit: <? echo is_online("123456789"); ?>
function is_online($uin) {
if (!is_numeric($uin)) return FALSE;
$fp = fsockopen('status.icq.com', 80, &$errno, &$errstr, 8);
if (!$fp) return FALSE;
$request = "GET /online.gif?icq=".$uin."&img=5 HTTP/1.0rn"
."Host: status.icq.comrn"
."Connection: closernrn";
fputs($fp, $request);
do {
$response = fgets($fp, 1024);
# echo $response,'<br />';
} while (!feof($fp) && !stristr($response, 'Location'));
fclose($fp);
if (strstr($response, 'online1.gif')) return 'online';
if (strstr($response, 'online0.gif')) return 'offline';
if (strstr($response, 'online2.gif')) return 'disabled';
return FALSE;
} |