<?
$bstand = $_GET['bstand'];
$edited = $_POST['edit'];
if (isset($edited)) {
$filename = 'test.txt';
$somecontent = "Voeg dit toe aan het bestand\n";
$data = fopen ($bstand, "w");
if (is_writable($bstand)) {
fwrite($data, $edited);
fclose($data);
ECHO "Het bestand $bstand is succesvol veranderd";
} else {
print "Het bestand $bstand is niet schrijfbaar";
}
}
else
{
if (isset($bstand)) {
$datas = fopen ($bstand, "r");
$data = fread ($datas, filesize ($bstand));
fclose ($datas);
ECHO "
<form method=\"post\" action=\"?page=". $page ."&bstand=" . $bstand . "&menu=" . $menu ."\">
<textarea cols=\"80\" rows=\"30\" name=\"edit\">
$data
</textarea>
<input type=\"submit\" value=\"wijzig\">
</form>
";
}
else
{
$handle=opendir('../data/');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<a href=\"?bstand=../data/" . $file . "\">$file</a><br>";
}
}
closedir($handle);
}
}
?>