Hi,

I am trying to integrate the javascript editor called edit area to my php application.
http://www.cdolivet.com/editarea/
I want to create an application where user can upload files, then those uploaded files' name will appear on the web page and if they click the file name. The javascript editor which is on the same page with the uploaded files's name will show the code inside the uploaded file. After that if the user edit something on the code inside the javascript editor, then click save button. The code changes will be saved to the file.

Right now, I am able to show the file to appear inside the javascript editor. However, I can't use the save button from the toolbar.
I don't why is it not working whether it is my javascript code or my php code.
So, I am sorry if I post this thread on the wrong group.

Below is my code

index.php
PHP Code:
//Javascript
print('
<script language="javascript" type="text/javascript" src="/editarea/edit_area/edit_area_loader.js"></script>
<script language="javascript" type="text/javascript">
editAreaLoader.init({
    id : "content"              // textarea id
    ,syntax: "c"                // syntax to be uses for highgliting
    ,start_highlight: true        // to display with highlight mode on start-up
    ,language:"en"
    ,toolbar: "save,| ,undo, redo, |, search, go_to_line"
    ,is_multiple_files:true
    ,allow_toggle:false
        ,allow_resize:false
    ,word_wrap:true
        ,replace_tab_by_spaces:4
        ,save_callback:"save_feature"
});

function save_feature(id, content)
{
    form1.content1.value=content;
    document.forms["form1"].submit();
    
}
</script>'
);

//for Directory
if ($handle opendir('.\\'.$folder.'\cfile\\')) 
{
    while (
false !== ($file readdir($handle))) 
    {
        if (
$file != ".." && $file != "."
        {    
    echo 
"<a href='?path=.&filename=$file'>$file</a><br />";
        }
    }
    
closedir($handle);
}

//EDITAREA
$path=$_REQUEST['path'];
$filename=$_REQUEST['filename'];
echo
'
<textarea name=content id=content style="height: 700px; width: 800px;">'

$script="edit";
if(
$filename!="scriptinclude.php")
    {
        if(
$script=="edit")
        {
            
//$lines = file("../$path/upload/$filename");
            //$lines = file("$path/upload/$filename");
            
$lines file($path."/".$_SESSION['folder']."/cfile/".$filename);
            foreach(
$lines as $line)
            {
                echo 
str_replace("</textarea>","<#textarea>",$line);
            }
        }
    else
        {
            
$contentstripslashes(str_replace("<#textarea>","</textarea>",$_REQUEST['content1']));
        }
    }
else
    {
    echo 
"Scriptinclude may not be edited";
    }
echo
'
</textarea>
<form name=form1 method=post action=scriptupdate.php>
<table>
<tr><td>
<textarea name=content1 id=content1 style="display:none;">
</textarea></td></tr>
</table>'
;
//<textarea name=content1 id=content1 style="height: 0px; width: 0px;">
//<textarea name=content1 id=content1 style="display:none;">
echo'
<input type=hidden name=path value='

echo 
$path;
echo
"'>";
echo
"<input type=hidden name=filename value='";
echo 
$filename;
echo 
"'>
</form>"
;
echo
"</td></tr></table>"
scriptinclude.php
PHP Code:
session_start();
if(
$script=="edit")
{
    
//$lines = file("../$path/upload/$filename");
    //$lines = file("$path/upload/$filename");
    
$lines file($path."/".$_SESSION['folder']."/cfile/".$filename);
    foreach(
$lines as $line)
    {
    echo 
str_replace("</textarea>","<#textarea>",$line);
    }
}
else
    {
    
$contentstripslashes(str_replace("<#textarea>","</textarea>",$_REQUEST['content1']));
    }
?> 
scriptupdate.php
PHP Code:
<?php
session_start
();
//chdir($_REQUEST['path']."/upload");
chdir($_REQUEST['path']."/".$_SESSION['folder']."/cfile");
$fp fopen($_REQUEST['filename'], 'w');
include 
"scriptinclude.php";
fwrite($fp$content);
fclose($fp);
//include 'vars.php';
header('Location: ../index.php');
The message that appear every time I open my web root and press the save button is
Notice: Undefined index: path
Notice: Undefined index: filename
<br />
<b>Warning</b>: file(/user_andrew/cfile/) [<a href='function.file'>function.file</a>]: failed to open stream: No such file or directory in <b>C:\Program Files\EasyPHP-5.3.9\www\index.php</b> on line <b>271</b><br />
<br />
<b>Warning</b>: Invalid argument supplied for foreach() in <b>C:\Program Files\EasyPHP-5.3.9\www\index.php</b> on line <b>272</b><br />
Line 271 and 272 is
$lines = file($path."/".$_SESSION['folder']."/cfile/".$filename);
foreach($lines as $line)
Right now, I only knew that these
Code:
$path=$_REQUEST['path'];
$filename=$_REQUEST['filename'];
for $filename the value is null. I really don't know why this is not working. Please help. Why does my code is not working?
Thanks in advance