Page 1 of 1

How to pass variable from PHP to IFRAME

Posted: Thu Jan 23, 2003 5:34 am
by praveen
Dear List,
I'm using IFrames with PHP. I'ld like to pass the value of the variable to the IFRAME to show up. I'm actually trying to customize Liveeditor, I'ld like to put IFrame instead of Textarea (To get the WYSIWYG) functionality, but it's not passing the value to the IFRAME.

I'm also attaching the file, anybody can install and check.Please remember this is the liveeditor modified version.

Please find the line below in the file pasted below. I'm getting problem there.


//GETTING PROBLEM HERE, IT SOULD PASS THE $indlaesFilen VALUE TO THE JAVASCRIPT, BUT IT"S NOT PASSING.


It'll end with the comment
//UPTO HERE

Code: Select all

<?PHP 

##################################################
################### 
# PLEASE EDIT THE FOLLOWING VARIABLES: 
##################################################
################### 
include ("../conf.php"); 
# Choose a language file: 
$languageFile = "../liveeditor/english.php"; 

# Choose a username: 
$username = $user; 

# Choose a password: 
$password = $pass; 

# THERE'S NO NEED THE CHANGE THE FOLLOWING VARIABLES 
# UNLESS YOU REALLY WANT TO: 

# The frameset. I.e., if you write "100,*" here, the left frame will 
# be 100 pixels and the right frame will fill up the rest of the 
# browser window. 
$frameset = "1%,14%,*,1%"; 

# The height of the text area: 
$textareaRows = "17"; 

# The width of the text area: 
$textareaCols = "83"; 

# The text area font: 
$font = "helvetica"; 

# The text area font size: 
$fontSize = "10pt"; 

##################################################
################### 
# THAT'S IT! NO MORE EDITING NECESSARY. 
##################################################
################### 


require($languageFile); 



################################################# 
# Authentification 
################################################# 

if (!$PHP_AUTH_USER) { 
header("WWW-Authenticate: Basic realm="Yip Soft. Inc, Content editor""); 
header("HTTP/1.0 401 Unauthorized"); 
echo $s1; 
exit; 
} 
else { 
if ($PHP_AUTH_USER != $username || $PHP_AUTH_PW != $password) { 
echo $s1; 
exit; 
} 
} 



################################################# 
# Setting the start directory 
################################################# 

if (!$mappe) $mappe = $DOCUMENT_ROOT; 
//$mappe.="/templates"; 
$mappeEtNiveauOp = dirname($mappe); 

if (!ereg(dirname($DOCUMENT_ROOT), $mappe) || ereg("\.\.", $mappe)) { 
echo $s2; 
exit; 
} 
if ($fil) { 
if (!ereg(dirname($DOCUMENT_ROOT), $fil) || ereg("\.\.", $fil)) { 
echo $s2; 
exit; 
} 
} 


################################################# 
# Page header 
################################################# 

$sidehoved = "<html><head><title>Content editor</title> 
<style type=text/css><!-- 
body { background: white; font-family: helvetica; font-size: 10pt } 
a { color: black; text-decoration: none } 
--></style> 
</head> 
<body> 
"; 


################################################# 
# Frameset 
################################################# 

if (!$QUERY_STRING) { 
echo "<html><head><title>Content editor</title>\n"; 
echo "</head>\n"; 
echo "<frameset rows='1%,*,1%' border=0>"; 
echo "<Frame src=bg.html scrolling=no>"; 
echo "<frameset cols="$frameset" border=0>\n"; 
echo "<frame src=bg.html>"; 
echo "<frame src=$PHP_SELF?ramme=venstre name=venstre>\n"; 
echo "<frame src=$PHP_SELF?ramme=hoejre name=hoejre>\n"; 
echo "<frame src=bg.html>"; 
echo "</frameset><frame src=bg.html scrolling=no></frameset></html>\n"; 
} 


################################################# 
# Left frame 
################################################# 

