コード例 #1
0
ファイル: jaxl.0114.php プロジェクト: rahijain/JAXL
 public static function preHandler($xml, $jaxl)
 {
     if ($xml == '<handshake/>') {
         $xml = '';
         JAXLPlugin::execute('jaxl_post_handshake', false, $jaxl);
     }
     return $xml;
 }
コード例 #2
0
ファイル: jaxl.0202.php プロジェクト: ZZB/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns;
     JAXLXml::addTag('iq', 'time', '//iq/time/@xmlns');
     JAXLXml::addTag('iq', 'timeTZO', '//iq/time/tzo');
     JAXLXml::addTag('iq', 'timeUTC', '//iq/time/utc');
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0202', 'handleIq'));
 }
コード例 #3
0
ファイル: jaxl.0092.php プロジェクト: ZZB/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns;
     JAXLXml::addTag('iq', 'softwareName', '//iq/query[@xmlns="' . self::$ns . '"]/name');
     JAXLXml::addTag('iq', 'softwareVersion', '//iq/query[@xmlns="' . self::$ns . '"]/version');
     JAXLXml::addTag('iq', 'softwareOS', '//iq/query[@xmlns="' . self::$ns . '"]/os');
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0092', 'getIq'));
 }
コード例 #4
0
ファイル: jaxl.0184.php プロジェクト: ZZB/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns;
     JAXLXml::addTag('message', 'request', '//message/request/@xmlns');
     JAXLXml::addTag('message', 'received', '//message/received/@xmlns');
     JAXLXml::addTag('message', 'receivedId', '//message/received/@id');
     JAXLPlugin::add('jaxl_get_message', array('JAXL0184', 'handleMessage'));
 }
コード例 #5
0
ファイル: jaxl.0085.php プロジェクト: rahijain/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns;
     JAXLXml::addTag('message', 'composing', '//message/composing/@xmlns');
     JAXLXml::addTag('message', 'active', '//message/active/@xmlns');
     JAXLXml::addTag('message', 'inactive', '//message/inactive/@xmlns');
     JAXLXml::addTag('message', 'paused', '//message/paused/@xmlns');
     JAXLXml::addTag('message', 'gone', '//message/gone/@xmlns');
     JAXLPlugin::add('jaxl_get_message', array('JAXL0085', 'getMessage'));
 }
コード例 #6
0
ファイル: jaxl.0199.php プロジェクト: ZZB/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns;
     $jaxl->pingInterval = 0;
     $jaxl->pingInterval = $jaxl->getConfigByPriority($jaxl->config['pingInterval'], "JAXL_PING_INTERVAL", $jaxl->pingInterval);
     if ($jaxl->pingInterval > 0) {
         JAXLCron::add(array('JAXL0199', 'ping'), $jaxl->pingInterval, $jaxl->domain, $jaxl->jid, array('JAXL0199', 'pinged'));
     }
     JAXLXml::addTag('iq', 'ping', '//iq/ping/@xmlns');
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0199', 'handleIq'));
 }
コード例 #7
0
ファイル: jaxl.0030.php プロジェクト: rahijain/JAXL
 public static function init($jaxl, $config = array())
 {
     $jaxl->features[] = self::$ns['info'];
     $jaxl->features[] = self::$ns['item'];
     self::$category = isset($config['category']) ? $config['category'] : 'client';
     self::$type = isset($config['type']) ? $config['type'] : 'bot';
     self::$name = isset($config['name']) ? $config['name'] : 'Jaxl';
     self::$lang = isset($config['lang']) ? $config['lang'] : 'en';
     // register callbacks
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0030', 'handleIq'));
 }
コード例 #8
0
ファイル: jaxl.0030.php プロジェクト: ZZB/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns['info'];
     $jaxl->features[] = self::$ns['items'];
     JAXLXml::addTag('iq', 'identityCategory', '//iq/query/identity/@category');
     JAXLXml::addTag('iq', 'identityText', '//iq/query/identity/@text');
     JAXLXml::addTag('iq', 'identityName', '//iq/query/identity/@name');
     JAXLXml::addTag('iq', 'identityLang', '//iq/query/identity/@xml:lang');
     JAXLXml::addTag('iq', 'featureVar', '//iq/query/feature/@var');
     // register callbacks
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0030', 'handleIq'));
 }
