4 Replies - 2031 Views - Last Post: 16 April 2011 - 09:25 AM

#1 Mitman   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 09-March 08

Detecting lightbox, fancybox, thickbox etc.

Posted 12 April 2011 - 06:05 PM

I have a page that we'll call page1. I want page1 to open another page, page2, in a lightbox type style. And only this way (not if the person tries to directly access it). Is there any way to detect whether page2 is being opened in lightbox or if it has just been directly accessed (like example.com/page2.php) instead going through page1.

My idea is to detect whether page2 is in a lightbox and then display the content. If its isn't redirect them to page1 and then open page2. Is there an easy/better way to do this?

By the way, I'm practicing on fancybox if that helps.

Is This A Good Question/Topic? 0
  • +

Replies To: Detecting lightbox, fancybox, thickbox etc.

#2 nightscream   User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 237
  • Joined: 04-December 08

Re: Detecting lightbox, fancybox, thickbox etc.

Posted 13 April 2011 - 05:52 PM

You should be able to fix this with php.

On the page2.php you can do something similar to
if(strpos($_SERVER['HTTP_REFERER'], 'page1.php') === false) die("Page not found");

// show stuff here


So if you put the url in your browser http_referer is empty and the page will return page not found
Was This Post Helpful? 1
  • +
  • -

#3 Mitman   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 09-March 08

Re: Detecting lightbox, fancybox, thickbox etc.

Posted 13 April 2011 - 08:07 PM

View Postnightscream, on 13 April 2011 - 07:52 PM, said:

You should be able to fix this with php.

On the page2.php you can do something similar to
if(strpos($_SERVER['HTTP_REFERER'], 'page1.php') === false) die("Page not found");

// show stuff here


So if you put the url in your browser http_referer is empty and the page will return page not found


So now i know i can use the if...else command (is this the best or is there something better) to redirect to page1.php. My question is how would i open page2.php if its based on the id in a href, which say is content?

And also, if its not a problem, could you explain what the above script is doing?
Was This Post Helpful? 0
  • +
  • -

#4 nightscream   User is offline

  • D.I.C Head

Reputation: 19
  • View blog
  • Posts: 237
  • Joined: 04-December 08

Re: Detecting lightbox, fancybox, thickbox etc.

Posted 14 April 2011 - 02:42 AM

with fancybox or any other you just have to say page2.php in href and it will open it in a box (Or don't you mean that?)

the $_SERVER['HTTP_REFERER'] logs where you come from. So i'm searching on google for your website and I find it. I click on the link http_referer will have http://google.be in it.
So if I come from http://yoursite.com/page1.php and click on the link. The http_referer will be http://yoursite.com/page1.php. Now strpos will search for the value page1.php inside HTTP_REFERER, if it does not exists === false it will show Page not found (you want to do header("Location: page1.php"); to redirect the user back.
In other words if the user did not click a link from page1.php they are not allowed to view the page.
if(strpos($_SERVER['HTTP_REFERER'], 'page1.php') === false) die("Page not found");

// show stuff here


Was This Post Helpful? 1
  • +
  • -

#5 Mitman   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 79
  • Joined: 09-March 08

Re: Detecting lightbox, fancybox, thickbox etc.

Posted 16 April 2011 - 09:25 AM

thank you! that makes a lot of sense. thanks for the help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1