Click to See Complete Forum and Search --> : Warning About Using Vi with Apache and PHP


jesusjr
03-22-2004, 01:38 PM
[I'm not sure if this has been addressed before]

Just a quick note:

Newer versions of VIM create temporary file buffers with a trailing ~ on the file name. This file is in many cases by default readable by the web browser.

For example: If you use vi to edit index.php, a file called index.php~ will be created. If someone types index.php~ into their web-browser, they will see your source code!!! These files are not automatically deleted by VIM.

How to Fix this:

The easiest way to fix this is to have Apache send *.php~ files to the PHP parser. You can do this by adding the following line to the .htaccess file in your root directory. (If you don't have an .htaccess file in that directory, just create one and add this line)

AddType application/x-httpd-php .php .php~

Note: You may wish to add other extensions such as .html depending on how your site is set up.

Hope this helps.

*

LordShryku
03-23-2004, 12:34 AM
A lot of text editors do this and the functionality can be turned off. It's just a backup mechanism in case you're "in Windows mode" and save your work every couple seconds so you don't lose your progress when the system crashes.

rebelo
03-23-2004, 03:17 AM
I have my vim configured so that temporary backup files are stores in ~/.vim/backups/ instead of in the current working directory to keep them all separate. Same goes for ~/.vim/swap/ for the swap files. This is a good way to have it setup.

Though it really shouldn't be that much of an issue because most people would be editing the files in a source directory (not in the live webroot) and then ftping or copying them to the appropriate web accessible directory.