<?php
if (isset($_GET['edit'])){
if ($_GET['edit'] == 'save' && isset($_POST['save'])){
file_put_contents($_POST['file'], $_POST['content']);
header('Location: '.$_SERVER['PHP_SELF']);
} else {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>?edit=save">
<p><textarea rows="20" name="content" cols="80"><?php echo file_get_contents($_GET['edit']); ?></textarea></p>
<p><input type="hidden" name="file" value="<?php echo $_GET['edit']; ?>" /><input type="submit" value="Speichern" name="save"></p>
</form>
<?php
}
} else {
if (empty($_GET['dir'])){
$_GET['dir'] = '.';
}
foreach (scandir($_GET['dir']) as $verz){
if (is_dir($_GET['dir'].'/'.$verz)){
echo '<a href="?dir='.realpath($_GET['dir'].'/'.$verz).'">'.$verz.'</a><br />';
} else {
echo $verz.' <a href="?edit='.realpath($_GET['dir'].'/'.$verz).'">Edit</a><br />';
}
}
}
?>