예제 #1
0
$j->server = $conf['Messaging']['jabber_server'];
$j->port = $conf['Messaging']['jabber_port'];
$j->username = $conf['Messaging']['jabber_username'];
$j->password = $conf['Messaging']['jabber_password'];
$j->enable_logging = true;
if (!$j->Connect()) {
    echo $j->log_array[count($j->log_array) - 1] . NEWLINE;
    return;
}
if (!$j->SendAuth()) {
    echo $j->log_array[count($j->log_array) - 1] . NEWLINE;
    return;
}
$j->SendPresence('available');
sleep(2);
$j->Listen();
foreach ($j->packet_queue as $message) {
    set_time_limit(30);
    if (!array($message) || key($message) != 'message') {
        continue;
    }
    $thread = $j->GetInfoFromMessageThread($message);
    if (!$thread) {
        continue;
    }
    // now figure out:
    // - type of message (M, T, or C), for now handle only M
    switch (substr($thread, 0, 1)) {
        case 'M':
            $msg_id = str_replace('M', '', $thread);
            break;