1 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="es" lang
="es">
4 <meta http
-equiv
="Content-Type" content
="text/html; charset=UTF-8" />
5 <meta http
-equiv
="Content-Style-type" content
="text/css" />
6 <meta http
-equiv
="Content-Script-type" content
="text/javascript" />
7 <meta http
-equiv
="Content-Language" content
="es" />
8 <link rel
="StyleSheet" href
="estilo.css" type
="text/css" />
9 <link rel
="shortcut icon" href
="/favicon.ico" type
="image/x-icon" />
10 <link rel
="start" href
="/" />
11 <title
>Instalador de Control de Laboratorio
</title
>
15 function CREAR_TBL($TBL,$QUERY) {
17 $x = @mysql_query
("DROP TABLE IF EXISTS $TBL;", $link) or die('!->No se pudo eliminar la tabla "'.$TBL.'".<br /><pre>' . mysql_error() . '</pre>');
18 $x = @mysql_query
($QUERY, $link) or die('!->No se pudo crear la tabla "'. $TBL .'".<br /><pre>' . mysql_error() . '</pre>');
19 if ($x) {echo "- Creada: '$TBL'<br />";}
22 if (!isset($_POST['instalar'])) {
24 <h3>Sistema de Horarios - Instalador</h3><br />
25 <form action="'. $_SERVER['PHP_SELF'] .'" method="post">
27 <tr><td>Configuración MySQL</td></tr>
29 <td>Dirección del servidor MySQL:</td>
30 <td><input type="text" name="motor" maxlength="50" size="20" value="localhost" /></td>
33 <td>Base de datos a utilizar:</td>
34 <td><input type="text" name="base" maxlength="50" size="20" value="" /></td>
38 <td><input type="text" name="usuario" maxlength="50" size="20" value="" /></td>
42 <td><input type="password" name="clave" maxlength="30" size="20" value="" /></td>
44 <tr><td><br /><h2>Administración</h2></td></tr>
46 <td>Nombre Administrador:</td>
47 <td><input type="text" name="admin" maxlength="10" size="20" value="" /></td>
50 <td>Correo electrónico:</td>
51 <td><input type="text" name="email" maxlength="50" size="20" value="" /></td>
55 <td><input type="password" name="admin_clave" maxlength="20" size="20" value="" /></td>
58 <td>Clave (repetir):</td>
59 <td><input type="password" name="admin_clave2" maxlength="20" size="20" value="" /></td>
63 <input type="submit" name="instalar" value="Instalar" />
67 echo '<b>cLab - Instalador : Instalando</b><br />';
68 if ($_POST['admin_clave'] != $_POST['admin_clave2']) {
69 echo '<h3>+Las contraseñas no coinciden.</h3><br />
70 <a href="javascript:history.back();">Regresar al instalador</a>';
72 echo '<h3>+Creando conexión a la base de datos...</h3><br />';
73 $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>');
74 mysql_select_db($_POST['base'], $link) or die('!->La base de datos seleccionada "'.$_POST['base'].'" no existe');
75 echo '- Base de datos conectada...<br />';
76 echo '<h3>+Creando Archivo con datos de conexión...</h3><br />';
78 //chmod("data.php", 0666);
79 $fh = @fopen
("include/data.php", 'w') or die("No se pudo escribir 'data.php'.<br />");
83 $Datos = '$motor = '. $_POST['motor'] .";\n" . '$usuario = '. $_POST['usuario'] .";\n". '$clave = '. $_POST['clave'] .";\n" . '$base = '. $_POST['base'] .";\n";
89 echo '- Creado<br />';
90 echo '<h3>+Creando Tablas...</h3><br />';
91 $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, encargado varchar(100), catedratico varchar(100), tipo tinyint(1) unsigned not null, departamento tinyint(1) unsigned not null);";
92 CREAR_TBL("users", $q);
93 $q="CREATE TABLE active_users (username varchar(30) primary key, timestamp int(11) unsigned not null);";
94 CREAR_TBL("active_users", $q);
95 $q="CREATE TABLE active_guests (ip varchar(15) primary key, timestamp int(11) unsigned not null);";
96 CREAR_TBL("active_guests", $q);
97 $q="CREATE TABLE banned_users (username varchar(30) primary key, timestamp int(11) unsigned not null);";
98 CREAR_TBL("banned_users", $q);
99 $q="CREATE TABLE horarios (username varchar(10), taller varchar(5), dia tinyint(1), posicion int(11));";
100 CREAR_TBL("horarios", $q);
101 echo '<h3>+Creando usuario Admin...</h3><br />';
102 $q = "INSERT INTO users VALUES ('".$_POST['admin'] . "', '" . md5($_POST['admin_clave']) . "', '0', '9', '" . $_POST['email'] . "', " . time() . ",0,0,0,4,2)";
103 @mysql_query
($q, $link);
104 echo '- Creado<br />';
106 echo '<br /><b>Instalación completa</b><br />';