How to : Overwrite the config.php file. |
[eluser]Twisted1919[/eluser]
This is an additional method to keep your config updated from your admin backend using FTP. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); As you can see , the ftp_config() function allows us to retrieve an array and write its keys/values to our config.php file . Of course we need a new configuration file for our ftp connection , just create in the config folder and name it ftp.php: Code: $config['ftp_hostname'] = 'my host'; Let's say, in our config.php file we would have : Code: $config['sess_use_database'] = TRUE; And we would like to overwrite these values ,then we would do : Code: $data['sess_use_database'] = $this->input->post('sess_use_database',TRUE); It's not big deal at all , you have to remember two things : 1. Always the array keys of the array that you pass to the method must have the same name as the ones from config.php file . 2. I did not find any method to escape the single quotes and the backslashes, so i destroy them before i save the configuration file. Hope it helps
[eluser]Twisted1919[/eluser]
Oh , i forgot to say that i use ftp to overwrite the file because i hate the ideea that config.php will be always writeable by everyone and as far as i know is a security risk too.
[eluser]jedd[/eluser]
[quote author="Twisted1919" date="1256616093"] Oh , i forgot to say that i use ftp to overwrite the file because i hate the ideea that config.php will be always writeable by everyone and as far as i know is a security risk too. [/quote] Whereas FTP has such a shining history in the security realm. </sarcasm> I can't but help feel that while this is interesting code, it kind of misses the point of config files - shouldn't the kind of data that you are shuffling around here just be kept in a database?
[eluser]Twisted1919[/eluser]
Yes i know FTP is not the most secure protocol, but hey better than nothing right ? Quote:I can’t but help feel that while this is interesting code, it kind of misses the point of config files - shouldn’t the kind of data that you are shuffling around here just be kept in a database?Yes, but we can have an alternative , why not showing it ? (maybe it can be used if your config items number is too high ) . @Paulus - Yes , keep your config.php file chmoded to 0666, and use only the regexp from the library . |
Welcome Guest, Not a member yet? Register Sign In |