It's just basic file methods.
If you look here:
www.deathmonkeyz.com/tutorials in the AJAX section, I have a video on how to make a file editor with Javascript And PHP (It's called "First AJAX Application"). You can ignore the Javascript part if you wish, but the php will help.
These scripts are very unsecure at the moment however. As it allows anyone to create these files. But the code I have made only allows new files to be made, and cannot change existing files. And will only make a page defining two variables.