From 74fdea8e08981ce410da7c76af9c068da3f3216a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Wed, 19 Mar 2014 03:38:03 +0100 Subject: [PATCH] =?UTF-8?q?Versi=C3=B3n=201.04=20-=20Separado=20el=20fiche?= =?UTF-8?q?ro=20de=20configuraci=C3=B3n=20del=20de=20versi=C3=B3n=20-=20Ar?= =?UTF-8?q?reglado=20que=20el=20men=C3=BA=20de=20la=20aplicaci=C3=B3n=20co?= =?UTF-8?q?lapse=20en=20resoluciones=20peque=C3=B1as=20-=20A=C3=B1adidos?= =?UTF-8?q?=20los=20ficheros=20de=20fuentes=20que=20se=20hab=C3=ADan=20cam?= =?UTF-8?q?biado=20-=20Arreglado=20el=20nombre=20del=20fichero=20FPDF.php?= =?UTF-8?q?=20para=20que=20coincida=20con=20el=20nombre=20de=20la=20clase?= =?UTF-8?q?=20-=20A=C3=B1adido=20el=20puerto=20a=20la=20configuraci=C3=B3n?= =?UTF-8?q?=20de=20MySQL=20y=20a=C3=B1adido=20el=20puerto=20y=20el=20servi?= =?UTF-8?q?dor=20como=20par=C3=A1metros=20a=20la=20copia=20de=20seguridad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AportaContenido.php | 6 +- Configuracion.php | 372 +++++++++++++++++------------------------- InformePDF.php | 2 +- Pdf_mysql_table.php | 2 +- inc/configuracion.inc | 1 + 5 files changed, 159 insertions(+), 224 deletions(-) diff --git a/AportaContenido.php b/AportaContenido.php index 99c57ce..652d12a 100644 --- a/AportaContenido.php +++ b/AportaContenido.php @@ -118,14 +118,14 @@ class AportaContenido { public function __call($metodo, $parametros) { switch ($metodo) { // Dependiendo del método invocado case 'titulo': // devolvemos el título - return APLICACION; + return PROGRAMA.VERSION; case 'usuario': if ($this->registrado) return "Usuario=$this->usuario"; else return ''; case 'fecha': return $this->fechaActual(); - case 'aplicacion': return APLICACION; + case 'aplicacion': return PROGRAMA.VERSION; case 'menu': // el menú if ($this->registrado) { return $this->miMenu->insertaMenu(); @@ -237,7 +237,7 @@ class AportaContenido { if (file_exists($archivo)) { unlink($archivo); } - $comando = escapeshellcmd(MYSQLDUMP . ' -u ' . USUARIO . ' --password=' . CLAVE . ' --result-file=' . $archivo_sql . ' ' . BASEDATOS); + $comando = escapeshellcmd(MYSQLDUMP . ' -h ' . SERVIDOR . ' -P ' . PUERTO . ' -u ' . USUARIO . ' --password=' . CLAVE . ' --result-file=' . $archivo_sql . ' ' . BASEDATOS); $comando2 = escapeshellcmd(GZIP . ' -9f ' . $archivo_sql); exec($comando); exec($comando2); diff --git a/Configuracion.php b/Configuracion.php index 577b3a5..c8d477e 100644 --- a/Configuracion.php +++ b/Configuracion.php @@ -1,231 +1,165 @@ . - * - */ - class Configuracion { - private $nombreCentro; - private $numFilas; - private $estilo; - private $servidor; - private $baseDatos; - private $usuario; - private $clave; - private $configuracion="inc/configuracion.inc"; - private $confNueva="inc/configuracion.new"; - private $confAnterior="inc/configuracion.ant"; - private $plantilla; - private $colorLateral; - private $colorFondo; - private $mysqldump; //comando mysqldump para la copia de seguridad - private $gzip; //comando gzip para comprimir la copia de seguridad - - public function ejecuta() - { - $fichero=file_get_contents($this->configuracion,FILE_TEXT); - $datos=explode("\n",$fichero); - $grabar=isset($_POST['servidor']); - if ($grabar) { - $fsalida=@fopen($this->confNueva,"wb"); - } - foreach($datos as $linea) { - if (stripos($linea,"DEFINE")!==false) { - $filtro=str_replace("'","",$linea); - list($clave,$valor)=explode(",",$filtro); - list($resto,$campo)=explode("(",$clave); - list($valor,$resto)=explode(")",$valor); - //$salida.="[$campo]=[$valor]
\n"; - switch ($campo) { - case 'CENTRO': - $this->nombreCentro=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['centro'],$linea); - $this->nombreCentro=$_POST['centro']; - } - break; - case 'NUMFILAS': - $this->numFilas=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['filas'],$linea); - $this->numFilas=$_POST['filas']; - } - break; - case 'ESTILO': - $this->estilo=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['estilo'],$linea); - $this->estilo=$_POST['estilo']; - } - break; - case 'PLANTILLA': - $this->plantilla=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['plantilla'],$linea); - $this->plantilla=$_POST['plantilla']; - } - break; - case 'SERVIDOR': - $this->servidor=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['servidor'],$linea); - $this->servidor=$_POST['servidor']; - } - break; - case 'BASEDATOS': - $this->baseDatos=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['baseDatos'],$linea); - $this->baseDatos=$_POST['baseDatos']; - } - break; - case 'USUARIO': - $this->usuario=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['usuario'],$linea); - $this->usuario=$_POST['usuario']; - } - break; - case 'CLAVE': - $this->clave=$valor; - if ($grabar) { - $linea=str_replace($valor, $_POST['clave'],$linea); - $this->clave=$_POST['clave']; - } - break; - case 'COLORLAT': - $valor = trim($valor); - $this->colorLateral = $valor; - if ($grabar) { - $linea=str_replace($valor,$_POST['colorLat'],$linea); - $this->colorLateral=$_POST['colorLat']; - } - break; - case 'COLORFON': - $valor = trim($valor); - $this->colorFondo = $valor; - if ($grabar) { - $linea=str_replace($valor,$_POST['colorFon'],$linea); - $this->colorFondo=$_POST['colorFon']; - } - break; - case 'MYSQLDUMP': - $valor = trim($valor); - $this->mysqldump = $valor; - if ($grabar) { - $linea=str_replace($valor,$_POST['mysqldump'],$linea); - $this->mysqldump=$_POST['mysqldump']; - } - break; - case 'GZIP': - $valor = trim($valor); - $this->gzip = $valor; - if ($grabar) { - $linea=str_replace($valor,$_POST['gzip'],$linea); - $this->gzip=$_POST['gzip']; - } - break; - } - } - if ($grabar) { - $registro=substr($linea,0,2)=="?>"?$linea:$linea."\n"; - fwrite($fsalida,$registro); - } - } - $salida.=$this->formulario(); - if ($grabar) { - //$salida.=''; - $salida.='

Configuración guardada correctamente

'; - fclose($fsalida); - //unlink($this->confAnterior); - rename($this->configuracion,$this->confAnterior); - rename($this->confNueva,$this->configuracion); - unlink($this->confAnterior); - } - return $salida; + +/** + * @package Inventario + * @copyright Copyright (c) 2008, Ricardo Montañana Gómez + * @license http://www.gnu.org/licenses/gpl-3.0.txt + * This file is part of Inventario. + * Inventario is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Inventario is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Inventario. If not, see . + * + */ +class Configuracion { + private $configuracion = "inc/configuracion.inc"; + private $confNueva = "inc/configuracion.new"; + private $confAnterior = "inc/configuracion.ant"; + private $datosConf; + //Campos del fichero de configuración que se van a editar. + private $lista = array('SERVIDOR', 'PUERTO', 'BASEDATOS', 'BASEDATOSTEST', 'USUARIO', 'CLAVE', 'CENTRO', 'NUMFILAS', 'ESTILO', 'PLANTILLA', 'COLORLAT', 'COLORFON', 'MYSQLDUMP', 'GZIP'); + private $campos; + + public function __construct() + { + $this->campos = implode(",", $this->lista); + } + + //Hecho público para poder efectuar los tests correspondientes. + public function obtieneFichero() + { + return file_get_contents($this->configuracion, FILE_TEXT); + } + + public function obtieneLista() + { + return $this->lista; + } + + public function obtieneDatos($linea, &$clave, &$valor) + { + $filtro = str_replace("'", "", $linea); + list($clave, $valor) = explode(",", $filtro); + list($resto, $campo) = explode("(", $clave); + list($valor, $resto) = explode(")", $valor); + list($resto, $clave) = explode("(", $clave); + $valor = trim($valor); + } + + public function ejecuta() { + $fichero = $this->obtieneFichero(); + $datos = explode("\n", $fichero); + $grabar = isset($_POST['SERVIDOR']); + if ($grabar) { + $fsalida = @fopen($this->confNueva, "wb"); } - private function formulario() - { - $coloresLateral = array( "Original" => "#C4FAEC", "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db", - "Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Morado" => "#6633FF", - "Rojo oscuro" => "#dc2127", "Púrpura" => "#dbadff", "Gris" => "#e1e1e1"); - $coloresFondo = array( "Verde" => "#7bd148", "Azul marino" => "#5484ed", "Azul" => "#a4bdfc", "Turquesa" => "#46d6db", - "Verde claro" => "#7ae7bf", "Verde oscuro" => "#51b749", "Amarillo" => "#fbd75b", "Naranja" => "#ffb878", "Rojo" => "#ff887c", - "Rojo oscuro" => "#dc2127", "Púrpura" => "#dbadff", "Gris" => "#e1e1e1", "Original" => '#F3FEC8'); - $personal=$this->estilo=="personal"?'selected':' '; - $bluecurve=$this->estilo=="bluecurve"?'selected':' '; - $cristal=$this->estilo=="cristal"?'selected':' '; - $normal=$this->plantilla=="normal"? 'selected':' '; - $bootstrap=$this->plantilla=="bootstrap" ? 'selected':' '; - $salida='
'; - //$salida.='

'; - $salida.='

'; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.=''; - $salida.='

'; - $salida.=''; - $salida.=""; - //$salida.="
fondo=[$this->colorFondo] lateral=[$this->colorLateral]
"; - return $salida; - } + return $salida; } + +} + ?> \ No newline at end of file diff --git a/InformePDF.php b/InformePDF.php index d6ad37d..b94088b 100644 --- a/InformePDF.php +++ b/InformePDF.php @@ -55,7 +55,7 @@ class InformePDF { //echo $def->Titulo.$def->Cabecera; $this->pdf->Open(); $this->pdf->setAuthor(AUTOR,true); - $creador = CENTRO . " " . APLICACION; + $creador = CENTRO . " " . PROGRAMA.VERSION; $this->pdf->setCreator(html_entity_decode($creador),true); $this->pdf->setSubject($this->def->Titulo,true); $this->pdf->setAutoPageBreak(true, 10); diff --git a/Pdf_mysql_table.php b/Pdf_mysql_table.php index a9d99a9..402a9e9 100644 --- a/Pdf_mysql_table.php +++ b/Pdf_mysql_table.php @@ -61,7 +61,7 @@ class Pdf_mysql_table extends Fpdf //Titulo $fecha=strftime("%d-%b-%Y %H:%M"); $this->SetFont('Arial','',8); - $this->Cell(0,4,html_entity_decode(CENTRO . " " . APLICACION,ENT_COMPAT | ENT_HTML401,'ISO-8859-1'),0,1,'L'); + $this->Cell(0,4,html_entity_decode(CENTRO . " " . PROGRAMA . VERSION,ENT_COMPAT | ENT_HTML401,'ISO-8859-1'),0,1,'L'); $this->SetFont('Arial','',18); $this->Cell(0,6,utf8_decode($this->titulo),0,1,'C'); $this->SetFont('Arial','',8); diff --git a/inc/configuracion.inc b/inc/configuracion.inc index c3c164b..ee26619 100644 --- a/inc/configuracion.inc +++ b/inc/configuracion.inc @@ -24,6 +24,7 @@ require_once 'version.inc'; define('SERVIDOR', 'localhost'); //Ubicación del servidor MySQL +define('PUERTO', '3306'); //Puerto donde se conecta a MySQL define('BASEDATOS', 'Inventario2'); //Nombre de la base de datos. define('BASEDATOSTEST', 'Inventario_test'); //Base de datos para los tests. define('USUARIO', 'test'); //Usuario con permisos de lectura/escritura en la base de datos
Preferencias
Nombre del Centro
Número de filas
Plantilla
Estilo
Color Lateral (bootstrap)
Color Fondo (bootstrap)
Base de datos
Servidor
Base de datos
Usuario
Clave
mysqldump
gzip