Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8304711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:55:12+00:00 2026-06-08T17:55:12+00:00

I’m working on a little experiment here. I’ve got a test file that I

  • 0

I’m working on a little experiment here. I’ve got a test file that I use to run some code without having to actually log into my app.

At any rate, I had a thought today that I could potentially make the page self-editing and make it quicker for me to do certain menial tasks as I wouldn’t even need to open up a text editor for them.

It’s mostly working as it sits, but I’m getting a weird thing; I’m hoping either someone just happens to have experience with or can shed some light on.

I won’t post the code for the entire file, just the relevant stuff. Here’s the basic idea:

index.php:

<?php
if(isset($_POST['file'])) {
  // rewrite ourself
  $test_page = fopen('index.php', 'w');
  fwrite($test_page, $_POST['file']);
  fclose($test_page);
  header('Refresh: 0; ' . $_SERVER['PHP_SELF']);
  exit();
  die(); // we should never get this far...
}
?>
<?php <!-- All the tester stuff goes here --> ?>
<?php <!-- Nothing fancy just a bunch of function calls --> ?>
<!doctype html>
<html lang="en">
  <head>
  </head>
  <body>
    <div>
      <!-- a dump of the functions called in the tester area -->
    </div>
    <div>
      <form method='post'>
        <textarea name='file'>
<?php
$self = fopen('index.php', 'r');
while(!feof($self)) {
  echo fgets($self);
}
fclose($self);
?>
        </textarea>
        <input type="submit" value="Edit/Refresh">
      </form>
    </div>
  </body>
</html>

Now everything is working just great, except that the last 5 HTML tags are not being written to the file; or more accurate, the last 5 HTML tags are not being written into the textarea So when it comes time to save, after the submit, they obviously are not being appended. My theory so far is that once the tag is output by PHP, it obviously closes the text area… so I need to find a way to get that closing tag inside the textarea. I verified this by viewing the source of the page, so I think it’s correct.

So I think I just need a way to ‘escape’ them…

I know it’s not a good thing in terms of security, but this is just a local page that I use (it’s not available to anyone except the person sitting at my computer). So we don’t need to discuss the security issues it obviously may have…

All thoughts appreciated! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:55:13+00:00Added an answer on June 8, 2026 at 5:55 pm

    The easiest way to solve your problem would be to replace:

    echo fgets($self);
    

    with:

    echo htmlspecialchars(fgets($self));
    

    That way you still see the special characters in your text box but they will not be rendered as html.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.