.
*/
//Se incluyen los módulos necesarios
function __autoload($class_name)
{
require_once $class_name.'.php';
}
require_once 'inc/configuracion.inc';
define('NUMPASOS', 3);
//Para el Paso 1
define('MINBYTES', 4096000); // post_max_size y max_upload van con esto
define('CADENAMINBYTES', '4M');
define('CONFIGURACION', 'inc/configuracion.inc');
define('CONFIGTMP', TMP.'/config.tmp');
define('INC', './inc');
$instalar = new Instalar();
if ($instalar->error) {
echo $instalar->panelError();
return;
}
echo $instalar->ejecuta();
class Instalar
{
private $contenido;
private $plant;
public $error;
public $error_msj;
public function __construct()
{
//Selecciona la plantilla a utilizar
$this->plant = 'plant/';
$this->plant .= PLANTILLA;
$this->plant .= '.html';
$this->error = false;
$this->eror_msj = '';
if (INSTALADO != 'no') {
$this->error = true;
$this->error_msj = 'El programa ya está instalado';
}
/*if ($this->existenDatos()) {
$this->error = true;
$this->error_msj = "El indicador de instalación tiene 'no' pero la base de datos " . BASEDATOS . " contiene la tabla Articulos.";
}*/
}
private function existenDatos()
{
//Comprueba si existe la tabla Articulos
$sql = new Sql(SERVIDOR, USUARIO, CLAVE, BASEDATOS);
if ($sql->error()) {
return false;
}
$sql->ejecuta('select * from Articulos;');
if ($sql->error()) {
return false;
}
return true;
}
public function ejecuta()
{
$paso = isset($_GET['paso']) ? $_GET['paso'] : 0;
$paso = $paso > NUMPASOS ? '0' : $paso;
$i = 0;
//Si quiere ir a un determinado paso se asegura que estén completos los anteriores
for ($i = 0; $i < $paso; $i++) {
$funcion = 'validaPaso'.$i;
if (!$this->$funcion()) {
break;
}
}
$funcion = 'paso'.$i;
$this->contenido = $this->$funcion();
$salida = new Distribucion($this->plant, $this);
return $salida->procesaPlantilla();
}
// Cuestiones relacionadas con el servidor
private function paso0()
{
$info = '
';
// img.dat
$mensaje = is_writable(IMAGEDATA) ? $this->retornaLabel(false, 'Se debe poder escribir en el directorio '.IMAGEDATA) :
$this->retornaLabel(true, 'Se debe poder escribir en el directorio '.IMAGEDATA);
$valor = is_writable(IMAGEDATA) ? 'Sí' : 'No';
$info .= $this->retornaElemento($mensaje, 'Se puede escribir en '.IMAGEDATA, $valor);
// tmp
$mensaje = is_writable(TMP) ? $this->retornaLabel(false, 'Se debe poder escribir en el directorio '.TMP) :
$this->retornaLabel(true, 'Se debe poder escribir en el directorio '.TMP);
$valor = is_writable(TMP) ? 'Sí' : 'No';
$info .= $this->retornaElemento($mensaje, 'Se puede escribir en '.TMP, $valor);
// inc
$mensaje = is_writable(INC) ? $this->retornaLabel(false, 'Se debe poder escribir en el directorio '.INC) :
$this->retornaLabel(true, 'Se debe poder escribir en el directorio '.INC);
$valor = is_writable(INC) ? 'Sí' : 'No';
$info .= $this->retornaElemento($mensaje, 'Se puede escribir en '.INC, $valor);
// configuracion.inc
$mensaje = is_writable(CONFIGURACION) ? $this->retornaLabel(false, 'Se debe poder escribir en el fichero de configuración '.CONFIGURACION) :
$this->retornaLabel(true, 'Se debe poder escribir en el fichero de configuración '.CONFIGURACION);
$valor = is_writable(CONFIGURACION) ? 'Sí' : 'No';
$info .= $this->retornaElemento($mensaje, 'Se puede escribir en '.CONFIGURACION, $valor);
// Final del paso
$info .= '
';
$info .= $this->validaPaso0() ? $this->retornaBoton(false, 'Instalar.php?paso=1') : $this->retornaBoton(true, 'Instalar.php');
$panel = $this->panelMensaje($info, 'primary', 'PASO 1: Configuración del servidor y la aplicación');
return $panel;
}
private function retornaElemento($validacion, $mensaje, $valor)
{
$info = '