コード例 #9
0
ファイル: jaxl.class.php プロジェクト: pavl00/Kalkun
 /**
  * Use this method instead of JAXLPlugin::remove to remove a callback for connected instance only
  */
 function executePlugin($hook, $payload)
 {
     return JAXLPlugin::execute($hook, $payload, $this);
 }
コード例 #10
0
ファイル: preFetchXMPP.php プロジェクト: ZZB/JAXL
// Demo requires VCard XEP
$xmpp->requires('JAXL0054');
function postConnect($payload, $xmpp)
{
    $xmpp->startStream();
}
function doAuth($mechanism, $xmpp)
{
    $xmpp->auth('DIGEST-MD5');
}
function postAuth($payload, $xmpp)
{
    $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard');
}
function handleVCard($payload, $xmpp)
{
    echo "<b>Successfully fetched VCard</b><br/>";
    print_r($payload);
    $xmpp->shutdown();
}
function postAuthFailure($payload, $xmpp)
{
    echo "OOPS! Auth failed";
}
// Register callbacks for required events
JAXLPlugin::add('jaxl_post_connect', 'postConnect');
JAXLPlugin::add('jaxl_get_auth_mech', 'doAuth');
JAXLPlugin::add('jaxl_post_auth', 'postAuth');
JAXLPlugin::add('jaxl_post_auth_failure', 'postAuthFailure');
// Fire start JAXL Core
$xmpp->startCore();
コード例 #11
0
ファイル: boshchat.php プロジェクト: ZZB/JAXL
         $response = array('jaxl' => 'pinged');
         $jaxl->JAXL0206('out', $response);
     }
     public static function postAuthFailure($payload, $jaxl)
     {
         $response = array('jaxl' => 'authFailed');
         $jaxl->JAXL0206('out', $response);
     }
 }
 // Add callbacks on various event handlers
 JAXLPlugin::add('jaxl_post_auth_failure', array('boshchat', 'postAuthFailure'));
 JAXLPlugin::add('jaxl_post_auth', array('boshchat', 'postAuth'));
 JAXLPlugin::add('jaxl_post_disconnect', array('boshchat', 'postDisconnect'));
 JAXLPlugin::add('jaxl_get_empty_body', array('boshchat', 'postEmptyBody'));
 JAXLPlugin::add('jaxl_get_message', array('boshchat', 'getMessage'));
 JAXLPlugin::add('jaxl_get_presence', array('boshchat', 'getPresence'));
 // Handle incoming bosh request
 switch ($_REQUEST['jaxl']) {
     case 'connect':
         $jaxl->user = $_POST['user'];
         $jaxl->pass = $_POST['pass'];
         $jaxl->startCore('bosh');
         break;
     case 'disconnect':
         $jaxl->JAXL0206('endStream');
         break;
     case 'getRosterList':
         $jaxl->getRosterList(array('boshchat', 'handleRosterList'));
         break;
     case 'setStatus':
         $jaxl->setStatus(FALSE, FALSE, FALSE, TRUE);
コード例 #12
0
ファイル: jaxl.0199.php プロジェクト: rahijain/JAXL
 public static function init($jaxl)
 {
     $jaxl->features[] = self::$ns;
     JAXLXml::addTag('iq', 'ping', '//iq/ping/@xmlns');
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0199', 'handleIq'));
 }
コード例 #13
0
ファイル: jaxl.httpd.php プロジェクト: pavl00/Kalkun
 function shutdown()
 {
     JAXLPlugin::execute('jaxl_httpd_pre_shutdown');
     exit;
 }
コード例 #14
0
ファイル: componentbot.php プロジェクト: ZZB/JAXL
 * Usage: php componentbot.php
 * Read more: http://bit.ly/aGpYf8
 */
// Initialize Jaxl Library
require_once '../core/jaxl.class.php';
$jaxl = new JAXL(array('port' => 5559, 'compHost' => 'component.localhost', 'compPass' => '', 'logLevel' => 5));
// Include required XEP's
$jaxl->requires('JAXL0114');
// Jabber Component Protocol
// Sample Component class
class componentbot
{
    function postAuth($payload, $jaxl)
    {
        $jaxl->log("Component handshake completed ...");
    }
    function getMessage($payloads, $jaxl)
    {
        foreach ($payloads as $payload) {
            if (strlen($payload['body']) > 0) {
                $jaxl->sendMessage($payload['from'], $payload['body'], $payload['to']);
            }
        }
    }
}
// Add callbacks on various event handlers
$componentbot = new componentbot();
JAXLPlugin::add('jaxl_post_handshake', array($componentbot, 'postAuth'));
JAXLPlugin::add('jaxl_get_message', array($componentbot, 'getMessage'));
// Fire start Jaxl core
$jaxl->startCore("component");
コード例 #15
0
ファイル: xmpp.send.php プロジェクト: rahijain/JAXL
 public static function iq($type, $payload = false, $to = false, $from = false, $callback = false, $jaxl, $id = false, $ns = 'jabber:client')
 {
     if ($type == 'get' || $type == 'set') {
         $id = $jaxl->getId();
         if ($callback) {
             JAXLPlugin::add('jaxl_get_iq_' . $id, $callback);
         }
     }
     $types = array('get', 'set', 'result', 'error');
     $xml = '';
     $xml .= '<iq';
     $xml .= ' type="' . $type . '"';
     $xml .= ' id="' . $id . '"';
     if ($to) {
         $xml .= ' to="' . $to . '"';
     }
     if ($from) {
         $xml .= ' from="' . $from . '"';
     }
     $xml .= '>';
     if ($payload) {
         $xml .= $payload;
     }
     $xml .= '</iq>';
     self::xml($xml, $jaxl);
     if ($type == 'get' || $type == 'set') {
         return $id;
     } else {
         return true;
     }
 }
コード例 #16
0
ファイル: jaxl.httpd.php プロジェクト: ZZB/JAXL
 public static function start($options)
 {
     self::reset($options);
     pcntl_signal(SIGTERM, array("JAXLHTTPd", "shutdown"));
     pcntl_signal(SIGINT, array("JAXLHTTPd", "shutdown"));
     $options = getopt("p:b:");
     foreach ($options as $opt => $val) {
         switch ($opt) {
             case 'p':
                 self::$settings['port'] = $val;
                 break;
             case 'b':
                 self::$settings['maxq'] = $val;
             default:
                 break;
         }
     }
     self::$httpd = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
     socket_set_option(self::$httpd, SOL_SOCKET, SO_REUSEADDR, 1);
     socket_bind(self::$httpd, 0, self::$settings['port']);
     socket_listen(self::$httpd, self::$settings['maxq']);
     self::$id = self::getResourceID(self::$httpd);
     self::$clients = array("0#" . self::$settings['port'] => self::$httpd);
     echo "JAXLHTTPd listening on port " . self::$settings['port'] . PHP_EOL;
     while (true) {
         $read = self::$clients;
         $ns = @socket_select($read, $write = null, $except = null, JAXL_HTTPd_SELECT_TIMEOUT);
         if ($ns) {
             foreach ($read as $read_socket) {
                 $accept_id = self::getResourceID($read_socket);
                 if (self::$id == $accept_id) {
                     $sock = socket_accept($read_socket);
                     socket_getpeername($sock, $ip, $port);
                     self::$clients[$ip . "#" . $port] = $sock;
                     //echo "Accepted new connection from ".$ip."#".$port.PHP_EOL;
                     continue;
                 } else {
                     socket_getpeername($read_socket, $ip, $port);
                     $data = trim(socket_read($read_socket, 1024));
                     if ($data == "") {
                         self::close($ip, $port);
                     } else {
                         //echo "Recv data from ".$ip."#".$port.PHP_EOL;
                         $request = self::parseRequest($data, array('ip' => $ip, 'port' => $port));
                         if ($request['meta']['protocol'] == 'HTTP') {
                             JAXLPlugin::execute('jaxl_httpd_get_http_request', $request);
                         } else {
                             JAXLPlugin::execute('jaxl_httpd_get_sock_request', $request);
                         }
                     }
                 }
             }
         }
         JAXLPlugin::execute('jaxl_httpd_post_read');
     }
 }
コード例 #17
0
ファイル: jaxl.0124.php プロジェクト: rahijain/JAXL
 public static function processBody($xml, $jaxl)
 {
     $arr = $jaxl->xml->xmlize($xml);
     switch ($jaxl->action) {
         case 'connect':
             if (isset($arr["body"]["@"]["sid"])) {
                 $_SESSION['sid'] = $arr["body"]["@"]["sid"];
                 $jaxl->bosh['sid'] = $arr["body"]["@"]["sid"];
             }
             break;
         case 'disconnect':
             JAXLPlugin::execute('jaxl_post_disconnect');
             break;
         case 'ping':
             break;
         default:
             break;
     }
     return $xml;
 }
コード例 #18
0
ファイル: xmpp.auth.php プロジェクト: ZZB/JAXL
 public static function getResponse($authType, $challenge, $jaxl)
 {
     $response = array();
     $decoded = base64_decode($challenge);
     $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">';
     if ($authType == 'X-FACEBOOK-PLATFORM') {
         $decoded = explode('&', $decoded);
         foreach ($decoded as $k => $v) {
             list($kk, $vv) = explode('=', $v);
             $decoded[$kk] = $vv;
             unset($decoded[$k]);
         }
         list($secret, $decoded['api_key'], $decoded['session_key']) = JAXLPlugin::execute('jaxl_get_facebook_key', false, $jaxl);
         $decoded['call_id'] = time();
         $decoded['v'] = '1.0';
         $base_string = '';
         foreach (array('api_key', 'call_id', 'method', 'nonce', 'session_key', 'v') as $key) {
             if (isset($decoded[$key])) {
                 $response[$key] = $decoded[$key];
                 $base_string .= $key . '=' . $decoded[$key];
             }
         }
         $base_string .= $secret;
         $response['sig'] = md5($base_string);
         $responseURI = '';
         foreach ($response as $k => $v) {
             if ($responseURI == '') {
                 $responseURI .= $k . '=' . urlencode($v);
             } else {
                 $responseURI .= '&' . $k . '=' . urlencode($v);
             }
         }
         $xml .= base64_encode($responseURI);
     } else {
         if ($authType == 'DIGEST-MD5') {
             $decoded = JAXLUtil::explodeData($decoded);
             if (!isset($decoded['digest-uri'])) {
                 $decoded['digest-uri'] = 'xmpp/' . $jaxl->domain;
             }
             $decoded['cnonce'] = base64_encode(JAXLUtil::generateNonce());
             if (isset($decoded['qop']) && $decoded['qop'] != 'auth' && strpos($decoded['qop'], 'auth') !== false) {
                 $decoded['qop'] = 'auth';
             }
             $response = array('username' => $jaxl->user, 'response' => JAXLUtil::encryptPassword(array_merge($decoded, array('nc' => '00000001')), $jaxl->user, $jaxl->pass), 'charset' => 'utf-8', 'nc' => '00000001', 'qop' => 'auth');
             foreach (array('nonce', 'digest-uri', 'realm', 'cnonce') as $key) {
                 if (isset($decoded[$key])) {
                     $response[$key] = $decoded[$key];
                 }
             }
             $xml .= base64_encode(JAXLUtil::implodeData($response));
         } else {
             if ($authType == 'SCRAM-SHA-1') {
                 $decoded = JAXLUtil::explodeData($decoded);
                 // SaltedPassword  := Hi(Normalize(password), salt, i)
                 $saltedPasswd = JAXLUtil::pbkdf2($jaxl->pass, $decoded['s'], $decoded['i']);
                 // ClientKey       := HMAC(SaltedPassword, "Client Key")
                 $clientKey = JAXLUtil::hashMD5($saltedPassword, "Client Key");
                 // StoredKey       := H(ClientKey)
                 $storedKey = sha1("Client Key");
                 // assemble client-final-message-without-proof
                 $clientFinalMessage = "c=bwis,r=" . $decoded['r'];
                 // AuthMessage     := client-first-message-bare + "," + server-first-message + "," + client-final-message-without-proof
                 // ClientSignature := HMAC(StoredKey, AuthMessage)
                 // ClientProof     := ClientKey XOR ClientSignature
                 // ServerKey       := HMAC(SaltedPassword, "Server Key")
                 // ServerSignature := HMAC(ServerKey, AuthMessage)
                 foreach (array('c', 'r', 'p') as $key) {
                     if (isset($decoded[$key])) {
                         $response[$key] = $decoded[$key];
                     }
                 }
                 $xml .= base64_encode(JAXLUtil::implodeData($response));
             } else {
                 if ($authType == 'CRAM-MD5') {
                     $xml .= base64_encode($jaxl->user . ' ' . hash_hmac('md5', $jaxl->pass, $arr['challenge']));
                 }
             }
         }
     }
     $xml .= '</response>';
     $jaxl->secondChallenge = true;
     return $xml;
 }
コード例 #19
0
ファイル: jaxl.0012.php プロジェクト: ngsru/JAXL
 public static function init()
 {
     global $jaxl;
     $jaxl->features[] = self::$ns;
     JAXLPlugin::add('jaxl_get_iq_get', array('JAXL0012', 'getIq'));
 }
コード例 #20
0
ファイル: jaxl.class.php プロジェクト: ZZB/JAXL
 /**
  * Starts Jaxl Core
  *
  * This method should be called after Jaxl initialization and hook registration inside your application code
  * Optionally, you can pass 'jaxl_post_connect' and 'jaxl_get_auth_mech' response type directly to this method
  * In that case application code SHOULD NOT register callbacks to above mentioned hooks
  *
  * @param string $arg[0] Optionally application code can pre-choose what Jaxl core should do after establishing socket connection.
  *                            Following are the valid options:
  *                            a) startStream
  *                            b) startComponent
  *                            c) startBosh
  */
 function startCore($mode = false)
 {
     if ($mode) {
         switch ($mode) {
             case 'stream':
                 JAXLPlugin::add('jaxl_post_connect', array($this, 'startStream'));
                 break;
             case 'component':
                 JAXLPlugin::add('jaxl_post_connect', array($this, 'startComponent'));
                 break;
             case 'bosh':
                 $this->startBosh();
                 break;
             default:
                 break;
         }
     }
     if ($this->mode == 'cli') {
         try {
             if ($this->connect()) {
                 while ($this->stream) {
                     $this->getXML();
                 }
             }
         } catch (Exception $e) {
             die($e->getMessage);
         }
         /* Exit Jaxl after end of loop */
         exit;
     }
 }
コード例 #21
0
ファイル: xmpp.class.php プロジェクト: rahijain/JAXL
 function getXML($nap = TRUE)
 {
     // sleep between two reads
     if ($nap) {
         sleep(JAXL_XMPP_GET_SLEEP);
     }
     // initialize empty lines read
     $emptyLine = 0;
     // read previous buffer
     $payload = $this->buffer;
     $this->buffer = '';
     // read socket data
     for ($i = 0; $i < JAXL_XMPP_GET_PCKTS; $i++) {
         if ($this->stream) {
             $line = fread($this->stream, JAXL_XMPP_GET_PCKT_SIZE);
             if (strlen($line) == 0) {
                 $emptyLine++;
                 if ($emptyLine > JAXL_XMPP_GET_EMPTY_LINES) {
                     break;
                 }
             } else {
                 $payload .= $line;
             }
         }
     }
     // trim read data
     $payload = trim($payload);
     $payload = JAXLPlugin::execute('jaxl_get_xml', $payload, $this);
     if ($payload != '') {
         XMPPGet::handler($payload, $this);
     }
 }
コード例 #22
0
ファイル: jaxl.class.php プロジェクト: rahijain/JAXL
 function shutdown($signal)
 {
     JAXLog::log("Jaxl Shutting down ...", 0, $this);
     JAXLPlugin::execute('jaxl_pre_shutdown', $signal, $this);
     if ($this->stream) {
         XMPPSend::endStream($this);
     }
     $this->stream = false;
 }
コード例 #23
0
ファイル: jaxl.0124.php プロジェクト: ZZB/JAXL
 public static function preHandler($payload, $jaxl)
 {
     if (substr($payload, 1, 4) == "body") {
         list($body, $payload) = self::unwrapBody($payload);
         if ($payload == '') {
             if ($_SESSION['auth'] === 'disconnect') {
                 $_SESSION['auth'] = false;
                 JAXLPlugin::execute('jaxl_post_disconnect');
             } else {
                 JAXLPlugin::execute('jaxl_get_empty_body', $body, $jaxl);
             }
         }
         if ($_SESSION['auth'] === 'connect') {
             $arr = $jaxl->xml->xmlize($body);
             if (isset($arr["body"]["@"]["sid"])) {
                 $_SESSION['auth'] = false;
                 $_SESSION['sid'] = $arr["body"]["@"]["sid"];
                 $jaxl->bosh['sid'] = $arr["body"]["@"]["sid"];
             }
         }
     }
     return $payload;
 }
コード例 #24
0
ファイル: jaxl.cron.php プロジェクト: ZZB/JAXL
 public static function init()
 {
     JAXLPlugin::add('jaxl_get_xml', array('JAXLCron', 'ticker'));
 }
コード例 #25
0
ファイル: echobot.php プロジェクト: rahijain/JAXL
            }
        }
    }
    function getPresence($payloads)
    {
        global $jaxl;
        foreach ($payloads as $payload) {
            if ($payload['type'] == "subscribe") {
                // accept subscription
                $jaxl->subscribed($payload['from']);
                // go for mutual subscription
                $jaxl->subscribe($payload['from']);
            } else {
                if ($payload['type'] == "unsubscribe") {
                    // accept subscription
                    $jaxl->unsubscribed($payload['from']);
                    // go for mutual subscription
                    $jaxl->unsubscribe($payload['from']);
                }
            }
        }
    }
}
// Add callbacks on various event handlers
$echobot = new echobot();
JAXLPlugin::add('jaxl_post_connect', array($echobot, 'startStream'));
JAXLPlugin::add('jaxl_get_auth_mech', array($echobot, 'doAuth'));
JAXLPlugin::add('jaxl_post_auth', array($echobot, 'postAuth'));
JAXLPlugin::add('jaxl_get_message', array($echobot, 'getMessage'));
JAXLPlugin::add('jaxl_get_presence', array($echobot, 'getPresence'));
コード例 #26
0
ファイル: xmpp.class.php プロジェクト: ZZB/JAXL
 /**
  * Routes incoming XMPP data to appropriate handlers
  */
 function handler($payload)
 {
     $this->log("[[XMPPGet]] \n" . $payload, 4);
     $buffer = array();
     $payload = JAXLPlugin::execute('jaxl_pre_handler', $payload, $this);
     $xmls = JAXLUtil::splitXML($payload);
     $pktCnt = count($xmls);
     foreach ($xmls as $pktNo => $xml) {
         if ($pktNo == $pktCnt - 1) {
             if (substr($xml, -1, 1) != '>') {
                 $this->buffer = $xml;
                 break;
             }
         }
         if (substr($xml, 0, 7) == '<stream') {
             $arr = $this->xml->xmlize($xml);
         } else {
             $arr = JAXLXml::parse($xml);
         }
         switch (true) {
             case isset($arr['stream:stream']):
                 XMPPGet::streamStream($arr['stream:stream'], $this);
                 break;
             case isset($arr['stream:features']):
                 XMPPGet::streamFeatures($arr['stream:features'], $this);
                 break;
             case isset($arr['stream:error']):
                 XMPPGet::streamError($arr['stream:error'], $this);
                 break;
             case isset($arr['failure']):
                 XMPPGet::failure($arr['failure'], $this);
                 break;
             case isset($arr['proceed']):
                 XMPPGet::proceed($arr['proceed'], $this);
                 break;
             case isset($arr['challenge']):
                 XMPPGet::challenge($arr['challenge'], $this);
                 break;
             case isset($arr['success']):
                 XMPPGet::success($arr['success'], $this);
                 break;
             case isset($arr['presence']):
                 $buffer['presence'][] = $arr['presence'];
                 break;
             case isset($arr['message']):
                 $buffer['message'][] = $arr['message'];
                 break;
             case isset($arr['iq']):
                 XMPPGet::iq($arr['iq'], $this);
                 break;
             default:
                 $jaxl->log("Unrecognized payload received from jabber server...", 1);
                 break;
         }
     }
     if (isset($buffer['presence'])) {
         XMPPGet::presence($buffer['presence'], $this);
     }
     if (isset($buffer['message'])) {
         XMPPGet::message($buffer['message'], $this);
     }
     unset($buffer);
     JAXLPlugin::execute('jaxl_post_handler', $payload, $this);
 }
