Пример #1
0
function util_send_jabber($to, $subject, $body)
{
    if (!$GLOBALS['sys_use_jabber']) {
        return;
    }
    $JABBER = new Jabber();
    if (!$JABBER->Connect()) {
        echo '<br />Unable to connect';
        return false;
    }
    //$JABBER->SendAuth();
    //$JABBER->AccountRegistration();
    if (!$JABBER->SendAuth()) {
        echo '<br />Auth Failure';
        $JABBER->Disconnect();
        return false;
        //or die("Couldn't authenticate!");
    }
    $JABBER->SendPresence(NULL, NULL, "online");
    $body = htmlspecialchars($body);
    $to_arr = explode(',', $to);
    for ($i = 0; $i < count($to_arr); $i++) {
        if ($to_arr[$i]) {
            //echo '<br />Sending Jabbers To: '.$to_arr[$i];
            if (!$JABBER->SendMessage($to_arr[$i], "normal", NULL, array("body" => $body, "subject" => $subject))) {
                echo '<br />Error Sending to ' . $to_arr[$i];
            }
        }
    }
    $JABBER->CruiseControl(2);
    $JABBER->Disconnect();
}