Hi there everyone,
I'm creating an HTML sandbox that utilizes a frame page. Top is HTML submission, bottom is output. I would like to ensure that the top and bottom pages are never accessed directly, since they both require variables that can't be set for obvious reasons if not called from the framed page.
main.php calls input.php and output.php. If input.php and output.php aren't in the frames of main.php, then I don't want them to be accessible.
I've tried $_SERVER vars, but , since it's called via a frameset, they carry their own server variables.
Javascript is not an option for anything like this.
Sessions! I think this is the trick, but it's not working for me. Here's what I'm trying:
main.php:
<?php
include("./includes/session.php");
$_SESSION['included'] = '1';
echo("
<FRAMESET ROWS='400,*'>
<FRAME NAME='input' SRC='./input.php'>
<FRAME NAME='output' SRC='./output.php'>
<NOFRAMES> ... </NOFRAMES>
</FRAMESET>
</html>");
UNSET($_SESSION['included']);
?>
input.php and output.php:
<?php
include("./includes/session.php");
if(!ISSET($_SESSION['included'])){
die("You can not access this file directly.");
}
echo("stuff");
?>
Since both files are being called after the session creation, I was sure that this would work, but I've either implemented it incorrectly or it's not possible to do it via this method. The inclusion of session.php is the start of the php session.
Am I going about this incorrectly? Did I just implement it incorrectly? Trying to echo the $_SESSION['included'] in input.php reveals that nothing is set. If I echo it in main.php however, it is present and accounted for.
Any help would be greatly appreciated.
thanks,
json