[eluser]Pascal Kriete[/eluser]
I don't know about rewrite, but an idea that I'll be using in an installer I have to write, is to put default config files in another folder. In those files, you change your settings to something unique.
Then, for the rewrite, you grab that file, do a str_replace on it and plop it down in the proper place.
Example:
Base_db file (application/extras/base_db.php):
Code:
//Truncated for this example
$db['default']['username'] = "__DB_USERNAME__";
$db['default']['password'] = "__DB_PASSWORD__";
// Truncated again
Now when you save the settings you do this:
Code:
//CI 1.6.2 Compat Helper (need file_put_contents)
$this->load->helper('compatibility');
// The new stuff we want - usually user input
$uname = 'aardvark';
$pword = 'iheartants';
// Grab the default file
$file_path = APPPATH.'extras/base_db.php';
$file = file_get_contents($file_path);
// Change the values
$file = str_replace(array('__DB_USERNAME__', '__DB_PASSWORD__'), array($uname, $pword), $file);
// Put it in the proper spot
$config_path = APPPATH.'config/database.php';
file_put_contents($config_path, $file);