public function testAuthException()
 {
     try {
         $xmpp = new XMPPHP_XMPP('jabber.wentz.it', 5222, 'invalidusername', 'invalidpassword', 'xmpphp', 'jabber.wentz.it', true, XMPPHP_Log::LEVEL_VERBOSE);
         $xmpp->useEncryption(false);
         $xmpp->connect(10);
         $xmpp->processUntil('session_start');
         $xmpp->presence();
         $xmpp->message('*****@*****.**', 'This is a test message!');
         $xmpp->disconnect();
     } catch (XMPPHP_Exception $e) {
         return;
     } catch (Exception $e) {
         $this->fail('Unexpected Exception thrown: ' . $e->getMessage());
     }
     $this->fail('Expected XMPPHP_Exception not thrown!');
 }
Exemple #2
0
function snapRegisterNewXmppUser($emailaddress)
{
    global $APPCONFIG;
    include_once '../extensions/XMPPHP/XMPPHP_XMPP.php';
    $conf = $APPCONFIG['XMPP'];
    $passwd = $conf['userpasswd'];
    $userJID = cleanString($emailaddress) . time() . '@' . $conf['server'];
    $conn = new XMPPHP_XMPP($conf['server'], $conf['port'], $conf['adminuser'], $conf['adminpasswd'], $conf['resource'], $conf['domain']);
    $conn->autoSubscribe(true);
    $conn->useEncryption(false);
    $resp = array();
    try {
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->registerNewUser($userJID, $emailaddress, $passwd);
        $conn->processUntil('done');
        $conn->disconnect();
        return array('xmppuserid' => $userJID, 'xmpppasswd' => $passwd);
    } catch (XMPPHP_Exception $e) {
        return 0;
        //die($e->getMessage());
    }
}
Exemple #3
0
if ($at->message !== '' && isset($at->jabberServer) && isset($at->jabberLogin) && isset($at->jabberPasswd) && isset($at->jabberFor)) {
    $useEncryption = true;
    $jabberHost = $at->jabberServer;
    $jabberPort = 5222;
    if ($at->advancedSettings) {
        $useEncryption = $at->useEncryption;
        if ($at->jabberHost) {
            $jabberHost = $at->jabberHost;
        }
        if ($at->jabberPort) {
            $jabberPort = $at->jabberPort;
        }
    }
    $conn = new XMPPHP_XMPP($jabberHost, $jabberPort ? $jabberPort : 5222, $at->jabberLogin, $at->jabberPasswd, 'xmpphp', $at->jabberServer);
    if ($useEncryption) {
        $conn->useEncryption(true);
        $opts = array('ssl' => array('verify_peer' => true, 'allow_self_signed' => true));
        if ($at->jabberHost != $at->jabberServer) {
            $opts['ssl']['CN_match'] = $at->jabberServer;
        }
        $conn->set_context($opts);
    } else {
        $conn->useEncryption(false);
    }
    try {
        $message = str_replace("{TORRENT}", $name, $at->message);
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->presence();
        $conn->message($at->jabberFor, $message);
        $conn->disconnect();
Exemple #4
0
/**
 * connect the configured Jabber account to the configured server
 *
 * @param string $resource Resource to connect (defaults to configured resource)
 *
 * @return XMPPHP connection to the configured server
 */
function jabber_connect($resource = null)
{
    static $conn = null;
    if (!$conn) {
        $conn = new XMPPHP_XMPP(common_config('xmpp', 'host') ? common_config('xmpp', 'host') : common_config('xmpp', 'server'), common_config('xmpp', 'port'), common_config('xmpp', 'user'), common_config('xmpp', 'password'), $resource ? $resource : common_config('xmpp', 'resource'), common_config('xmpp', 'server'), common_config('xmpp', 'debug') ? true : false, common_config('xmpp', 'debug') ? XMPPHP_Log::LEVEL_VERBOSE : null);
        if (!$conn) {
            return false;
        }
        $conn->autoSubscribe();
        $conn->useEncryption(common_config('xmpp', 'encryption'));
        try {
            $conn->connect(true);
            // true = persistent connection
        } catch (XMPPHP_Exception $e) {
            common_log(LOG_ERR, $e->getMessage());
            return false;
        }
        $conn->processUntil('session_start');
    }
    return $conn;
}
<?php

require_once "../libs/require_once.php";
#Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports
#If this doesn't work, are you running 64-bit PHP with < 5.2.6?
if ($XMPP_ENABLE) {
    $conn = new XMPPHP_XMPP($XMPP_SERVER, $XMPP_PORT, $XMPP_USER, $XMPP_PASSWORD, 'xmpphp', $XMPP_DOMAIN, $printlog = false, $loglevel = XMPPHP_Log::LEVEL_INFO);
    try {
        if (!$XMPP_ENCRYPTION) {
            $conn->useEncryption(false);
        }
        $conn->connect();
        $conn->processUntil('session_start');
        $conn->presence();
        $message = $_POST['message'];
        if ($XMPP_MESSAGE_SIGN_ENABLE) {
            $UserInfo = $ldap->getArray($_COOKIE['dn'], false, array($DISPLAY_NAME_FIELD, $LDAP_TITLE_FIELD, $LDAP_CELL_PHONE_FIELD, $LDAP_INTERNAL_PHONE_FIELD), false, false, true);
            $Sign = "\n\n" . $L->l("start_of_xmpp_sign");
            $Sign .= "\n" . $UserInfo[$DISPLAY_NAME_FIELD][0] . " (" . $UserInfo[$LDAP_TITLE_FIELD][0] . ")";
            if ($XMPP_USE_INTERNAL_PHONE_IN_SIGN_ENABLE) {
                $Sign .= "\n" . $L->l("intrenal_phone") . ": " . $UserInfo[$LDAP_INTERNAL_PHONE_FIELD][0] . "";
            }
            if ($XMPP_USE_MOBILE_PHONE_IN_SIGN_ENABLE) {
                $Sign .= "\n" . $L->l("cell_phone") . ": " . $UserInfo[$LDAP_CELL_PHONE_FIELD][0] . "";
            }
            $message .= $Sign;
        }
        if (is_array($_POST['resipients'])) {
            foreach ($_POST['resipients'] as $key => $value) {
                $conn->message(current(explode("@", $value)) . "@" . $XMPP_ACCOUNT_END, $message);
            }