Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Sir Osis of Liver - syyskuu 12, 2013, 05:04:18 IP

Otsikko: Access denied from link in popup
Kirjoitti: Sir Osis of Liver - syyskuu 12, 2013, 05:04:18 IP

Opening a popup from a button in main menu.  Text in popup contains direct link to member's Paid Subs section -



<a href="#" onClick="window.opener.document.location.href=\'http://xxxxxx.com/forum/index.php?action=profile;u=1;area=subscriptions;confirm\'; window.self.close();">Profile -> Paid Subscriptions</a> 



Link doesn't work, nothing happens, debug shows 'Access denied' error.

Popup contains button that opens 'Help' in same popup window.  'Help' contains same link, and it works. 

If I open popup with 'Help' as first page, link doesn't work.

Same result in IE and FF. 

It all works fine on my server.

Any ideas?

Otsikko: Re: Access denied from link in popup
Kirjoitti: mashby - syyskuu 12, 2013, 06:58:52 IP
Which member though? I see u=1 in that URL...
Otsikko: Re: Access denied from link in popup
Kirjoitti: Sir Osis of Liver - syyskuu 13, 2013, 02:01:15 IP

That link takes any registered member directly to Paid Subs page in their Profile.

Appears to be something server-side.  Links (any link) don't work in the page that opens when popup is launched.  I can fix it by launching the popup with a dummy file that just has a header redirect to the first page (making it second page), but not comfortable using a workaround on someone else's business site unless I understand the problem.

Otsikko: Re: Access denied from link in popup
Kirjoitti: All Colours Sam - syyskuu 13, 2013, 02:08:59 IP
Lainaus käyttäjältä: Krash. - syyskuu 13, 2013, 02:01:15 IP

That link takes any registered member directly to Paid Subs page in their Profile.

Nope, it would take whoever clicks on it to the paid subscription page of the user with ID 1

http://www.simplemachines.org/community/index.php?action=profile

http://www.simplemachines.org/community/index.php?action=profile;u=271166

http://www.simplemachines.org/community/index.php?action=profile;u=245528

Check out the differences, if there is a link with no u var been set SMF then will load whoever's ID whos viewing that page.

Each page in the profile page will check if the current user has the permission to be there.

In other words, just remove the u=1 from your url.
Otsikko: Re: Access denied from link in popup
Kirjoitti: Sir Osis of Liver - syyskuu 13, 2013, 02:21:40 IP

Yes, I know.  Was doing some tinkering and had changed the link for test purposes.  Correct link is $scripturl . '?action=profile;area=subscriptions',.  Link is not the problem, no url works from first page that loads in the popup.

Otsikko: Re: Access denied from link in popup
Kirjoitti: All Colours Sam - syyskuu 13, 2013, 02:40:48 IP
Using window.opener.document.location.href  gives me "window.opener" is not an object.

Maybe using a separate function: onclick="newWin()" ?

function newWin
{
  newWin = window.open(....);
newWin.opener.document.location.href = 'url';
}

As far as my JS skills goes, before using .opener you gotta use window.open first.
Otsikko: Re: Access denied from link in popup
Kirjoitti: Sir Osis of Liver - syyskuu 13, 2013, 09:35:17 IP

JS makes me (https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.thekrashsite.com%2Fpics%2Fhairpull1.gif&hash=d1684c7b73ef4c7cc773994cfce0795f18f1c1d9), but it works as is in four browsers (yes, even Opera), so I'll leave it alone. 

Otsikko: Re: Access denied from link in popup
Kirjoitti: Sir Osis of Liver - syyskuu 14, 2013, 03:36:24 IP

Don't know who checked it, but this problem is not resolved.  Still have no explanation why this is occurring, and would appreciate any help.

Otsikko: Re: Access denied from link in popup
Kirjoitti: All Colours Sam - syyskuu 14, 2013, 07:11:27 IP
It certainly wasn't me.

I tried to replicate your issue but I couldn't.

So, the issue is not the code to generate the pop up but the code that appears in the pop up?  perhaps the entire subscription page isn't suited to be loaded via JS.
Otsikko: Re: Access denied from link in popup
Kirjoitti: emanuele - syyskuu 14, 2013, 07:47:14 IP
TBH I don't really understand what you are trying to do...

The code you posted in the first message doesn't work in any browser I test, all of them don't know what to do with the "opener" part.
What exactly are trying to achieve?
Otsikko: Re: Access denied from link in popup
Kirjoitti: Sir Osis of Liver - syyskuu 16, 2013, 12:31:00 AP

<sigh>

I can't replicate it either, it all works fine on my test install.  What I'm doing is opening a popup that loads main.php, which contains links to member's Paid Subs order page in Profile, and a couple of buttons for other pages, one of which contains the same Paid Subs link.  The popup opens and loads the page properly, but the links do nothing, and debug shows 'Access denied'.  This only happens in the first file loaded.  If I click a button to the FAQ (help.php) the same link works fine.  If I open the popup with help.php as the first page, link doesn't work.  Doesn't matter what url I use (i.e., www.simplemachines.org), link doesn't work in first page loaded in the popup.

The workaround I'm using has the popup load a dummy page (main1.php) first, which contains a header redirect to main.php, nothing else.  The links work because main.php is now the second page loaded into the popup (main1.php is first).

Don't think it's the JS because that's client-side, so should have the same problem in same browser regardless of host.  Seems to be something server-side.