Dynamic PHP Directory Reader with CKeditor

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
<script>
function processAjax(url) {
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = targetDiv;
try {
req.open("GET", url, true);
} catch (e) {
alert(e);
}
req.send(null);
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = targetDiv;
req.open("GET", url, true);
req.send();
}
}
return false;
}
function targetDiv() {
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
document.getElementById("myDivName").innerHTML = req.responseText;
// Tried to dynamically load textarea with no luck :-(
//document.frmload.editor1.value = req.responseText;
} else {
alert("Problem: " + req.statusText);
}
}
}
</script>
</head>
<body>
<table width="950">
<tr>
<td valign="top" style="border-right:solid 2px green;margin: 0 0 0 10px;padding:0 10px 0 0 ;">
<b>Choose File:</b><br />
<?php
$path = ".";
$narray=array();
$dir_handle = @opendir($path) or die("Unable to open $path");
//echo "Edit File:<br/>";
$i=0;
while($file = readdir($dir_handle))
{
if(is_dir($file))
{
continue;
}
else if($file != '.' && $file != '..')
{
//echo "<a href='$path/$file'>$file</a><br/>";
$narray[$i]=$file;
$i++;
}
}
sort($narray);
for($i=0; $i<sizeof($narray); $i++)
{
$filename = str_replace(".htm", "", $narray[$i]);
echo "<a onclick='return processAjax(this.href)' href=".chr(34).$narray[$i].chr(34).">".$filename."</a><br/>";
}
//closing the directory
closedir($dir_handle);
?>
</td>
<td valign="top" style="margin:0px;padding:0 0 0 10px;">
<!-- This <fieldset> holds the HTML that you will usually find in your pages. -->
<form id="frmload" method="post">
<textarea id="editor1" name="editor1"><p>Initial 2 value.</p></textarea>
<script type="text/javascript">CKEDITOR.replace( 'editor1' );</script>
<p><input type="submit" value="Submit"/></p>
</form>
<div id="myDivName"></div>
</td>
</tr>
</table>
</body>
</html>
Re: Newbie: Dynamic PHP Directory Reader with CKeditor
Re: Dynamic PHP Directory Reader with CKeditor