Confirm_box doesn't works as spected

Discussion forum for MOD Writers regarding MOD Development.
Locked
tomynabo
Registered User
Posts: 45
Joined: Wed Feb 18, 2009 8:25 am

Confirm_box doesn't works as spected

Post by tomynabo » Mon Feb 22, 2010 12:14 pm

Hi people!

I have the next piece of code in a custom script

Code: Select all

if (!confirm_box(true)) {
    //action if no
} else {
    //action if yes
}
Phpbb is instaled into a server called iforodein1, and the path to the script is located in includes/acp/acp_suscribe.php so the complete URL the the script is the next:

Code: Select all

http://iforodein1.server.com/forum/includes/acp/acp_suscripbe.php
Using a inverse proxy, a user can access to the forum via http://www.server.com/forum/ and to the script using this url:

Code: Select all

http://www.server.com/forum/includes/acp/acp_suscripbe.php
The forum works well with the inverse proxy, except for the confirmation box (And probably, I tink, all the confirm boxes used trough the forum) it seems like "No" is alway pressed.

Any idea?? Thanks!

User avatar
ric323
Former Team Member
Posts: 22909
Joined: Tue Feb 06, 2007 12:33 am
Location: Melbourne, Australia
Name: Ric
Contact:

Re: Confirm_box doesn't works as spected

Post by ric323 » Mon Feb 22, 2010 12:16 pm

-- moved from Support to "MOD Writers Discussion".
The Knowledge Base contains solutions to many common problems!
How to fix "Doesn't have a default value" and "Incorrect string value: xxx for column 'post_text' " errors.
How to do a clean re-install of the latest phpBB3 version.
Problems with permissions? Read phpBB3 Permissions

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Confirm_box doesn't works as spected

Post by m157y » Mon Feb 22, 2010 12:24 pm

Firstly, check confirm boxes on default phpbb`s pages. So we'll sure that your opinion true or false.
i'm about it:
The forum works well with the inverse proxy, except for the confirmation box (And probably, I tink, all the confirm boxes used trough the forum) it seems like "No" is alway pressed.
Secondly, why you don't use this?

Code: Select all

if (confirm_box(true))
{
    //action if yes
    trigger_error($message);
}
// action if no
And finally... did you called confirm_box(false, $lang, $hidden_fields) before? Because confirm_box() generates some hidden confirm fields and w/o confirm_box(false) it'll be always parsed like 'no' pressed.
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

tomynabo
Registered User
Posts: 45
Joined: Wed Feb 18, 2009 8:25 am

Re: Confirm_box doesn't works as spected

Post by tomynabo » Mon Feb 22, 2010 12:38 pm

The "complete" code is that

Code: Select all

    if (!confirm_box(true)) {
        confirm_box(false, '$lang'', $hidden_fields);
        //action is No
    } else {
        //action if yes
    }
Using a no "proxyed" petition it works fine...

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Confirm_box doesn't works as spected

Post by m157y » Mon Feb 22, 2010 12:59 pm

Okay, my ideas. You're using mode or something like this at parser on 'yes' button press? Possible you forgot to add it at hidden fields? because your "complete" code looks right, possible error at really complete code.
P.S.
and i think that it'll be better :)

Code: Select all

    if (confirm_box(true)) {
        //action is yes
    }
    //action if not
    confirm_box(false, $lang, $hidden_fields);
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

tomynabo
Registered User
Posts: 45
Joined: Wed Feb 18, 2009 8:25 am

Re: Confirm_box doesn't works as spected

Post by tomynabo » Tue Feb 23, 2010 7:50 am

Thanks for you help... unfortunately it doesn't work either. I don't know what's wrong with this, in our pre-production environment works fine.

I'm going to keep trying to make it work...

EDIT: I noticed that other confirm boxes, like the shown when yo're trying to clean de admin/mod log doesn't work with the Inverse proxy configuration...

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Confirm_box doesn't works as spected

Post by m157y » Tue Feb 23, 2010 12:24 pm

Did you have any changes at adm/index.php or something non-standart for phpbb at non-worked admin files? Because as i think problem is non catchable $_POST array.
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

tomynabo
Registered User
Posts: 45
Joined: Wed Feb 18, 2009 8:25 am

Re: Confirm_box doesn't works as spected

Post by tomynabo » Tue Feb 23, 2010 1:33 pm

I've dicover that in this piece of code:

Code: Select all

if ($user_id != $user->data['user_id'] || $session_id != $user->session_id || !$confirm_key || !$user->data['user_last_confirm_key'] || $confirm_key != $user->data['user_last_confirm_key'])
{
                        return false;
}
This condition is true

Code: Select all

$session_id != $user->session_id
I don't understand why... adm/index.php has not been modified. But as I said, the confirm box woks well when accesing directly to the server:

Code: Select all

http://forum.server.com/includes/acp/acp_subscrbe.php <- Woks fine
But using the "proxyed" UTL it doesn't:

Code: Select all

http://www.server.com/includes/acp/acp_subscrbe.php <- Doesn't work
Sorry for my english :roll:

Any suggestions??

User avatar
m157y
Registered User
Posts: 482
Joined: Mon Apr 30, 2007 9:39 am
Location: Russia, Moscow, Khimki
Contact:

Re: Confirm_box doesn't works as spected

Post by m157y » Tue Feb 23, 2010 4:05 pm

Code: Select all

$session_id != $user->session_id
This condition describes that sess hidden field was not catched from confirm dialog which is generated by confirm_box() or session_id doesn't available from $user class and finally it can means, that on your subdomain(or main domain) you have troubles with sessions. Try to add something like this:

Code: Select all

echo $session_id . '<br />' . $user->session_id;
before this check

Code: Select all

		if ($user_id != $user->data['user_id'] || $session_id != $user->session_id || !$confirm_key || !$user->data['user_last_confirm_key'] || $confirm_key != $user->data['user_last_confirm_key'])
And look have you different session_ids or doesn't have one of them.
Then we'll think about the problem.
m157y aka Misty
NO SUPPORT VIA PM
KarmaMOD for phpBB 3.0.x | bbAJAX
Follow me on twitter

tomynabo
Registered User
Posts: 45
Joined: Wed Feb 18, 2009 8:25 am

Re: Confirm_box doesn't works as spected

Post by tomynabo » Wed Feb 24, 2010 7:12 am

m157y wrote:

Code: Select all

echo $session_id . '<br />' . $user->session_id;
before this check
That's how I discovered the problem... $session_id and $user->session_id are set. but the values are completely different

Locked

Return to “[3.0.x] MOD Writers Discussion”

cron