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(); }
$j = new Jabber(); $j->resource = 'Sitellite CMS ' . SITELLITE_VERSION; $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':