jhm – Mon, 2005 – 02 – 14 11:13

I created a small class that allows to determine the online status of any AOL account (as long as its privacy settings allow)

<?php
class AIM {
        var
$online = false;
        function
__construct($screenname){
            if(!empty(
$screenname)) $this-&gt;online = $this-&gt;check($screenname);
        }
        function
check($screenname){
           
$aol = &quot;big.oscar.aol.com&quot;;
           
$sock = fsockopen($aol, 80, $errno, $errstr, 10);
            if (!
$sock) die(&quot;$errstr ($errno)\n&quot;);
           
socket_set_blocking($sock, 1);
           
fputs($sock,
                &
quot;GET /$screenname?on_url=yes&amp;off_url=offline HTTP/1.1\r\n&quot; .
                &
quot;Host: $aol\r\n\r\n&quot;
            );
           
$online = array();
            while( !
feof($sock) ){
               
$result = rtrim(fgets($sock, 2048));
                if(empty(
$result) or eregi(&quot;^HTTP&quot;,$result)) continue;
               
$online[]=$result;
            }
           
fclose($sock);

            if(
eregi(&quot;yes&quot;,implode(&quot; &quot;,$online))) {
                return
true;
            } else {
                return
false;
            }
        }
    }
?>