this could work
at least after some little bughunting
and small modifications
instead of write to file you can append to existing data in file
by using $fp = ( $file, "ab" );
and add some error messages, too
/halojoy - did a rewriting of a script he has downloaded ( a file-editor )
<?php
if(isset($_POST["act"]) && $_POST["act"]=="save"){
if (isset($file) && ($file!="") ){
$fp = getFilePath($file);
if ($fd = @fopen($fp, "wb")) {
$data = trim($_POST["data"]);
$data = stripslashes($data); // Strips doubled backslashes
$data = str_replace("\r\n", "\n", $data); // Remove LF => UNIX format
// if ($fileformat == "dos") $data = str_replace("\n", "\r\n", $data); // Add LF => DOS format
@fwrite($fd, $data);
@fclose($fd);
echo htmlspecialchars($data);
echo "<br>File $file saved.";
}
}
}else{
$data = "enter your HTML code here";
echo "<table border=0 cellspacing=0 cellpadding=10>";
echo "<form action='' method=post name=editForm>";
echo "<input name=act type=hidden value=save>";
echo "<input name=file type=hidden value=\"$file\">";
echo "<tr>";
echo "<td colspan=3>";
echo "<textarea name=data cols=$editcols rows=$editrows>";
echo htmlspecialchars($data);
echo "</textarea>";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=3 align=center>";
echo "<input type=submit value=\"Save\">";
echo "</td>";
echo "</tr>";
echo "</form>";
echo "</table>";
}
exit;
?>