Posts: 256
Location: Auckland, New Zealand
|
You have a configuration file, which contains variables, however it sounds like you want to treat it as an ordinary file, where you can alter the information that's already saved in it, and then re-save the file with the new configuration.
It's possible, but how do you want to go about it?
I suggest the first thing you want to look at, is backing up the file you are about to change.
PHP Code:
copy('config.php', 'config.old.php'); // extension left as php so code is hidden
That way, you can revert back to the old one, if it fails.
This is where you decide on handling what to do with the file.
I think the best way for you would be to create a form that mimics the variables and values of this configuration file, and allow yourself to make the changes using the form. When you submit the form, the changes you want will be made.
If possible, maybe you can find another solution for this? I don't think allowing a configuration file to be writable a good thing, to me if you did need to do this, then you should probably plan for your site to go down for maintenance while this happens, because you might have some unexpected results messing with the configuration in a live site.
You can also just include at the end of your config.php file another file that contains similar variables/values that has your changes in it, that way, if it's at the end of the configuration file, it will overwrite any existing variables with your information.
Cheers,
MC
__________________
#------------------------------ signature---------------------------------------------------------------------------------#
Quote:
|
I am well recognised for what I don't do than what I do. Chores are just one of those things.
|
|