I'm trying to open a file in the browser and then edit and save the file. For some reason 4 out of 10 files won't show content, I don't get an error, so the file opened, though I don't see more than an empty textarea.
Here's the code I used to choose the page to edit, just click the image and it should show the editable content.
<ul>
<li><a class="list" href="home.php">Home</a> <?php if ($logged_in) { echo'<a href="?cpage=hinfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="wie.php">Wie zijn wij</a> <?php if ($logged_in) { echo'<a href="?cpage=winfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="brand.php">Branderij</a> <?php if ($logged_in) { echo'<a href="?cpage=binfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="csp.php">Computer Service Punt</a> <?php if ($logged_in) { echo'<a href="?cpage=cinfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="fiets.php">Fietsenmakerij</a> <?php if ($logged_in) { echo'<a href="?cpage=finfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="klus.php">Klussendienst</a> <?php if ($logged_in) { echo'<a href="?cpage=klinfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="dienst.php">Dienstverlening</a> <?php if ($logged_in) { echo'<a href="?cpage=dinfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="admin.php">Administratie</a> <?php if ($logged_in) { echo'<a href="?cpage=ainfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="kuip.php">Kuiperij</a> <?php if ($logged_in) { echo'<a href="?cpage=kinfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
<li><a class="list" href="contact.php">Contact</a> <?php if ($logged_in) { echo'<a href="?cpage=coinfo.php"><input type="image" src="images/editbutton.gif"></a>';}?></li>
</ul>
Then, this is what shows the content:
$fs = fopen( $file, "r+" ) or die("error when opening the file");
while (!feof($fs)) {
$contents .= fgets($fs);
}
fclose($fs);
?>
<form action="save.php" method="post">
<input type="hidden" name="file" value="<?php echo $file; ?>">
<textarea name="contents"><?php echo htmlspecialchars($contents); ?></textarea>
<input type="submit" value="Submit">
</form>
As said, just 4 out of 10 files won't show content, the other 6 work fine. The problemcases are cinfo, finfo, klinfo and kinfo. If I use this method to change the content from one of those files, the change get's shown when opening the file in a texteditor, however I can't get the file to show in my browser, and after changing the file, opening it again shows an empty textarea. Any help would be appreciated:)