Is there a way I can use php to automatically add data to a certain part of a txt file?
Here's the scenario:
Its for an online game server.
I have an INI file on my home pc. Im using apache/php server (apache2triad) on a WinXP machine
I have an upload form that uploads files into certain directories on my harddrive. The files that can be uploaded are for user made add-ons to the game. This upload form allows them to add their files to the game system folder and use them ingame without any need for manual file moving on my part.
and it works great! BUT...... with some files, a new line needs to be added to the INI file. I can manually edit/save the file via php right now, but I certainly don't want to give everyone access to this file. So I want a way that users can enter a command line thats needed, and have it saved to the INI file behind the scenes with PHP.
What I need to know is : How do I set the php to write under a certain header in the INI file? for example: my.ini file:
[level.info]
blah1=x
blah2=y
blah3=z
[Game.info]
test1=hello
test2=thanks
test3=failed
[garbage.code]
color1=red
color2=green
I want the data to always write under the [Game.info] header and not at the end or beginning.
WORST CASE! I can actually change the file around to work if php can "append" the file at the end of the file. I can just rearrange the headers I guess.
Help on either of these 2 ways would be great! thanks.