Good day to you all !!!
I've find an directory lister and from it i need when the user click on a file that it pass the value to another page, this one in a frame, witch would be a simple php file editor so that he/she could edit the selected file and save it.
Here is thecode use for the directory lister :
function directory($result) {
$handle=opendir(".");
while ($file = readdir($handle)) {
if ($file == "." || $file == "..") { } else { print "<a href=$file>$file</a><br>\n"; }
}
closedir($handle);
return $result;
}
?>
<b>Select the file you want to go to:</b>
<p>
<?
echo directory($result);
?>
Here is the code for the editor :
<?php
$file = "index.html";
if(isset($POST['text']))
{
if(get_magic_quotes_gpc())
{
$POST['text'] = stripslashes($POST['text']);
}
$handle = fopen($file, 'w') or die("Unable to open file for writing");
fwrite($handle, $POST['text']);
fclose($handle);
}
$text = "";
if(is_readable($file))
{
$text = file_get_contents($file);
}
?>
and in an textarea is :
<?php echo $text; ?>