protected function clonar_schema_windows($schema_viejo, $schema_nuevo, $profile, $base, $user, $pass, $port) { $temp_dir = $this->proyecto->get_dir() . '/temp'; $salida = toba_manejador_archivos::path_a_windows($temp_dir . '/dump.sql'); $bat = "\n\t\t\t@echo off\n\t\t\tSET PGUSER={$user}\n\t\t\tSET PGPASSWORD={$pass}\n\t\t\tpg_dump -h {$profile} -p {$port} --inserts --no-owner -x -n {$schema_viejo} {$base} -f {$salida}\t\t\t\t\n\t\t\tpsql -h {$profile} -p {$port} -c \"ALTER SCHEMA {$schema_viejo} RENAME TO {$schema_nuevo}\" {$base}\n\t\t\tpsql -h {$profile} -d {$base} -p {$port} -f {$salida}\n\t\t"; $bat_file = $temp_dir . '/clonar_schema.bat'; file_put_contents($bat_file, $bat); system('cmd /c "' . $bat_file . '"'); unlink($bat_file); unlink($salida); }
/** * Utiliza una llamada al sist. operativo para que abra el archivo en un edtiro del sist. de ventanas del servidor */ function abrir() { $cmd = toba::instalacion()->get_editor_php(); if (strlen($cmd) == 0) { throw new toba_error_def("No se encuentra definido el editor por defecto a utilizar en la instalación"); } if (toba_manejador_archivos::es_windows()) { $archivo = toba_manejador_archivos::path_a_windows($this->nombre); $com = "{$cmd} {$archivo}"; toba::logger()->debug("Intentando abrir archivo con comando: '{$com}'"); exec($com); } else { $archivo = toba_manejador_archivos::path_a_unix($this->nombre); $archivo = str_replace(" ", "\\ ", $archivo); $com = "{$cmd} {$archivo}"; toba::logger()->debug("Intentando abrir archivo con comando: '{$com}'"); $fp = popen($com . ' 2>&1', 'r'); stream_set_blocking($fp, 0); sleep(1); $salida = fgets($fp, 2096); pclose($fp); if ($salida != '') { throw new toba_error("Intentando abrir archivo con comando: '{$com}'<br><br>Mensaje de error:<br>" . $salida); } } }