コード例 #27
0
ファイル: sendMessage.php プロジェクト: ZZB/JAXL
<?php

/**
 * Sample command line bot for sending a message
 * Usage: php sendMessage.php "*****@*****.**" "Your message"
 */
// Initialize Jaxl Library
require_once '../core/jaxl.class.php';
// Values passed to the constructor can also be defined as constants
// List of constants can be found inside "../../env/jaxl.ini"
// Note: Values passed to the constructor always overwrite defined constants
$jaxl = new JAXL(array('user' => '', 'pass' => '', 'host' => 'talk.google.com', 'domain' => 'gmail.com', 'authType' => 'PLAIN', 'logLevel' => 5));
// Post successful auth send desired message
function postAuth($payload, $jaxl)
{
    global $argv;
    $jaxl->sendMessage($argv[1], $argv[2]);
    $jaxl->shutdown();
}
// Register callback on required hooks
JAXLPlugin::add('jaxl_post_auth', 'postAuth');
// Fire start Jaxl core
$jaxl->startCore("stream");
コード例 #28
0
ファイル: preFetchBOSH.php プロジェクト: ZZB/JAXL
// Include required XEP's
$xmpp->requires(array('JAXL0054', 'JAXL0206'));
function doAuth($mechanism, $xmpp)
{
    $xmpp->auth('DIGEST-MD5');
}
function postAuth($payload, $xmpp)
{
    $xmpp->JAXL0054('getVCard', false, $xmpp->jid, 'handleVCard');
}
function handleVCard($payload, $xmpp)
{
    echo "<b>Successfully fetched VCard</b><br/>";
    print_r($payload);
    $xmpp->JAXL0206('endStream');
}
function postDisconnect($payload, $xmpp)
{
    exit;
}
function postAuthFailure($payload, $xmpp)
{
    echo "OOPS! Auth failed";
}
// Register callbacks for required events
JAXLPlugin::add('jaxl_get_auth_mech', 'doAuth');
JAXLPlugin::add('jaxl_post_auth', 'postAuth');
JAXLPlugin::add('jaxl_post_auth_failure', 'postAuthFailure');
JAXLPlugin::add('jaxl_post_disconnect', 'postDisconnect');
// Fire start Jaxl in bosh mode
$xmpp->startCore('bosh');
コード例 #29
0
ファイル: xmpp.get.php プロジェクト: rahijain/JAXL
 public static function iq($arr, $jaxl)
 {
     switch ($arr['type']) {
         case 'result':
             $id = $arr['id'];
             JAXLPlugin::execute('jaxl_get_iq_' . $id, $arr, $jaxl);
             break;
         case 'get':
             JAXLPlugin::execute('jaxl_get_iq_get', $arr, $jaxl);
             break;
         case 'set':
             JAXLPlugin::execute('jaxl_get_iq_set', $arr, $jaxl);
             break;
         case 'error':
             JAXLPlugin::execute('jaxl_get_iq_error', $arr, $jaxl);
             break;
         default:
             JAXLog::log('Unhandled iq type ...' . json_encode($arr), 0, $jaxl);
             break;
     }
     return $arr;
 }