Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-07-2005, 10:36 AM   PM User | #1
odtufatih
New Coder

 
Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
odtufatih is an unknown quantity at this point
How can I avoid an iframe to be called directly?

I have an iframe in the middle of my site, and I dont want in anyway someone to directly address that iframe..

How can this be possible??

An idea may be passing a control variable from the main page to the iframe but someone still can open the iframe with including that variable at the end of the url..
odtufatih is offline   Reply With Quote
Old 06-07-2005, 10:50 AM   PM User | #2
mrruben5
Regular Coder

 
Join Date: Nov 2004
Location: The Netherlands
Posts: 551
Thanks: 0
Thanked 0 Times in 0 Posts
mrruben5 is an unknown quantity at this point
Use authentication with php or use .htacces for this.

Here's the php way.
Or another easy one with sessions.
__________________
CATdude about IE6: "All your box-model are belong to us"
mrruben5 is offline   Reply With Quote
Old 06-07-2005, 11:23 AM   PM User | #3
delinear
Regular Coder

 
Join Date: Feb 2005
Location: West Midlands, UK
Posts: 623
Thanks: 0
Thanked 0 Times in 0 Posts
delinear is an unknown quantity at this point
You could try something like this at the top of your iframe file:
PHP Code:
$mydomain 'yourdomain.com';
if(
strpos($_SERVER['HTTP_HOST'], $mydomain) === FALSE) {
    
header('Location: http://www.yourdomain.com');

The only problem is, because it's an iframe I'm not sure if $_SERVER will be populated with your server data or the data of the server belonging to the person linking it but you can test that pretty simply.

If it does cause a problem you could probably solve it by using css overflow to create a virtual iframe and including the file instead (I'm pretty sure an included file gets the server data of the calling page, not it's own server data), but if it gets to that point you may as well look at authentication as an easier solution.
__________________
~ Bazzy
delinear is offline   Reply With Quote
Old 06-07-2005, 11:49 AM   PM User | #4
odtufatih
New Coder

 
Join Date: Apr 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
odtufatih is an unknown quantity at this point
I think I will set up a session variable in the page calling the frame and then check that variable inside the frame..Seems an easy solution, thanks for your help
odtufatih is offline   Reply With Quote
Old 06-07-2005, 03:56 PM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,752
Thanks: 4
Thanked 2,468 Times in 2,437 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Sessions are always the best route when passing data from page to page in your site. That includes blocking out things that can only be included or added to your pages. Go with that route, watch your session settings though, and test it with your cookies off (use_trans_sid is off by default in php.ini, which auto-appends your links).
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 AM.


Advertisement
Log in to turn off these ads.