<?php ############################################################ # Copyright Daniel Doman 06.14.2003 # # Demo Script of PHP writing across frames using self referencing program # A little extra jazz to show each window in a different color etc... # # browser back history is goofy in frames, so we capture the orginal refer value and pass it around so we can always go home # # Contact Info: # # Daniel Doman # ddoman@panix.com # www.dandoman.com ############################################################
if(array_key_exists('cmd',$_GET)) $cmd = $_GET['cmd']; if(array_key_exists('refer',$_GET)) $refer = $_GET['refer']; if(array_key_exists('frame',$_GET)) $frame = $_GET['frame']; else $frame = false;
switch($frame) { case 'top': SayFrame("top", "middle", "lightblue"); break; case 'bottom': SayFrame("bottom", "top", "lightyellow"); break; case 'middle': SayFrame("middle", "bottom", "orange"); break; case 'framer'; default: SayFramer(""); break; } function SayFramer($cmd) { header('<html><head> <title>phpframe</title> </head>'); global $refer; // Need to maintain our original referer or we will go nuts from cycling through frames // so we capture it at start and pass it around so we can always go back to the start page $refer = $_SERVER['HTTP_REFERER']; print('<frameset rows="25%,25%,25%">'); print('<frame name="top" src="' . basename($_SERVER['PHP_SELF']) . '?frame=top&cmd='.$cmd. '&refer='.$refer.'">'); print('<frame name="middle" src="' . basename($_SERVER['PHP_SELF']) . '?frame=middle&cmd='.$cmd. '&refer='.$refer. '">'); print('<frame name="bottom" src="' . basename($_SERVER['PHP_SELF']) . '?frame=bottom&cmd='.$cmd. '&refer='.$refer. '">'); print('</frameset>'); print('</html>'); } function SayValue() { }
function SayFrame($Fname, $target, $color) {
// Need to maintain our original referer or we will go nuts from cycling through frames global $refer; global $cmd;
header('<html><head <base target="' . $Fname. '"> > <title>phpframe</title> </head>'); print('<body bgcolor="'. $color.'" ><h3><center>' . $Fname . '</center></h3><p>');
print('Value=' . $cmd . '<br>'); print('Selections will target:'.$target.'<br>'); for($i=0, $c='A'; $i <3; $i++, $c++) { print('<a href="' . basename($_SERVER['PHP_SELF']) . '?cmd='.$c. '&frame='.$target. '&refer='.$refer.'" target="'.$target.'" >'.$c.'</a><br>'); } // back to our orginal refer page, not the last frame load the target="_top" loads us out of the frame print('<br><a href="' . $refer . '" target="_top" >Back</a>'); print('</body></html>'); }
?>
|