示例#1
0
 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);
 }
示例#2
0
 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);
 }
示例#3
0
文件: linker.php 项目: ajira86/movim
     $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");
 }
示例#4
0
 function ajaxLogout()
 {
     $pd = new \Modl\PresenceDAO();
     $pd->clearPresence();
     $session = \Session::start();
     $p = new Unavailable();
     $p->setType('terminate')->setResource($session->get('resource'))->setTo($session->get('jid'))->request();
     Stream::end();
 }
示例#5
0
文件: linker.php 项目: Anon215/movim
         $loop->stop();
         return;
     }
     fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " : " . colorize('TLS enabled', 'blue') . "\n");
     $restart = true;
 }
 #fwrite(STDERR, colorize(getenv('sid'), 'yellow')." widgets : ".\sizeToCleanSize(memory_get_usage())."\n");
 \Moxl\API::clear();
 \RPC::clear();
 $timestamp = time();
 if (!$parser->parse($message)) {
     fwrite(STDERR, colorize(getenv('sid'), 'yellow') . " " . $parser->getError() . "\n");
 }
 if ($restart) {
     $session = \Session::start();
     \Moxl\Stanza\Stream::init($session->get('host'));
     stream_set_blocking($conn->stream, 0);
     $restart = false;
 }
 $msg = \RPC::commit();
 if (!empty($msg)) {
     echo base64_encode(gzcompress(json_encode($msg), 9)) . "";
     //fwrite(STDERR, colorize(json_encode($msg).' '.strlen($msg), 'yellow')." : ".colorize('sent to browser', 'green')."\n");
 }
 \RPC::clear();
 $xml = \Moxl\API::commit();
 if (!empty($xml)) {
     $conn->write(trim($xml));
     #fwrite(STDERR, colorize(trim($xml), 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
 }
 \Moxl\API::clear();
示例#6
0
文件: Bind.php 项目: movim/moxl
 public function request()
 {
     $this->store();
     Stream::bindSet($this->_resource);
 }
示例#7
0
文件: Start.php 项目: Hywan/moxl
 public function request()
 {
     $this->store();
     Stream::sessionStart($this->_to);
 }
示例#8
0
文件: Login.php 项目: Nyco/movim
 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);
 }
示例#9
0
 function ajaxLogout()
 {
     $pd = new \Modl\PresenceDAO();
     $session = \Sessionx::start();
     $pd->clearPresence($session->username . '@' . $session->host);
     $session = \Sessionx::start();
     $p = new Unavailable();
     $p->setType('terminate')->setResource($session->resource)->setTo($this->user->getLogin())->request();
     Stream::end();
 }
示例#10
0
文件: STARTTLS.php 项目: movim/moxl
 public function handle($stanza, $parent = false)
 {
     if (isset($stanza->required)) {
         Stream::startTLS();
     }
 }
示例#11
0
 public function handle($stanza, $parent = false)
 {
     $session = \Sessionx::start();
     \Moxl\Stanza\Stream::init($session->host);
 }
示例#12
0
文件: Login.php 项目: Anon215/movim
 private function doLogin($login, $password)
 {
     // We get the Server Configuration
     $cd = new \Modl\ConfigDAO();
     $config = $cd->get();
     // First we check the form
     $validate_login = Validator::email()->length(1, 254);
     $validate_password = Validator::stringType()->length(1, 128);
     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) {
         //if($s->get('hash') == sha1($username.$password.$host)) {
         RPC::call('Login.setCookie', $here->session);
         RPC::call('MovimUtils.redirect', Route::urlize('main'));
         $this->showErrorBlock('conflict');
         return;
     }
     $s = Session::start();
     // We create a new session or clear the old one
     $s->set('password', $password);
     $s->set('username', $username);
     $s->set('host', $host);
     $s->set('jid', $login);
     $s->set('hash', sha1($username . $password . $host));
     $s = Sessionx::start();
     $s->init($username, $password, $host);
     // We launch the XMPP socket
     RPC::call('register', $host);
     \Moxl\Stanza\Stream::init($host);
 }