chrisfane Posted July 30, 2007 Share Posted July 30, 2007 im in the process of creating a method to allow the user to change the config file currently in use. i have created an html form with a dropdown menu, which passes the filename of the new config file forward to the action page. i have the following in a text file called settings.conf <?php $confname="config1.conf"; $sqlhost="10.165.250.250"; // add the Automation db Server here. $username="webstats"; //username for Automation db server $dbpass=""; //password for Automation db server //variables which shouldnt be modified $vers="V 1.4"; // version number, dont change this. ?> and im planning to alter the value of $confname, to config2.conf etc. i cna successfully process the text using an str_replace () command, when the contents of the file is sent as a form post, but i would like to cut that intermediate out, and read directly from the file. so im looking to ... read file in ... run contents through str_replace ($confname , $newconf , $text) output new config file to settings.conf with ammendments made. ive tried searching through the forum but havent found anything particularly relevant, if anyone could give me some advice, it would be most appreciated. Quote Link to comment Share on other sites More sharing options...
trq Posted July 30, 2007 Share Posted July 30, 2007 Youv'e allready outlined the steps required. All you need do is impliment them. Read the file into an array using file, loop through the array and replace what you need, then write the file back again using fwrite. If you get stuck... post some code. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.