public static function init($jaxl) { // Requires Bosh Session Manager jaxl_require('JAXL0124', $jaxl); $jaxl->action = $_REQUEST['jaxl']; JAXLog::log("[[JaxlAction]] " . $jaxl->action . "\n" . json_encode($_REQUEST), 5, $jaxl); }
public static function init($jaxl) { jaxl_require('JAXLS5B'); // SOCKS5 $jaxl->features[] = self::$ns; JAXLXml::addTag('iq', 'streamSid', '//iq/query/@sid'); JAXLXml::addTag('iq', 'streamMode', '//iq/query/@mode'); JAXLXml::addTag('iq', 'streamHost', '//iq/query/streamhost/@host'); JAXLXml::addTag('iq', 'streamPort', '//iq/query/streamhost/@port'); JAXLXml::addTag('iq', 'streamJid', '//iq/query/streamhost/@jid'); JAXLXml::addTag('iq', 'streamHostUsed', '//iq/query/streamhost-used/@jid'); $jaxl->addPlugin('jaxl_get_iq_set', array('JAXL0065', 'getStreamHost')); }
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ // include required classes jaxl_require(array('JAXLPlugin', 'JAXLog')); /* * XMPP Send Class * Provide methods for sending all kind of xmpp stream and stanza's */ class XMPPSend { public static function xml($xml, $jaxl) { $xml = JAXLPlugin::execute('jaxl_send_xml', $xml, $jaxl); if ($jaxl->mode == "cgi") { JAXLPlugin::execute('jaxl_send_body', $xml, $jaxl); } else { if ($jaxl->lastSendTime && JAXLUtil::getTime() - $jaxl->lastSendTime < JAXL_XMPP_SEND_RATE) { sleep(JAXL_XMPP_SEND_SLEEP); }
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package jaxl * @subpackage xmpp * @author Abhinav Singh <*****@*****.**> * @copyright Abhinav Singh * @link http://code.google.com/p/jaxl */ // include required classes jaxl_require(array('JAXLUtil', 'JAXLPlugin')); /** * XMPP Auth class for performing various SASL auth mechanisms * DIGEST-MD5, X-FACEBOOK-PLATFORM, SCRAM-SHA-1, CRAM-MD5 */ class XMPPAuth { 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);
/** * Instead of using jaxl_require method applications can use $jaxl->requires to include XEP's in PHP environment * * @param string $class Class name of the XEP to be included e.g. JAXL0045 for including XEP-0045 a.k.a. Multi-user chat */ function requires($class) { jaxl_require($class, $this); }
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package jaxl * @subpackage xmpp * @author Abhinav Singh <*****@*****.**> * @copyright Abhinav Singh * @link http://code.google.com/p/jaxl */ // include required classes jaxl_require(array('JAXLPlugin', 'JAXLog', 'XMPPGet', 'XMPPSend')); /** * Base XMPP class */ class XMPP { /** * Auth status of Jaxl instance * * @var bool */ var $auth = false; /** * Connected XMPP stream session requirement status * * @var bool
public static function init($jaxl) { // include required XEP's jaxl_require(array('JAXL0004', 'JAXL0050'), $jaxl); $jaxl->features[] = self::$ns; }
<?php /* * Example echobot application using Jaxl library * Read more: http://bit.ly/bz9KXb */ // Initialize Jaxl Library $jaxl = new JAXL(); // Include required XEP's jaxl_require(array('JAXL0115', 'JAXL0085', 'JAXL0092', 'JAXL0203', 'JAXL0199'), $jaxl); // Sample Echobot class class echobot { function startStream() { global $jaxl; $jaxl->startStream(); } function doAuth($mechanism) { global $jaxl; switch (TRUE) { case in_array("ANONYMOUS", $mechanism): $jaxl->auth("ANONYMOUS"); break; case in_array("DIGEST-MD5", $mechanism): $jaxl->auth("DIGEST-MD5"); break; case in_array("PLAIN", $mechanism): $jaxl->auth("PLAIN"); break;
* * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRIC * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ // include required classes jaxl_require(array('JAXLPlugin', 'JAXLog', 'JAXLXml', 'XMPPAuth', 'XMPPSend')); /* * XMPP Get Class * Provide methods for receiving all kind of xmpp streams and stanza's */ class XMPPGet { public static function handler($payload, &$jaxl) { JAXLog::log("[[XMPPGet]] \n" . $payload, 4, $jaxl); $buffer = array(); $payload = JAXLPlugin::execute('jaxl_pre_handler', $payload, $jaxl); $xmls = JAXLUtil::splitXML($payload); $pktCnt = count($xmls); foreach ($xmls as $pktNo => $xml) { if ($pktNo == $pktCnt - 1) {
<?php /* * Example bosh chat application using Jaxl library * Read more: http://bit.ly/aMozMy */ // Ajax poll url define('BOSHCHAT_POLL_URL', 'http://localhost/jaxl.php'); // Admin jid who will receive all messages sent using this application ui define('BOSHCHAT_ROOM_JID', '*****@*****.**'); if (isset($_REQUEST['jaxl'])) { // Valid bosh request // Initialize Jaxl Library $jaxl = new JAXL(); // Include required XEP's jaxl_require(array('JAXL0115', 'JAXL0092', 'JAXL0203', 'JAXL0202', 'JAXL0206', 'JAXL0045'), $jaxl); // Sample Bosh chat application class class boshMUChat { public static function doAuth($mechanism) { global $jaxl; $jaxl->auth("DIGEST-MD5"); } public static function postAuth() { global $jaxl; list($nick, $domain, $res) = JAXLUtil::splitJid($jaxl->jid); $jaxl->JAXL0045('joinRoom', $jaxl->jid, BOSHCHAT_ROOM_JID . '/' . $nick, 0, 'seconds'); $response = array('jaxl' => 'connected', 'jid' => $jaxl->jid); $jaxl->JAXL0206('out', $response);
<?php /* * Example componentbot application using Jaxl library * Read more: http://bit.ly/aGpYf8 */ // Initialize Jaxl Library $jaxl = new JAXL(array('host' => JAXL_HOST_NAME, 'domain' => JAXL_HOST_DOMAIN, 'component' => JAXL_COMPONENT_HOST, 'port' => JAXL_COMPONENT_PORT)); // Include required XEP's jaxl_require('JAXL0114', $jaxl); // Jabber Component Protocol // Sample Component class class componentbot { function doAuth() { global $jaxl; $jaxl->log("Going for component handshake ...", 1); return JAXL_COMPONENT_PASS; } function postAuth() { global $jaxl; $jaxl->log("Component handshake completed ...", 1); } function getMessage($payloads) { global $jaxl; // echo back foreach ($payloads as $payload) { $jaxl->sendMessage($payload['from'], $payload['body'], $payload['to']);