public function handle($stanza, $parent = false) { $session = \Sessionx::start(); $session->destroy(); $this->pack($stanza->children()->getName()); $this->deliver(); }
public function handle($stanza, $parent = false) { $mec = (array) $stanza->mechanism; /* * Weird behaviour on old eJabberd servers, fixed on the new versions * see https://github.com/processone/ejabberd/commit/2d748115 */ if (isset($parent->starttls) && isset($parent->starttls->required)) { return; } $sessx = \Sessionx::start(); $user = $sessx->user; if (isset($user)) { if (!is_array($mec)) { $mec = array($mec); } $mecchoice = str_replace('-', '', \Moxl\Auth::mechanismChoice($mec)); $sess = \Session::start(); $sess->set('mecchoice', $mecchoice); \Moxl\Utils::log("/// MECANISM CHOICE " . $mecchoice); if (method_exists('\\Moxl\\Auth', 'mechanism' . $mecchoice)) { call_user_func('Moxl\\Auth::mechanism' . $mecchoice); } else { \Moxl\Utils::log("/// MECANISM CHOICE NOT FOUND"); } } else { $g = new Get(); $g->setTo($sessx->host)->request(); } }
static function iqWrapper($xml = false, $to = false, $type = false, $id = false) { $session = \Sessionx::start(); $dom = new \DOMDocument('1.0', 'UTF-8'); $iq = $dom->createElementNS('jabber:client', 'iq'); $dom->appendChild($iq); if ($to != false) { $iq->setAttribute('to', $to); } if ($type != false) { $iq->setAttribute('type', $type); } global $language; if ($id == false) { $id = $session->id; } $iq->setAttribute('id', $id); if (isset($language)) { $iq->setAttribute('xml:lang', $language); } if (isset($session->user)) { $iq->setAttribute('from', $session->user . '@' . $session->host . '/' . $session->resource); } if ($xml != false) { if (is_string($xml)) { $f = $dom->createDocumentFragment(); $f->appendXML($xml); $iq->appendChild($f); } else { $xml = $dom->importNode($xml, true); $iq->appendChild($xml); } } return $dom->saveXML($dom->documentElement); }
function dispatch() { $session = \Sessionx::start(); requestURL('http://localhost:1560/disconnect/', 2, ['sid' => $session->sessionid]); Session::dispose(); $this->redirect('login'); }
static function server() { $session = \Sessionx::start(); $dom = new \DOMDocument('1.0', 'UTF-8'); $ping = $dom->createElementNS('urn:xmpp:ping', 'ping'); \Moxl\API::request(\Moxl\API::iqWrapper($ping, $session->host, 'get')); }
static function maker($to, $content = false, $html = false, $type = 'chat', $chatstates = false, $receipts = false) { $session = \Sessionx::start(); $dom = new \DOMDocument('1.0', 'UTF-8'); $root = $dom->createElementNS('jabber:client', 'message'); $dom->appendChild($root); $root->setAttribute('to', str_replace(' ', '\\40', $to)); $root->setAttribute('id', $session->id); $root->setAttribute('type', $type); if ($content != false) { $body = $dom->createElement('body', $content); $root->appendChild($body); } if ($html != false) { $xhtml = $dom->createElementNS('http://jabber.org/protocol/xhtml-im', 'html'); $body = $dom->createElement('http://www.w3.org/1999/xhtml', 'body', $html); $xhtml->appendChild($body); $root->appendChild($xhtml); } if ($chatstates != false) { $chatstate = $dom->createElementNS('http://jabber.org/protocol/chatstates', $chatstates); $root->appendChild($chatstate); } if ($receipts != false) { if ($receipts == 'request') { $request = $dom->createElement('request'); } else { $request = $dom->createElement('received'); $request->setAttribute('id', $receipts); } $request->setAttribute('xmlns', 'urn:xmpp:receipts'); $root->appendChild($request); } \Moxl\API::request($dom->saveXML($dom->documentElement)); }
public function runRequest($request) { $c = $this->loadController($request); $sess = \Sessionx::start(); $sess->refreshCookie(); if (is_callable(array($c, 'load'))) { $c->name = $request; $c->load(); $c->checkSession(); $c->dispatch(); // If the controller ask to display a different page if ($request != $c->name) { $new_name = $c->name; $c = $this->loadController($new_name); $c->name = $new_name; $c->load(); $c->dispatch(); } // We display the page ! $c->display(); } else { $log = new Logger('movim'); $log->pushHandler(new SyslogHandler('movim')); $log->addError(t("Could not call the load method on the current controller")); } }
function ajaxGetForm($host) { $domain = \Moxl\Utils::getDomain($host); // We create a new session or clear the old one $s = Sessionx::start(); $s->init(null, null, $host, $domain); \Moxl\Stanza\Stream::init($host); }
public function handle($stanza, $parent = false) { $session = \Sessionx::start(); //if($stanza->required) { $ss = new Bind(); $ss->setResource($session->resource)->request(); //} }
public function handle($stanza, $parent = false) { $sessx = \Sessionx::start(); $user = $sessx->user; if (!isset($user)) { $r = new Get(); $r->request(); } }
public function handle($stanza, $parent = false) { $session = \Sessionx::start(); Utils::log("/// AUTH SUCCESSFULL"); $session->active = true; $session->password = '******'; $this->pack($session); $this->deliver(); }
function dispatch() { $session = \Sessionx::start(); //requestURL('http://localhost:1560/unregister/', 2, ['sid' => $session->sessionid]); $this->page->setTitle(__('page.login')); $user = new User(); if ($user->isLogged()) { $this->redirect('root'); } }
public function handle($stanza, $parent = false) { $session = \Sessionx::start(); list($jid, $resource) = explode('/', (string) $stanza->bind->jid); list($session->username, $session->host) = explode('@', $jid); if ($resource) { $session->resource = $resource; } $ss = new Start(); $ss->setTo($session->host)->request(); }
static function setSubject($to, $subject) { $session = \Sessionx::start(); $dom = new \DOMDocument('1.0', 'UTF-8'); $message = $dom->createElementNS('jabber:client', 'message'); $dom->appendChild($message); $message->setAttribute('to', str_replace(' ', '\\40', $to)); $message->setAttribute('id', $session->id); $message->setAttribute('type', 'groupchat'); $message->appendChild($dom->createElement('subject', $subject)); \Moxl\API::request($dom->saveXML($dom->documentElement)); }
public function handle($stanza, $parent = false) { $session = \Session::start(); $session->remove('password'); $session->set('active', true); $session = \Sessionx::start(); Utils::log("/// AUTH SUCCESSFULL"); // And we tell the daemon that the session is started ! fwrite(STDERR, 'started'); $session->active = true; $this->pack($session); $this->deliver(); }
static function mechanismSCRAMSHA1() { $s = new SASL2(); $fa = $s->factory('SCRAM-SHA1'); $session = \Sessionx::start(); Utils::log("/// INITIAL MESSAGE"); $response = base64_encode($fa->getResponse($session->user, $session->password)); $sess = \Session::start(); $sess->set('saslfa', $fa); $xml = '<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="SCRAM-SHA-1"> ' . $response . ' </auth>'; API::request($xml); }
public final function store() { $sess = \Session::start(); //$_instances = $sess->get('xecinstances'); // Set a new Id for the Iq request $session = \Sessionx::start(); // Generating the iq key. $id = $session->id = \generateKey(6); // We serialize the current object $obj = new \StdClass(); $obj->type = get_class($this); $obj->object = serialize($this); $obj->time = time(); //$_instances = $this->clean($_instances); $sess->set($id, $obj); }
public function handle($stanza, $parent = false) { $sess = \Session::start(); $session = \Sessionx::start(); $s = new SASL2(); switch ($sess->get('mecchoice')) { case 'SCRAMSHA1': $fa = $sess->get('saslfa'); $sess->remove('saslfa'); $challenge = base64_decode((string) $stanza); \Moxl\Utils::log("/// SECOND MESSAGE - PROOF"); $response = base64_encode($fa->getResponse($session->user, $session->password, $challenge)); $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $response . '</response>'; \Moxl\API::request($xml); break; case 'DIGESTMD5': $decoded = base64_decode((string) $stanza); $s = new SASL2(); $d = $s->factory('digest-md5'); if (!$sess->get('saslfirst')) { \Moxl\Utils::log("/// CHALLENGE"); $response = $d->getResponse($session->user, $session->password, $decoded, $session->host, 'xmpp'); $response = base64_encode($response); $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $response . '</response>'; $sess->set('saslfirst', 1); } else { $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>'; } \Moxl\API::request($xml); break; case 'CRAMMD5': $decoded = base64_decode((string) $stanza); $s = new SASL2(); $c = $s->factory('cram-md5'); $session = \Sessionx::start(); $response = $c->getResponse($session->user, $session->pass, $decoded); $response = base64_encode($response); \Moxl\Utils::log("/// CHALLENGE"); $xml = '<response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">' . $response . '</response>'; \Moxl\API::request($xml); break; } }
function ajaxLogin($username) { $validate_user = Validator::string()->length(4, 40); if (!$validate_user->validate($username)) { Notification::append(null, $this->__('login_anonymous.bad_username')); return; } // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); $host = 'anonymous.jappix.com'; $password = '******'; // We try to get the domain $domain = \Moxl\Utils::getDomain($host); // We launch the XMPP socket RPC::call('register', $host); // We set the username in the session $s = Session::start(); $s->set('username', $username); // We create a new session or clear the old one $s = Sessionx::start(); $s->init($username, $password, $host, $domain); \Moxl\Stanza\Stream::init($host); }
/** * @brief Send a message * * @param string $to * @param string $message * @return void */ function ajaxSendMessage($to, $message, $muc = false, $resource = false) { if ($message == '') { return; } $m = new \Modl\Message(); $m->session = $this->user->getLogin(); $m->jidto = echapJid($to); $m->jidfrom = $this->user->getLogin(); $session = \Sessionx::start(); $m->type = 'chat'; $m->resource = $session->resource; if ($muc) { $m->type = 'groupchat'; $s = Session::start(); $m->resource = $s->get('username'); if ($m->resource == null) { $m->resource = $session->user; } $m->jidfrom = $to; } $m->body = rawurldecode($message); $m->html = prepareString($m->body, false, true); $m->published = gmdate('Y-m-d H:i:s'); $m->delivered = gmdate('Y-m-d H:i:s'); if ($resource != false) { $to = $to . '/' . $resource; } // We decode URL codes to send the correct message to the XMPP server $p = new Publish(); $p->setTo($to); //$p->setHTML($m->html); $p->setContent(htmlspecialchars($m->body)); if ($muc) { $p->setMuc(); } $p->request(); /* Is it really clean ? */ if (!$p->getMuc()) { if (!preg_match('#^\\?OTR#', $m->body)) { $md = new \Modl\MessageDAO(); $md->set($m); } $packet = new Moxl\Xec\Payload\Packet(); $packet->content = $m; $this->onMessage($packet); } }
$conn->close(); $loop->stop(); } elseif ($message == "<proceed xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>" || $message == '<proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>') { stream_set_blocking($conn->stream, 1); $out = stream_socket_enable_crypto($conn->stream, 1, STREAM_CRYPTO_METHOD_TLS_CLIENT); $restart = true; } #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received', 'green')."\n"); #fwrite(STDERR, colorize(getenv('sid'), 'yellow')." widgets : ".\sizeToCleanSize(memory_get_usage())."\n"); \Moxl\API::clear(); \RPC::clear(); if (!$parser->parse($message)) { fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " " . $parser->getError() . "\n"); } if ($restart) { $session = \Sessionx::start(); \Moxl\Stanza\Stream::init($session->host); stream_set_blocking($conn->stream, 0); $restart = false; } $msg = \RPC::commit(); \RPC::clear(); if (!empty($msg)) { echo base64_encode(gzcompress(json_encode($msg), 9)) . ""; #fwrite(STDERR, colorize($msg.' '.strlen($msg), 'yellow')." : ".colorize('sent to browser', 'green')."\n"); } $xml = \Moxl\API::commit(); \Moxl\API::clear(); if (!empty($xml)) { $conn->write(trim($xml)); #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
function isSupported($key) { $this->reload(); if ($this->caps != null) { switch ($key) { case 'pubsub': return in_array('http://jabber.org/protocol/pubsub#publish', $this->caps); break; case 'upload': $id = new \Modl\ItemDAO(); return $id->getUpload($this->getServer()) != null; break; default: return false; break; } } elseif ($key == 'anonymous') { $session = \Sessionx::start(); return $session->mechanism == 'ANONYMOUS'; } else { return false; } }
function ajaxSendCandidate($candidate) { $p = json_decode($candidate); $sd = Sessionx::start(); $sdp = 'm=' . $p->mid . "\n" . $p->sdp; $stj = new SDPtoJingle($sdp, $this->user->getLogin() . '/' . $sd->resource, $p->jid . '/' . $p->resource, 'transport-info'); $r = new SessionInitiate(); $r->setTo($p->jid . '/' . $p->resource)->setOffer($stj->generate())->request(); }
public function handle($stanza, $parent = false) { $session = \Sessionx::start(); \Moxl\Stanza\Stream::init($session->host); }
function preparePresenceList() { $txt = getPresences(); $txts = getPresencesTxt(); $session = \Sessionx::start(); $pd = new \Modl\PresenceDAO(); $p = $pd->getPresence($this->user->getLogin(), $session->resource); $cd = new \Modl\ContactDAO(); $contact = $cd->get($this->user->getLogin()); if ($contact == null) { $contact = new \Modl\Contact(); } $presencetpl = $this->tpl(); $presencetpl->assign('contact', $contact); $presencetpl->assign('p', $p); $presencetpl->assign('txt', $txt); $presencetpl->assign('txts', $txts); $presencetpl->assign('calllogout', $this->call('ajaxLogout')); $html = $presencetpl->draw('_presence_list', true); return $html; }
private function startingSession() { $s = \Sessionx::start(); $s->load(); $user = new User(); $db = modl\Modl::getInstance(); $db->setUser($user->getLogin()); }
function ajaxLogin($form) { // We get the Server Configuration $cd = new \Modl\ConfigDAO(); $config = $cd->get(); // First we check the form $validate_login = Validator::email()->length(6, 40); $validate_password = Validator::string()->length(4, 40); $login = $form->login->value; $password = $form->pass->value; if (!$validate_login->validate($login)) { $this->showErrorBlock('login_format'); return; } if (!$validate_password->validate($password)) { $this->showErrorBlock('password_format'); return; } list($username, $host) = explode('@', $login); // Check whitelisted server if ($config->xmppwhitelist != '' && !in_array($host, explode(',', $config->xmppwhitelist))) { $this->showErrorBlock('unauthorized'); return; } // We check if we already have an open session $sd = new \Modl\SessionxDAO(); $here = $sd->getHash(sha1($username . $password . $host)); if ($here) { RPC::call('Login.setCookie', $here->session); RPC::call('movim_redirect', Route::urlize('main')); $this->showErrorBlock('conflict'); return; } // We try to get the domain $domain = \Moxl\Utils::getDomain($host); // We launch the XMPP socket RPC::call('register', $host); // We create a new session or clear the old one $s = Sessionx::start(); $s->init($username, $password, $host, $domain); \Moxl\Stanza\Stream::init($host); }
static function muc($to, $nickname = false) { $session = \Sessionx::start(); if ($nickname == false) { $nickname = $session->user; } $dom = new \DOMDocument('1.0', 'UTF-8'); $presence = $dom->createElementNS('jabber:client', 'presence'); $dom->appendChild($presence); $presence->setAttribute('from', $session->user . '@' . $session->host . '/' . $session->resource); $presence->setAttribute('id', $session->id); $presence->setAttribute('to', $to . '/' . $nickname); $presence->appendChild($dom->createElementNS('http://jabber.org/protocol/muc', 'x')); \Moxl\API::request($dom->saveXML($dom->documentElement)); }
function ajaxSubmit($data, $node, $sessionid) { $session = \Sessionx::start(); $s = new Submit(); $s->setTo($session->host)->setNode($node)->setData($data)->setSessionid($sessionid)->request(); }
function checkConnected($room, $resource = false) { if (!$this->validateRoom($room)) { return; } if ($resource && !$this->validateResource($resource)) { Notification::append(null, $this->__('chatrooms.bad_id')); return; } $pd = new \modl\PresenceDAO(); if ($resource == false) { $session = \Sessionx::start(); $resource = $session->user; } $presence = $pd->getPresence($room, $resource); if ($presence != null) { return true; } else { return false; } }