Welcome Guest, Not a member yet? Register   Sign In
write a configuration file dynamically
#6

[eluser]sakcret[/eluser]
Thanks all, I found that only changes the value for the current request does not write the configuration file, I was confused because the manual says you can change set_item ('something', 'something'); currently use MAMP and sometimes I have trouble with it is handled by the compiled application, it was just a question I forgive you again with the framework, what I did was

Code:
function cambiaPeriodo() {
        $f1 = $this->input->post('fecha_inicio_r1');
        $f2 = $this->input->post('fecha_fin_r1');
        $nombre_fichero = 'application/config/configuracion_sistema.php';
        $contenido_config = $this->getContentfile($nombre_fichero);
        $fichero_texto = fopen($nombre_fichero, "w+");
        fclose($fichero_texto);
        $fecha_inicio = $this->config->item('fecha_periodo_inicio');
        $fecha_fin = $this->config->item('fecha_periodo_fin');
        $new_fecha_inicio = $this->utl_apecc->getSQL_date($f1);
        $new_fecha_fin = $this->utl_apecc->getSQL_date($f2);
        //obtener arreglos para buscar y rempazar variables
        $buscar_replace = array("['fecha_periodo_inicio']='$fecha_inicio';", "['fecha_periodo_fin']='$fecha_fin';");
        $replace = array("['fecha_periodo_inicio']='$new_fecha_inicio';", "['fecha_periodo_fin']='$new_fecha_fin';");
        //remplazar contenido
        $fp = fopen($nombre_fichero, "a");
        $nuevo_contenido = str_replace($buscar_replace, $replace, $contenido_config);
        fwrite($fp, $nuevo_contenido);
        fclose($fp);
    }

Sorry LonelyWolf stop by sometimes little things but ultimately affect greetings...


Messages In This Thread
write a configuration file dynamically - by El Forum - 08-13-2012, 08:50 AM
write a configuration file dynamically - by El Forum - 08-13-2012, 09:18 AM
write a configuration file dynamically - by El Forum - 08-13-2012, 09:19 AM
write a configuration file dynamically - by El Forum - 08-13-2012, 11:08 AM
write a configuration file dynamically - by El Forum - 08-13-2012, 12:21 PM
write a configuration file dynamically - by El Forum - 08-14-2012, 11:29 AM
write a configuration file dynamically - by El Forum - 08-14-2012, 11:52 AM
write a configuration file dynamically - by El Forum - 08-14-2012, 12:35 PM
write a configuration file dynamically - by El Forum - 08-20-2012, 11:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB