Jump to content

When saving via FTP, server briefly triggers "save as" for PHP file, shows code


Recommended Posts

I'm new to PHP and I'm worried about any security issues there might be.  When I noticed this I was very reluctant to use plain text passwords (such as the one needed to access the MySQL database).  I'm not sure what is causing this to happen so forgive me if I don't provide enough details ::)

 

Versions:

Ubuntu Server 10.04.1 LTS; Apache2; PHP Version 5.3.2-1ubuntu4.5

 

I use a program on my laptop to create a virtual drive for the files that are stored on my server.  It uses FTP to connect to the server and load/save files.  This is what happens when I edit my PHP files:

  • Make changes to PHP file
  • Save file (saves directly to server)
  • Reload PHP file in web browser on local machine
  • Browser shows "save as" dialog (only happens for a couple seconds, see below)

 

If I save the page and open it, I can read all the code in the file including whats between the <?php and ?> tags.  I have done this from two seperate computers.  One was connected to the local network, the other was on a different internet connection.  I got the same result when refreshing the page from both computers and was able to save and view the source.  However, it only happens when I reload the page immediately after saving.  If I wait a few seconds and then reload the page it loads like a normal PHP file.  I like PHP much better than CGI and do not want to go back to using perl just because of this.

Link to comment
Share on other sites

I've been picking at the issue for a bit and came up with some new information that might help resolve this issue.

 

I've noticed that when saving with the text editor I normally use (on the local machine), it deletes the file and creates a new one instead of just overwriting it.  I've tried a different text editor and the alternative editor did overwrite the file instead of deleting it and creating a new one.  Coincidentally, the browser stopped showing the "save as" dialog when reloading the PHP page right after a save with the alternative editor. 

 

I have also ran about 10-15 'ls -al' commands on the server within a 3-4 second period right after saving the file with both editors.  I've noticed that the file being saved is gone from the server for a few seconds when saving with my normal editor.  When saving with the alternative editor the file is always displayed with the 'ls -al' command.  I ran about 5 of these tests with each editor and got the same results.

Link to comment
Share on other sites

I have a PHP file located on my server opened for editing in my text editor that I am using on my local machine.  When I save the file to the server through the text editor (file saves directly to the server via FTP) and try to load the PHP file in any web browser (from any machine/internet connection) right after the save (within a few seconds) the browser asks me if I want to open it with a text editor or save it to the computer.  If I open the file or save it, I get access to the full source, including code between the php tags <?php ... ?>  However, if I wait more than 5 seconds after I save the PHP file with the text editor, the server returns the page to the browser like normal (PHP code executed and not displayed in the page).

 

I have noticed that this doesn't occur when I use a different text editor to change and save the PHP file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.