From 33d8648effa91cc731dd413d7aacb73cdbcd82b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Tue, 1 Apr 2014 01:54:58 +0200 Subject: [PATCH] =?UTF-8?q?Primer=20paso=20del=20programa=20de=20instalaci?= =?UTF-8?q?=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 5 +- Instalar.php | 248 ++++++++++++++++++++++++++++++++++++++++++ inc/configuracion.inc | 1 + 3 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 Instalar.php diff --git a/CHANGELOG b/CHANGELOG index 056cca8..f0c8459 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ -Versión 1.07 +-creado el programa instalar.php que permitirá configurar el acceso a la base de datos, comprobar la configuración del servidor y la creación del usuario administrador +-Añadido un parámetro en el archivo configuracion.inc que permite o no ejecutar el programa instalar.php + +Versión 1.07 31-03-2014 -Añadido bootstrap-select a la solicitud de informes de inventario de esta forma se pueden buscar artículos o ubicaciones en el select -Añadido bootstrap-select al mantenimiento para que en el alta de elementos se puedan buscar artículos o ubicaciones en el el select -Corregido un problema que permitía cambiar fechas en el formulario de bajas diff --git a/Instalar.php b/Instalar.php new file mode 100644 index 0000000..5822bff --- /dev/null +++ b/Instalar.php @@ -0,0 +1,248 @@ +. + * + */ +//Se incluyen los módulos necesarios +function __autoload($class_name) { + require_once $class_name . '.php'; +} +include 'inc/configuracion.inc'; +define('NUMPASOS', 3); +define('MINBYTES', 4096000); // post_max_size y max_upload van con esto +define('CADENAMINBYTES', '4M'); + +// Si ya se ha ejecutado con anterioridad esta script no continúa. +if (INSTALADO != 'no') { + echo "El programa ya está instalado"; + return 1; +} + +$instalar = new Instalar(); +echo $instalar->ejecuta(); + +class Instalar { + private $resultados; + private $contenido; + private $plant; + + public function __construct() + { + //Selecciona la plantilla a utilizar + $this->plant='plant/'; + $this->plant.=PLANTILLA; + $this->plant.='.html';; + } + + public function ejecuta() + { + $paso = isset($_GET['paso']) ? $_GET['paso'] : 0; + $paso = $paso > NUMPASOS ? '0' : $paso; + //Si quiere ir a un determinado paso se asegura que estén completos los anteriores + for ($i = 0; $i < $paso; $i++) { + if (!$this->resultado[$i]) { + //$funcion = "paso" . $i; + //$this->contenido = $this->$funcion(); + break; + } + } + if ($paso == NUMPASOS) { + $this->contenido = $this->pasoFinal(); + } else { + $funcion = "paso" . $i; + $this->contenido = $this->$funcion(); + } + $salida = new Distribucion($this->plant, $this); + return $salida->procesaPlantilla(); + } + + private function inicializa() + { + for ($i = 0; $i < NUMPASOS; $i++) { + $funcion = "validaPaso" . $i; + $resultado[] = $funcion(); + } + } + + // Resumen de cuestiones realizadas + private function pasoFinal() + { + + } + + // Cuestiones relacionadas con el servidor + private function paso0() + { + $displayErr = ini_get('display_errors'); + $info = ''; + if ($this->validaPaso0()) { + $boton = ''; + } else { + $boton = ''; + } + $info .= $boton; + $panel = $this->panelMensaje($info, 'info', 'PASO 1: Configuración del servidor'); + return $panel; + } + + private function retornaLabel($error, $mensaje, $tipo = "danger") + { + if ($error) { + $nombre1 = $tipo; $nombre2 = "remove"; + } else { + $nombre1 = "success"; $nombre2 = "ok"; + } + $mensaje = ''; + $mensaje .=''; + return $mensaje; + } + + private function retornaBytes($val) + { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + switch($last) { + // El modificador 'G' está disponble desde PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + return $val; + } + + private function validaPaso0() + { + $validar = true; + $postMax = ini_get('post_max_size'); + $uploadMax = ini_get('upload_max_filesize'); + $mysql = extension_loaded('mysqli'); + if ($this->retornaBytes($postMax) < MINBYTES) + $validar = false; + if ($this->retornaBytes($uploadMax) < MINBYTES) + $validar = false; + if (!$mysql) + $validar = false; + return $validar; + } + + // Cuestiones de la base de datos + private function paso2() + { + + } + + private function validaPaso2() + { + return false; + } + + // Usuario administrador + private function paso3() + { + + } + + private function validaPaso3() + { + return false; + } + + private function panelMensaje($info, $tipo = "info", $cabecera = "¡Atención!") { + $mensaje = '
'; + $mensaje .= '

' . $cabecera . '

'; + $mensaje .= '
'; + $mensaje .= $info; + $mensaje .= '
'; + $mensaje .= '
'; + return $mensaje; + } + + public function contenido() + { + return $this->contenido; + } + + public function menu() + { + return ''; + } + + public function opcion() + { + return 'INSTALACIÓN'; + } + + public function control() + { + return ''; + } + + public function aplicacion() + { + return PROGRAMA . ' v' . VERSION; + } + + public function usuario() + { + return ''; + } + + public function fecha() + { + $idioma = 'es_ES'; + if ($formato == '') + $formato = "%d-%b-%y"; + setlocale(LC_TIME, $idioma); + return strftime($formato); + } +} + +?> diff --git a/inc/configuracion.inc b/inc/configuracion.inc index be4f162..0e9a2e9 100644 --- a/inc/configuracion.inc +++ b/inc/configuracion.inc @@ -40,4 +40,5 @@ define('COLORFON', '#ffb878'); //Color del fondo de la pantalla define('MYSQLDUMP', '/usr/local/bin/mysqldump'); //camino a mysqldump define('GZIP', '/usr/bin/gzip'); //Camino a gzip define('IMAGEDATA', 'img.data'); //Directorio donde se almacenarán las imágenes +define('INSTALADO', 'no'); //no = permite la ejecución de instalar.php ?>