Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 3
0
$stdin_behaviour = function ($data) use(&$conn, $loop, &$buffer, &$connector, &$xmpp_behaviour, &$parser) {
    if (substr($data, -1) == "") {
        $messages = explode("", $buffer . substr($data, 0, -1));
        $buffer = '';
        foreach ($messages as $message) {
            #fwrite(STDERR, colorize($message, 'yellow')." : ".colorize('received from the browser', 'green')."\n");
            $msg = json_decode($message);
            if (isset($msg)) {
                if ($msg->func == 'message' && $msg->body != '') {
                    $msg = $msg->body;
                } elseif ($msg->func == 'unregister') {
                    \Moxl\Stanza\Stream::end();
                } elseif ($msg->func == 'register') {
                    $cd = new \Modl\ConfigDAO();
                    $config = $cd->get();
                    $domain = \Moxl\Utils::getDomain($msg->host);
                    #fwrite(STDERR, colorize('open a socket to '.$domain, 'yellow')." : ".colorize('sent to XMPP', 'green')."\n");
                    $connector->create($domain, 5222)->then($xmpp_behaviour);
                }
            } else {
                return;
            }
            $rpc = new \RPC();
            $rpc->handle_json($msg);
            $msg = json_encode(\RPC::commit());
            \RPC::clear();
            if (!empty($msg)) {
                echo base64_encode(gzcompress($msg, 9)) . "";
                #fwrite(STDERR, colorize($msg, 'yellow')." : ".colorize('sent to the browser', 'green')."\n");
            }
            $xml = \Moxl\API::commit();
Exemplo n.º 4
0
Arquivo: Login.php Projeto: 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);
 }