Estilizar tablas segun nuestro diseño.
[CLab.git] / instalar.php
blobfd6776a130a2a06cb613d6238a1d26f23451cc64
1 <?php
2 /*Instalador de cLab.*/
3 ?>
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">
6 <head>
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>
15 </head>
16 <body>
17 <?php
18 function CREAR_TBL($TBL,$QUERY) {
19 global $link;
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'])) {
26 echo '
27 <h3>cLab - Instalador</h3><br />
28 <form action="'. $_SERVER['PHP_SELF'] .'" method="post">
29 <table border=0>
30 <tr><td>Configuración MySQL</td></tr>
31 <tr>
32 <td>Dirección del servidor MySQL:</td>
33 <td><input type="text" name="motor" maxlength="50" size="20" value="localhost" /></td>
34 </tr>
35 <tr>
36 <td>Base de datos a utilizar:</td>
37 <td><input type="text" name="base" maxlength="50" size="20" value="" /></td>
38 </tr>
39 <tr>
40 <td>Usuario:</td>
41 <td><input type="text" name="usuario" maxlength="50" size="20" value="" /></td>
42 </tr>
43 <tr>
44 <td>Clave:</td>
45 <td><input type="password" name="clave" maxlength="30" size="20" value="" /></td>
46 </tr>
47 <tr><td><br /><h2>Administración</h2></td></tr>
48 <tr>
49 <td>Nombre Administrador:</td>
50 <td><input type="text" name="admin" maxlength="10" size="20" value="" /></td>
51 </tr>
52 <tr>
53 <td>Correo electrónico:</td>
54 <td><input type="text" name="email" maxlength="50" size="20" value="" /></td>
55 </tr>
56 <tr>
57 <td>Clave:</td>
58 <td><input type="password" name="admin_clave" maxlength="20" size="20" value="" /></td>
59 </tr>
60 <tr>
61 <td>Clave (repetir):</td>
62 <td><input type="password" name="admin_clave2" maxlength="20" size="20" value="" /></td>
63 </tr>
64 </table>
65 <br />
66 <input type="submit" name="instalar" value="Instalar" />
67 </form>
69 } else {
70 echo '<b>cLab - Instalador : Instalando</b><br />';
71 if ($_POST['admin_clave'] != $_POST['admin_clave2']) {
72 echo '<h3>+Las contraseñas no coinciden.</h3><br />
73 <a href="javascript:history.back();">Regresar al instalador</a>';
75 echo '<h3>+Creando conexión a la base de datos...</h3><br />';
76 $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>');
77 mysql_select_db($_POST['base'], $link) or die('!->La base de datos seleccionada "'.$_POST['base'].'" no existe');
78 echo '- Base de datos conectada...<br />';
79 echo '<h3>+Creando Archivo con datos de conexión...</h3><br />';
80 //touch("data.php");
81 //chmod("data.php", 0666);
82 $fh = @fopen("include/data.php", 'w') or die("No se pudo escribir 'data.php'.<br />");
83 if ($fh) {
84 $Datos = "<?php\n";
85 fwrite($fh, $Datos);
86 $Datos = '$motor = '. $_POST['motor'] .";\n" . '$usuario = '. $_POST['usuario'] .";\n". '$clave = '. $_POST['clave'] .";\n" . '$base = '. $_POST['base'] .";\n";
87 fwrite($fh, $Datos);
88 $Datos = "?>\n";
89 fwrite($fh, $Datos);
90 fclose($fh);
92 echo '- Creado<br />';
93 echo '<h3>+Creando Tablas...</h3><br />';
94 $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);";
95 CREAR_TBL("users", $q);
96 $q="CREATE TABLE active_users (username varchar(30) primary key, timestamp int(11) unsigned not null);";
97 CREAR_TBL("active_users", $q);
98 $q="CREATE TABLE active_guests (ip varchar(15) primary key, timestamp int(11) unsigned not null);";
99 CREAR_TBL("active_guests", $q);
100 $q="CREATE TABLE banned_users (username varchar(30) primary key, timestamp int(11) unsigned not null);";
101 CREAR_TBL("banned_users", $q);
102 $q="CREATE TABLE horarios (username varchar(10), taller varchar(5), dia tinyint(1), posicion int(11));";
103 CREAR_TBL("horarios", $q);
105 LSA+<posición en minutos>+<posición de día, Lunes=1>
106 ej: LSA+450+2 -> Taller LSA a las 6:30a.m el día martes.
108 echo '<h3>+Creando usuario Admin...</h3><br />';
109 $q = "INSERT INTO users VALUES ('".$_POST['admin'] . "', '" . md5($_POST['admin_clave']) . "', '0', '9', '" . $_POST['email'] . "', " . time() . ",0,0,0,4,2)";
110 @mysql_query($q, $link);
111 echo '- Creado<br />';
112 mysql_close($link);
113 echo '<br /><b>Instalación completa</b><br />';
116 </body>
117 </html>