What I do is send a command to APE via PHP when the user is registered.

The command sends a key to APE who stores it.

Then, when the client tries to connect to APE, it sends the key with it,
and APE checks it.

The code below should help you:


$cmd = array(array(
          'cmd' => 'REGISTER_USER',
          'params' => array(
        'name' => "register_user",
        'user_id' => $user_id,
        'check_key' => $key,
        'activation_key' => $activation_key
           )
    ));

    // Attention this is synchronous, so it may freeze the server ??
    $data=send_command_to_APE($cmd);

    if ($data===FALSE OR $data=="")
    {
        //die("Server down!!");
        header('location:server_down.php');
        die(); // Otherwise, the next header location will take precedence.
    }
    else
    {
        if ($data[0]->raw=="ERR") // 005 NICK USED
        {
            // We can test
            // $data[0]->data->code
            // for "005"
            // OR
            // $data[0]->data->value
            // for "NICK USED";
            header('location:already_connected.php');
            die();
        }
        else
        {
            //die("data:".$data[0]->data->value);//print_r($data));

            // Something went wrong with the registration of the user on
the HM server
            if ($data[0]->data->value==0)
            {
                header('location:server_down.php');
                die();
            }

            //die("data:".$data[0]->data->value);//print_r($data));
            // Nothing, let's continue! Checks succeeded!
        }
        //die("ok");
    }



// Attention this is synchronous, so it may freeze the server ??
function send_command_to_APE($cmd)
{

     $base="local.ape-project.org";
     $port=":6969";

    $APEserver = "http://ape.".$base.$port."/?";;

    $context= stream_context_create(array(
    'http' => array(
        'timeout' => 5
        )
    )
    );

    $data =
@file_get_contents($APEserver.rawurlencode(json_encode($cmd)),0, $context);

    $data = json_decode($data);

    return $data;
}





2011/11/30 KhoaTA <kencal...@gmail.com>

> And one thing currently i have to have APE connect MySQL.
>
> That is authenticating user who connects to APE.
> The process is:
> - User connects to web server, web server will save sessionId in MySQL
> & return sessionId to user.
> - User then connects to APE along with sessionId, APE will check if
> the submitted sessionId is equal to sessionId in MySQL.
>
> Currently i can't find another way for authentication. And APE is
> having problem with MySQL now.
> Thanks for your support.
>
> --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to ape-project@googlegroups.com
> To unsubscribe from this group, send email to
> ape-project+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ape-project?hl=en
> ---
> APE Project (Ajax Push Engine)
> Official website : http://www.ape-project.org/
> Git Hub : http://github.com/APE-Project/
>

-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to ape-project@googlegroups.com
To unsubscribe from this group, send email to
ape-project+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to