if ($ramme == "venstre") { 
echo $sidehoved; 

$handle = opendir($mappe); 
while ($file = readdir($handle)) { 
# Making an array containing the files in the current directory: 
$filer[] = $file; 
} 
closedir($handle); 

# Sorting the files in alphabetical order: 
sort($filer); 

// echo "<b>$mappe</b><p>\n"; 

for ($i = 0; $i < sizeof($filer); $i++) { 
if ($filer[$i] != ".") { 
if ($filer[$i] == "..") { 
if (ereg(dirname($DOCUMENT_ROOT), $mappeEtNiveauOp)) { 
echo "<a 

href="$PHP_SELF?ramme=venstre&mappe=".urlencode($mappeEtNiveauOp).""><img src="images/mappe.gif" height=16 

width=16 border=0> ..</a><br>\n"; 
} 
} 
else { 
if (is_dir("$mappe/$filer[$i]")) { 
echo "<a 

href="$PHP_SELF?ramme=venstre&mappe=".urlencode("$mappe/$filer[$i]").""><img src="images/mappe.gif" height=16 width=16 

border=0> $filer[$i]</a><br>\n"; 
} 
else { 
echo "<a href="$PHP_SELF?ramme=hoejre&fil=".urlencode("$mappe/$filer[$i]")."" 

target="hoejre"><img src="images/fil.gif" height=16 width=16 border=0> $filer[$i]</a><br>\n"; 
} 
} 
} 
} 
} 



################################################# 
# Right frame 
################################################# 

if ($ramme == "hoejre") { 
if ($gem) { 
if (get_magic_quotes_gpc() == 1) $tekst = stripslashes($tekst); 

$fp = fopen($fil, "w"); 
fwrite($fp, $tekst); 
fclose($fp); 
echo htmlspecialchars($indlaesFilen); 

} 



echo $sidehoved; 



echo "<form action="$PHP_SELF?ramme=hoejre&fil=".urlencode($fil)."" method=post>\n"; 

?> 

<script language="JavaScript"> 

function document.onreadystatechange(){ 
tekst.document.designMode="On" 
setTimeout('SetText()',1000); 
} 
function cmdExec(cmd,opt) { 
if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;} 
idContent.document.execCommand(cmd,"",opt);idContent.focus(); 


} 
function setMode(bMode){ 
var sTmp; 
//isHTMLMode = bMode; 
//if (isHTMLMode){ 
//sTmp=tekst.document.body.innerHTML;tekst.document.body.innerText=sTmp; 
//} 
//else {sTmp=idContent.document.body.innerText;idContent.document.body.innerHTML=sTmp;} 
tekst.focus(); 
} 
//Form stuff 


function fninit() 
{ 
//alert("asdf"); 
for(i=0;i<document.all.length;i++) document.all(i).unselectable = "on"; 
//idContent.unselectable = "off"; 

} 
function Save() 
{ 
//if (isHTMLMode){alert("Please uncheck 'Edit HTML'");return;} 
//alert("Add code to submit the document to the database here."); 
//document.frmEditor.hidcontent.value=idContent.document.body.innerText; 
//alert(idContent.document.body.innerText); 
//document.frmEditor.submit(); 
} 
function SetText() 
{ 
fninit(); 

//tekst.document.body.innerText='<?php echo(htmlspecialchars($indlaesFilen));?>'; 
tekst.document.body.innerText='Praveen'; 
<?php 
//GETTING PROBLEM HERE, IT SOULD PASS THE $indlaesFilen VALUE TO THE JAVASCRIPT, BUT IT"S NOT PASSING. 
if ($fil) { 
global $indlaesFilen; 
$fp = fopen($fil, "r"); 
$indlaesFilen = fread($fp, filesize($fil)); 
fclose($fp); 

$xy=$indlaesFilen; 
?> 
tekst.document.body.innerText='<?php print($xy); ?>'; 
<?php 
} 
?> 

//UPTO HERE 
setMode(this.checked); 

} 
</script> 




<?php 

echo "<div style="font-family: $font; font-size: $fontSize">\n"; 
echo "<iframe name=tekst>"; 
/** 
if ($fil) { 
$fp = fopen($fil, "r"); 
$indlaesFilen = fread($fp, filesize($fil)); 
fclose($fp); 

echo htmlspecialchars($indlaesFilen); 
} 
**/ 
echo "</iframe><p>\n"; 
echo "</div>\n"; 

echo "<input type=submit name="gem" value="$s7"><br>\n"; 
echo "<input type=text name=fil value="$fil" size="$textareaCols">\n"; 

echo "</form>\n"; 



echo "</body></html>\n"; 
} 
?>

Posted: Thu Jan 23, 2003 5:49 am
by twigletmac
I don't know what version of PHP you are running, but it looks like this has been written for an older version (PHP 4.0.6 or less), it may not have any bearing on the problem but have a read of:
viewtopic.php?t=511
viewtopic.php?t=1030

Mac