0

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:)

rags
  • 2,580
  • 19
  • 37
Vamps
  • 167
  • 1
  • 5
  • Who are the owners of those files and what are the permissions? – Sijmen Mulder Jul 13 '13 at 08:23
  • I own all files and am able to do everything I want with them. I can change all files, though I can't view the original content of 4 of the files with this specific method (can't figure out why), so I have to copy/paste the original content if I want to keep all, or part of the original content. If I don't copy/paste I just overwrite the existing file. – Vamps Jul 22 '13 at 12:34

1 Answers1

0

Apparantly it was a problem with the encoding of the files, as long as a file contained something like ï or ë orso, it wouldn't show content.

Vamps
  • 167
  • 1
  • 5