src/Identd/Worker.php
protected function handleMessage($line)
    {
        if (!is_string($line)) {
            return false;
        }

        $parts = array_map('trim', explode(',', $line));
        if (count($parts) != 2) {
            return false;
        }

        $line = implode(" , ", $parts);
        if (!ctype_digit($parts[0]) || !ctype_digit($parts[1])) {
            return $line . " : ERROR : INVALID-PORT";
        }

        $cport = (int) $parts[0];
        $sport = (int) $parts[1];

        if ($sport <= 0 || $sport > 65535 || $cport <= 0 || $cport > 65535) {
            return $line . " : ERROR : INVALID-PORT";
        }

        foreach ($this->bot->getConnections() as $connection) {
            if ($connection == $this) {
                continue;
            }

            $socket = $connection->getSocket();

            $rport = (int) substr(strrchr(stream_socket_get_name($socket, true), ':'), 1);
            if ($rport != $sport) {
                continue;
            }

            $lport = (int) substr(strrchr(stream_socket_get_name($socket, false), ':'), 1);
            if ($lport != $cport) {
                continue;
            }

            try {
                $config     = $connection->getConfig(null);
                $identity   = $config->parseString(
                    '\\Erebot\\Module\\IrcConnector',
                    'identity',
                    ''
                );
                return $line . " : USERID : UNIX : " . $identity;
            } catch (\Erebot\Exception $e) {
                return $line . " : ERROR : HIDDEN-USER ";
            }
        }

        return $line . " : ERROR : NO-USER";
    }
protected function handleMessage($line)
    {
        if (!is_string($line)) {
            return false;
        }

        $parts = array_map('trim', explode(',', $line));
        if (count($parts) != 2) {
            return false;
        }

        $line = implode(" , ", $parts);
        if (!ctype_digit($parts[0]) || !ctype_digit($parts[1])) {
            return $line . " : ERROR : INVALID-PORT";
        }

        $cport = (int) $parts[0];
        $sport = (int) $parts[1];

        if ($sport <= 0 || $sport > 65535 || $cport <= 0 || $cport > 65535) {
            return $line . " : ERROR : INVALID-PORT";
        }

        foreach ($this->bot->getConnections() as $connection) {
            if ($connection == $this) {
                continue;
            }

            $socket = $connection->getSocket();

            $rport = (int) substr(strrchr(stream_socket_get_name($socket, true), ':'), 1);
            if ($rport != $sport) {
                continue;
            }

            $lport = (int) substr(strrchr(stream_socket_get_name($socket, false), ':'), 1);
            if ($lport != $cport) {
                continue;
            }

            try {
                $config     = $connection->getConfig(null);
                $identity   = $config->parseString(
                    '\\Erebot\\Module\\IrcConnector',
                    'identity',
                    ''
                );
                return $line . " : USERID : UNIX : " . $identity;
            } catch (\Erebot\Exception $e) {
                return $line . " : ERROR : HIDDEN-USER ";
            }
        }

        return $line . " : ERROR : NO-USER";
    }
protected function handleMessage ( $ line ) { if ( ! is_string ( $ line ) ) { return false ; } $ parts = array_map ( 'trim' , explode ( ',' , $ line ) ) ; if ( count ( $ parts ) != 2 ) { return false ; } $ line = implode ( " , " , $ parts ) ; if ( ! ctype_digit ( $ parts [ 0 ] ) || ! ctype_digit ( $ parts [ 1 ] ) ) { return $ line . " : ERROR : INVALID-PORT" ; } $ cport = ( int ) $ parts [ 0 ] ; $ sport = ( int ) $ parts [ 1 ] ; if ( $ sport <= 0 || $ sport > 65535 || $ cport <= 0 || $ cport > 65535 ) { return $ line . " : ERROR : INVALID-PORT" ; } foreach ( $ this -> bot -> getConnections ( ) as $ connection ) { if ( $ connection == $ this ) { continue ; } $ socket = $ connection -> getSocket ( ) ; $ rport = ( int ) substr ( strrchr ( stream_socket_get_name ( $ socket , true ) , ':' ) , 1 ) ; if ( $ rport != $ sport ) { continue ; } $ lport = ( int ) substr ( strrchr ( stream_socket_get_name ( $ socket , false ) , ':' ) , 1 ) ; if ( $ lport != $ cport ) { continue ; } try { $ config = $ connection -> getConfig ( null ) ; $ identity = $ config -> parseString ( '\\Erebot\\Module\\IrcConnector' , 'identity' , '' ) ; return $ line . " : USERID : UNIX : " . $ identity ; } catch ( \ Erebot \ Exception $ e ) { return $ line . " : ERROR : HIDDEN-USER " ; } } return $ line . " : ERROR : NO-USER" ; }
Handles an IdentD request.

\param string $line
IdentD request to handle.

\retval string
Message to send as the response
to this request.

\retval false
The request was malformed.
Handles an IdentD request .