problema con install.php Buenas a todos;
Tengo que instalar un tipo de CMS, y tengo un problema.
El primero es que cuando voy a instalarlo tengo que darle a install.php y tengo que meter usuario y contraseña para definirlas. Luego cuando hago esto deberia crear las tablas y todo para la base de datos; el problema esta en que no se crea, el fichero install.php requiere common.php y este a la vez config.php (en este va usuario de la base datos, base de datos, contraseña), bueno pues eso que no puedo instalarlo, primero quiero instalarlo en mi apache, y no puedo.No se cual es problema.. Os dejo los tres archivos por si acaso es que tengo en el codigo algo mal escrito o algo por el estilo. Tambien si es posible sacar el archivo install.php a .sql
Este post lo pondre tambien en el foro de base de datos install.php
Código:
<?php
/***********************************************************************
Instalacción
***********************************************************************/
if ( isset($send) )
// We have already sent the admin data
{
require("common.php");
// We make avaiable the database
$db = new database()
or die("La base de datos está sobrecargada, por favor intentalo más tarde");
echo "Eliminando las anteriores bases de datos si existieran<br><br>";
$query = "DROP TABLE `League` , `Matches` , `Messages` , `Modules` , `Players` , `Teams` , `Users` , `Offers`;";
$db->doQuery ($query);
echo "Creando las bases de datos...<br><br>";
// Tabla de usuarios
$query = "CREATE TABLE Users (uname CHAR(16) NOT NULL, pass CHAR(50), team INT, admin BIT,";
$query .= "email CHAR(30), language CHAR(5), skin CHAR(16), KEY(uname));";
$db->doQuery ($query);
$pass = md5($pass);
$query = "INSERT INTO Users (uname, pass, admin, email, language, skin) VALUES ";
$query .= "('$user', '$pass', '1', '', 'es', 'default');";
$db->doQuery ($query);
// Tabla de jugadores
$query = "CREATE TABLE Players (id INT NOT NULL AUTO_INCREMENT, name CHAR(30), team INT, uname CHAR(16), defence INT(7),";
$query .= " pass INT(7), shoot INT(7), keeping INT(7), endurance INT(7), physicalForm INT(7), weeksInjured INT UNSIGNED,";
$query .= " matchesPlayed INT UNSIGNED, weeksBanned INT UNSIGNED, goals INT, yellowCards INT UNSIGNED,";
$query .= " redCards INT UNSIGNED, transferListed BIT, KEY(id) );";
$db->doQuery ($query);
// Tabla de partidos
$query = "CREATE TABLE Matches (id INT NOT NULL AUTO_INCREMENT, home INT,";
$query .= " away INT, played BIT, scoreHome INT, scoreAway INT, commentary LONGTEXT,";
$query .= " week INT, KEY(id) );";
$db->doQuery ($query);
// Tabla de equipos
$query = "CREATE TABLE Teams (id INT NOT NULL AUTO_INCREMENT, teamName CHAR(30),uname CHAR(16) NOT NULL,";
$query .= " tactic CHAR(8), budget INT, N1 INT, N2 INT, N3 INT, N4 INT, N5 INT, N6 INT, N7 INT, N8 INT, N9 INT,";
$query .= " N10 INT, N11 INT, N12 INT, N13 INT, N14 INT, N15 INT,";
$query .= " leaguePoints INT, KEY(id) );";
$db->doQuery ($query);
// Tabla de liga
$query = "CREATE TABLE League (id INT NOT NULL AUTO_INCREMENT, week INT, KEY(id));";
$db->doQuery ($query);
$query = "INSERT INTO League (id,week) VALUES ('1','0')";
$db->doQuery ($query);
// Tabla de modulos
$query = "CREATE TABLE Modules (id CHAR(20) NOT NULL, name CHAR(30),";
$query .= " type INT, KEY(id) );";
$db->doQuery ($query);
// Información de los modulos
$query = "INSERT INTO Modules (id, name, type) VALUES ('calendar',";
$query .= " 'Calendario', 1)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('change_profile',";
$query .= " 'Editar perfil', 1)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('roster',";
$query .= " 'Alineacion', 2)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('next_week',";
$query .= " 'Avanzar jornada', 0)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('add_user',";
$query .= " 'Añadir usuario', 0)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('reset_league',";
$query .= " 'Inicializar liga', 0)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('standings',";
$query .= " 'Clasificacion', 1)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('private_messages',";
$query .= " 'Mensajes Privados', 1)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('manage_users',";
$query .= " 'Administrar usuarios', 0)";
$db->doQuery ($query);
$query = "INSERT INTO Modules (id, name, type) VALUES ('transfer',";
$query .= " 'Fichajes', 1)";
$db->doQuery ($query);
// Tabla de mensajes privados
$query = "CREATE TABLE Messages (id INT NOT NULL AUTO_INCREMENT, messagefrom CHAR(30),";
$query .= " messageto CHAR(30), subject CHAR(50), body LONGTEXT, internal BIT, KEY(id) );";
$db->doQuery ($query);
// Ofertas de los equipos
$query = "CREATE TABLE Offers (id INT NOT NULL AUTO_INCREMENT, playerid INT, teamfrom INT,";
$query .= " amount INT UNSIGNED, age INT(3), KEY(id) );";
$db->doQuery ($query);
echo "Creación completa. Borra el archivo install.php y ya puedes entrar con tu nuevo usuario.";
echo "¡Disfruta del juego!";
}
else
{
?>
<h1>Instalador de RMP</h1><br><br>
Introduzca un nombre de usuario y una contraseña para el administrador:<br>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Nombre de usuario: <input type="text" name="user"><br>
Contraseña: <input type="password" name="pass"><br><br>
<input type="submit" value="Enviar" name="send">
</form>
<?php
}
?>
common.php
Código:
<?php
/************************************************************************************************
Auxiliary functions
************************************************************************************************/
require_once ("lib/user.php");
require_once ("lib/calendar.php");
require_once ("lib/offer.php");
//------------------------------------------------------------
function version()
{
// Returns version number
return "v0.1 RMP";
}
//------------------------------------------------------------
class database
// Class that allows us to perform operations in database
{
var $connection;
function database()
{
if ( !isset ($this->connection) )
{
include ("config.php");
$this->connection = mysql_connect($DatabaseHost, $DatabaseUsername, $DatabasePassword);
mysql_select_db($DatabaseName,$this->connection);
}
}
function doQuery($query)
{
$result = mysql_query($query,$this->connection);
return ($result);
}
}
//------------------------------------------------------------
function redirect($page)
// Redirects browser to given page
{
echo "<META http-equiv='refresh' content='0;URL=./".$page."'>";
}
//------------------------------------------------------------
function sessionControl()
// Registers needed variables redirecting to index if they aren't set yet
{
session_register('userdata');
}
//------------------------------------------------------------
function logout()
// Logs out
{
session_unregister('userdata');
}
//------------------------------------------------------------
function mustBeAdmin($userdata)
// If user isn't a registered user and an admin redirects browser to index.php
{
if ( !isset($userdata) )
redirect("index.php");
else if ($userdata->admin == 0)
redirect("index.php");
}
//------------------------------------------------------------
function generatename()
// This function returns an string containing a random name
// This will be copied in every names file we create
{
// We must include appropiate name file
include ("names/spanish.php");
$nametype = rand (1,3);
if ($nametype==1)
{
$index = rand (0, count ($names)-1);
$buffer = $names[$index];
$index = rand (0, count ($surnames)-1);
$buffer .= " ".$surnames[$index];
}
if ($nametype==2)
{
$index = rand (0, count ($names)-1);
$buffer = $names[$index];
}
if ($nametype==3)
{
$index = rand (0, count ($surnames)-1);
$buffer = $surnames[$index];
}
return $buffer;
}
//------------------------------------------------------------
function message($type, $attackingPlayer = 0, $defendingPlayer = 0, $attackingTeam = 0, $defendingTeam = 0)
// Gets a random message of the type given of the selected language (spanish only at the moment)
{
include ("language/es/commentary.php");
$randomIndex = rand (0, count( $messages[$type] )-1 );
$comment = $messages[$type][$randomIndex];
$comment=str_replace("%ap",$attackingPlayer,$comment);
$comment=str_replace("%dp",$defendingPlayer,$comment);
$comment=str_replace("%at",$attackingTeam,$comment);
$comment=str_replace("%dt",$defendingTeam,$comment);
return ($comment);
}
//------------------------------------------------------------
function frand($min,$max)
// Returns a random float between min and max
{
$range = $max - $min;
$value = $min + $range * rand(0, getrandmax() ) / getrandmax();
return ( $value );
}
?>
config.php
Código:
<?php
/*******************************************************************************************
Configuration file
********************************************************************************************/
// You MUST set this variables to their proper values before using RMP
$DatabaseHost="localhost"; // Host where the database is.
$DatabaseUsername="root"; // Username of the database
$DatabasePassword=""; // Database password
$DatabaseName="entrenador"; // Name of the database the game is going to use
?>
|