Please tell me if I can simplify or make this more 'graceful'. This script can sit anywhere on a site, probably best to have it at the root, then you just enter 'folder/file.php' to edit it. Works with any filetype, but has the advantage of highlighting for PHP.
<html>
<head>
<title>Page Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p> </p>
<?php if (!$_POST)
{ ?>
<form action="<?php echo $PHP_SELF; ?>" method="post" name="pickpage" id="pickpage">
Enter target URL
<input name="url" type="text" id="url" size="80" maxlength="80">
<input name="getpage" type="submit" id="getpage" value="Submit">
</form>
<?php }
elseif ($_POST['getpage'] == 'Submit')
{
$src = file_get_contents($_POST['url']);
$disp = htmlentities($src);
?>
<form action="<?php echo $PHP_SELF; ?>" method="post" name="preview" id="preview">
<p>
<textarea name="source" cols="120" rows="20" wrap="OFF" id="textarea"><?php echo $disp; ?></textarea>
</p>
<p>
<input name="url" type="hidden" id="url" value="<?php echo $_POST['url']; ?>">
<input type="reset" name="Reset" value="Reset">
<input name="preview" type="submit" id="preview" value="Preview Code">
</p>
</form>
<?php }
elseif($_POST['preview'])
{
$source = stripslashes($_POST['source']);
highlight_string($source); ?>
<p>Save changes?</p>
<form action="<?php echo $PHP_SELF; ?>" method="post" name="save" id="save">
<input name="url" type="hidden" id="url" value="<?php echo $_POST['url']; ?>">
<input name="savethis" type="hidden" id="savethis" value="<?php echo htmlentities($source); ?>">
<input name="save" type="submit" id="save" value="Save">
</form>
<?php }
elseif ($_POST['save'])
{
$newsrc = html_entity_decode(stripslashes($_POST['savethis']));
$fp = fopen($_POST['url'], 'w');
fwrite($fp, $newsrc);
fclose($fp); ?>
<p>New page as shown. <a href="editor.php">Back to Editor</a></p>
<?php highlight_file($_POST['url']);
} ?>
</body>
</html>