View Single Post
  #3 (permalink)  
Old 07-17-03, 08:39 AM
antoshka antoshka is offline
New Member
 
Join Date: Jul 2003
Location: USA
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
you want to create a script that will allow people to edit PHP files in their browser window?

there's 2 parts to it...

1. create a script that will load the php file and allow user to edit it.
PHP Code:

<?php

$file 
"/home/dir/file.php";
$fs fopen$file"a+" ) or die("error when opening the file");

while (!
feof($fs)) {
   
$contents .= fgets($fs1024);
}

fclose($fs);
?>

<html>
<form action="save.php" method="post">
<input type=hidden name="file" value="<?php echo $file?>">
<textarea name="contents"><?php echo htmlspecialchars($contents); ?></textarea>
</form>
</html>
2. create a script that will save the file once user done editing it.
PHP Code:

<?php

$fs 
fopen$_POST["file"], "a+" ) or die("error when opening the file");
fwrite($fs$_POST["contents"]);
fclose();
?>
this code might have bugs... it's very basic too.
__________________
RouTHost.com
PHP MySQL Perl SSI e-commerce
plans start at $3.95!
Reply With Quote