You need to forget about returning 0 or 1

What erick does is emulate what return 0 would do in the hook scope, which
is to send a generic error message/response. He manually sends this
response. Although he returns 0 or 1 after sending the response it doesn't
really does anything since it is inside the getContent callback. Once you
clear on that you should make his solution work for you.
On Jan 23, 2012 4:47 PM, "utan" <[email protected]> wrote:

> Ok, will do your suggestion,
> but to clarify how I am working on php side, I send the ip my php
> check if the ip exists in the database table banned if it is there,
> then the code returns 1 , and nothing for not match..
> so if the response from request.getContent i get a 1 then result != ""
> and run the inside code of if and return 0; if it has nothing then
> goes to the else and return all the other code...
> Let me know if I am totally wrong since my expertise its almost null.
>
> On Jan 23, 1:37 pm, Erick Romero <[email protected]> wrote:
> > Try
> >
> > request.getContent(function(result){
> >
> >         Ape.log('Result: "' + result + '"');
> >
> >         if(result == 0){
> >                 Ape.log('- Gandalf: You will not past..");
> >                 cmd.sendResponse('ERR', {'code': 1001, 'value':'User
> BANNED'});
> >                 return 0;
> >         }
> >         else {
> >                 Ape.log('- Frodo: Run away!!");
> >                 cmd.user.setProperty('name', params.name);
> >                 cmd.user.setProperty('ip', cmd.ip);
> >                 return 1;
> >         }
> >
> > }).bind(this);
> >
> > Modify your PHP file to output manually the result and make two test:
> >
> > First
> > <?php echo '0' ?>
> >
> > Second
> > <?php echo '1' ?>
> >
> > And let me know what your are getting in your APE log for each test.
> >
> > Note:
> > I don't know if you are missing the point, but in your function copied
> > below you are including
> >
> > if(result != ""){
> >
> > that means that php is sending something, so in good theory the
> > if-inside  logic should allow to past instead of send the sendResponse
> error
> >
> > On 01/23/2012 03:12 PM, utan wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Erick
> >
> > > I have it just like you suggested and still let me go all the way..
> >
> > > request.getContent(function(result){
> > >    if(result != ""){
> > >            Ape.log(result);
> > >            cmd.sendResponse('ERR', {'code': 1001, 'value':'User
> BANNED'});
> > >                    return 0;
> > >                    }else{
> > >            cmd.user.setProperty('name', params.name);
> > >            cmd.user.setProperty('ip', cmd.ip);
> >
> > >            return 1;
> > >                    }
> > >    }).bind(this);
> > > the only differences there is , is that your have a more recent build
> > > than me, I think I have 111 or something along those lines..
> > > I am frustrated..
>
> --
> You received this message because you are subscribed to the Google
> Groups "APE Project" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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