| 
                                
                                    @@ 413-431 (lines=19) @@
                                 | 
                            
                                                            
                                    | 410 | 
                                     | 
                                         *  - password  | 
                                
                                                            
                                    | 411 | 
                                     | 
                                         *  - database  | 
                                
                                                            
                                    | 412 | 
                                     | 
                                         */  | 
                                
                                                            
                                    | 413 | 
                                     | 
                                        public function writeDatabaseConfig($data) { | 
                                
                                                            
                                    | 414 | 
                                     | 
                                            $configFile = APPPATH . 'config/database.php';  | 
                                
                                                            
                                    | 415 | 
                                     | 
                                     | 
                                
                                                            
                                    | 416 | 
                                     | 
                                            $this->load->helper('file'); | 
                                
                                                            
                                    | 417 | 
                                     | 
                                            $configContent = read_file($configFile);  | 
                                
                                                            
                                    | 418 | 
                                     | 
                                     | 
                                
                                                            
                                    | 419 | 
                                     | 
                                            $basePattern = "/db\['default'\]\['__KEY__'\] = '([a-zA-Z0-9\-\_]*)';/";  | 
                                
                                                            
                                    | 420 | 
                                     | 
                                            $baseReplacement = "db['default']['__KEY__'] = '__VALUE__';";  | 
                                
                                                            
                                    | 421 | 
                                     | 
                                     | 
                                
                                                            
                                    | 422 | 
                                     | 
                                            foreach ($data as $key => $value) { | 
                                
                                                            
                                    | 423 | 
                                     | 
                                                $keyPattern = str_replace('__KEY__', $key, $basePattern); | 
                                
                                                            
                                    | 424 | 
                                     | 
                                                $replacement = str_replace(['__KEY__', '__VALUE__'], [$key, $value], $baseReplacement);  | 
                                
                                                            
                                    | 425 | 
                                     | 
                                                $configContent = preg_replace($keyPattern, $replacement, $configContent);  | 
                                
                                                            
                                    | 426 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 427 | 
                                     | 
                                     | 
                                
                                                            
                                    | 428 | 
                                     | 
                                            if (!write_file($configFile, $configContent)) { | 
                                
                                                            
                                    | 429 | 
                                     | 
                                                die(lang('Error writing file config.php', 'install')); | 
                                
                                                            
                                    | 430 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 431 | 
                                     | 
                                        }  | 
                                
                                                            
                                    | 432 | 
                                     | 
                                     | 
                                
                                                            
                                    | 433 | 
                                     | 
                                        /**  | 
                                
                                                            
                                    | 434 | 
                                     | 
                                         * @param bool $result  | 
                                
                                                                                
                                 | 
                                
                                    @@ 473-491 (lines=19) @@
                                 | 
                            
                                                            
                                    | 470 | 
                                     | 
                                            return $result;  | 
                                
                                                            
                                    | 471 | 
                                     | 
                                        }  | 
                                
                                                            
                                    | 472 | 
                                     | 
                                     | 
                                
                                                            
                                    | 473 | 
                                     | 
                                        public function writeCmsConfig($data) { | 
                                
                                                            
                                    | 474 | 
                                     | 
                                            $configFile = APPPATH . 'config/cms.php';  | 
                                
                                                            
                                    | 475 | 
                                     | 
                                     | 
                                
                                                            
                                    | 476 | 
                                     | 
                                            $this->load->helper('file'); | 
                                
                                                            
                                    | 477 | 
                                     | 
                                            $configContent = read_file($configFile);  | 
                                
                                                            
                                    | 478 | 
                                     | 
                                     | 
                                
                                                            
                                    | 479 | 
                                     | 
                                            $basePattern = "/config\[[\'\"]{1}__KEY__[\'\"]{1}\][\s]*=[\s]*([a-zA-Z0-9\-\_]*);/"; | 
                                
                                                            
                                    | 480 | 
                                     | 
                                            $baseReplacement = "config['__KEY__'] = __VALUE__;";  | 
                                
                                                            
                                    | 481 | 
                                     | 
                                     | 
                                
                                                            
                                    | 482 | 
                                     | 
                                            foreach ($data as $key => $value) { | 
                                
                                                            
                                    | 483 | 
                                     | 
                                                $keyPattern = str_replace('__KEY__', $key, $basePattern); | 
                                
                                                            
                                    | 484 | 
                                     | 
                                                $replacement = str_replace(['__KEY__', '__VALUE__'], [$key, $value], $baseReplacement);  | 
                                
                                                            
                                    | 485 | 
                                     | 
                                                $configContent = preg_replace($keyPattern, $replacement, $configContent);  | 
                                
                                                            
                                    | 486 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 487 | 
                                     | 
                                     | 
                                
                                                            
                                    | 488 | 
                                     | 
                                            if (!file_put_contents($configFile, $configContent)) { | 
                                
                                                            
                                    | 489 | 
                                     | 
                                                die(lang('Error writing file config.php', 'install')); | 
                                
                                                            
                                    | 490 | 
                                     | 
                                            }  | 
                                
                                                            
                                    | 491 | 
                                     | 
                                        }  | 
                                
                                                            
                                    | 492 | 
                                     | 
                                     | 
                                
                                                            
                                    | 493 | 
                                     | 
                                        public function change_language() { | 
                                
                                                            
                                    | 494 | 
                                     | 
                                            $language = $this->input->post('language'); |