2 /*Instalador de cLab.*/
4 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="es" lang
="es">
7 <meta http
-equiv
="Content-Type" content
="text/html; charset=UTF-8" />
8 <meta http
-equiv
="Content-Style-type" content
="text/css" />
9 <meta http
-equiv
="Content-Script-type" content
="text/javascript" />
10 <meta http
-equiv
="Content-Language" content
="es" />
11 <link rel
="StyleSheet" href
="estilo.css" type
="text/css" />
12 <link rel
="shortcut icon" href
="/favicon.ico" type
="image/x-icon" />
13 <link rel
="start" href
="/" />
14 <title
>Instalador de Control de Laboratorio
</title
>
18 function CREAR_TBL($TBL,$QUERY) {
20 $x = @mysql_query
("DROP TABLE IF EXISTS $TBL;", $link) or die('!->No se pudo eliminar la tabla "'.$TBL.'".<br /><pre>' . mysql_error() . '</pre>');
21 $x = @mysql_query
($QUERY, $link) or die('!->No se pudo crear la tabla "'. $TBL .'".<br /><pre>' . mysql_error() . '</pre>');
22 if ($x) {echo "- Creada: '$TBL'<br />";}
25 if (!isset($_POST['instalar'])) {
27 <b>cLab - Instalador</b><br />
28 <form action="'. $_SERVER['PHP_SELF'] .'" method="post">
30 <tr><td>Configuración MySQL</td></tr>
32 <td>Dirección del servidor MySQL:</td>
33 <td><input type="text" name="motor" maxlength="50" size="20" value="localhost" /></td>
36 <td>Base de datos a utilizar:</td>
37 <td><input type="text" name="base" maxlength="10" size="20" value="" /></td>
41 <td><input type="text" name="usuario" maxlength="10" size="20" value="" /></td>
45 <td><input type="password" name="clave" maxlength="20" size="20" value="" /></td>
47 <tr><td><br />Administración</td></tr>
49 <td>Nombre Administrador:</td>
50 <td><input type="text" name="admin" maxlength="30" size="20" value="" /></td>
53 <td>Correo electrónico:</td>
54 <td><input type="text" name="email" maxlength="50" size="20" value="" /></td>
58 <td><input type="password" name="admin_clave" maxlength="20" size="20" value="" /></td>
61 <td>Clave (repetir):</td>
62 <td><input type="password" name="admin_clave2" maxlength="20" size="20" value="" /></td>
66 <input type="submit" name="instalar" value="Instalar" />
70 echo '<b>cLab - Instalador : Instalando</b><br />';
71 echo '<h3>+Creando conexión a la base de datos...</h3><br />';
72 $link = @mysql_connect
($_POST['motor'], $_POST['usuario'], $_POST['clave']) or die('Por favor revise sus datos, puesto que se produjo el siguiente error:<br /><pre>' . mysql_error() . '</pre>');
73 mysql_select_db($_POST['base'], $link) or die('!->La base de datos seleccionada "'.$_POST['base'].'" no existe');
74 echo '- Base de datos conectada...<br />';
75 echo '<h3>+Creando Archivo con datos de conexión...</h3><br />';
77 //chmod("data.php", 0666);
78 $fh = @fopen
("include/data.php", 'w') or die("No se pudo escribir 'data.php'.<br />");
82 $Datos = '$motor = '. $_POST['motor'] .";\n" . '$usuario = '. $_POST['usuario'] .";\n". '$clave = '. $_POST['clave'] .";\n" . '$base = '. $_POST['base'] .";\n";
88 echo '- Creado<br />';
89 echo '<h3>+Creando Tablas...</h3><br />';
90 $q="CREATE TABLE users ( username varchar(10) primary key, password varchar(32), userid varchar(32), userlevel tinyint(1) unsigned not null, email varchar(50), timestamp int(11) unsigned not null, nombre varchar(100) not null, catedratico varchar(100), tipo tinyint(1) unsigned not null, departamento tinyint(1) unsigned not null);";
91 CREAR_TBL("users", $q);
92 $q="CREATE TABLE active_users (username varchar(30) primary key, timestamp int(11) unsigned not null);";
93 CREAR_TBL("active_users", $q);
94 $q="CREATE TABLE active_guests (ip varchar(15) primary key, timestamp int(11) unsigned not null);";
95 CREAR_TBL("active_guests", $q);
96 $q="CREATE TABLE banned_users (username varchar(30) primary key, timestamp int(11) unsigned not null);";
97 CREAR_TBL("banned_users", $q);
99 echo '<h3>+Creando usuario Admin...</h3><br />';
100 $q = "INSERT INTO users VALUES ('".$_POST['admin'] . "', '" . md5($_POST['admin_clave']) . "', '0', '9', '" . $_POST['email'] . "', " . time() . ",0,0,0,0)";
101 @mysql_query
($q, $link);
102 echo '- Creado<br />';
104 echo '<br /><b>Instalación completa</b><br />';