* Repaired installation script.

master
Victor De la Rocha 2008-10-24 00:18:24 +00:00
parent afdb52bafe
commit 02407f90f3
6 changed files with 235 additions and 258 deletions

View File

@ -1,6 +1,6 @@
<?php
if(!defined('entry') || !entry) die('Not a valid page');
require('classes/mysql_connection.class.php');
require(Absolute_Path.'/classes/mysql_connection.class.php');
class Install {
var $data = null;
@ -25,8 +25,6 @@ class Install {
if (empty($this->data)) false;
if (!$this->create_config()) return false;
$this->create_db();
if (!$this->install_db()) return false;
@ -159,8 +157,8 @@ class Install {
}
function is_gelato_installed(){
if(file_exists('config.php')) {
@include("config.php");
if(file_exists(Absolute_Path.'config.php')) {
@include(Absolute_Path."config.php");
if (!$this->check_for_config()){
return false;
} else {
@ -193,38 +191,6 @@ class Install {
return true;
}
function create_config(){
$config = fopen("config.php", 'w+');
$contents = '<?php
if(!defined(\'entry\') || !entry) die(\'Not a valid page\');
/* ===========================
gelato CMS - A PHP based tumblelog CMS
development version
http://www.gelatocms.com/
gelato CMS is a free software licensed under the GPL 2.0
Copyright (C) 2007 by Pedro Santana <pecesama at gmail dot com>
=========================== */
define(\'DB_Server\', \''. $this->data['db_host'] . '\');
define(\'DB_name\', \''. $this->data['db_name'] . '\');
define(\'DB_User\', \''. $this->data['db_login'] . '\');
define(\'DB_Password\', \''. $this->data['db_password'] . '\');
define(\'Table_prefix\', \'gel_\');
define(\'Absolute_Path\', dirname(__FILE__).DIRECTORY_SEPARATOR);
?>';
if (fwrite($config, $contents) === FALSE) {
$this->errors = "Could not write config file to directory";
return false;
}
fclose($config);
return true;
}
function check_form(){
$action="";
@ -237,7 +203,6 @@ define(\'Absolute_Path\', dirname(__FILE__).DIRECTORY_SEPARATOR);
$this->showForm = true;
if ($action=="config") {
$sep_err="";

View File

@ -23,12 +23,12 @@ class Conexion_Mysql {
var $mservidor;
var $musuario;
var $mclave;
var $mid_conexion = 0; // Identificador de conexión
var $mid_conexion = 0; // Identificador de conexi<EFBFBD>n
var $mid_consulta = 0; // Identificador de consulta
var $merror_numero = 0; // Número de error
var $merror = ""; // Descripción del error.
var $merror_numero = 0; // N<EFBFBD>mero de error
var $merror = ""; // Descripci<EFBFBD>n del error.
/** Al crear una instancia de clase, se ejecutará esta función */
/** Al crear una instancia de clase, se ejecutara esta funcion */
function Conexion_Mysql($bd="", $host="localhost", $user="", $pass="") {
$this->mbase_datos = $bd;
$this->mservidor = $host;
@ -53,7 +53,7 @@ class Conexion_Mysql {
// Conectamos al servidor
$this->mid_conexion = @mysql_connect($this->mservidor, $this->musuario, $this->mclave);
if (!$this->mid_conexion) {
$this->merror = "No se logró realizar la conexión.";
$this->merror = "No se logr<EFBFBD> realizar la conexi<78>n.";
return false;
}
//seleccionamos la base de datos
@ -61,10 +61,10 @@ class Conexion_Mysql {
$this->merror = "No se puede abrir la base ".$this->mbase_datos ;
return false;
}
return $this->mid_conexion; // Si todo salio bien regresa el id de la conexión
return $this->mid_conexion; // Si todo salio bien regresa el id de la conexi<EFBFBD>n
}
/** Para ejecutar consultas en la conexión abierta */
/** Para ejecutar consultas en la conexi<EFBFBD>n abierta */
function ejecutarConsulta($msql = "") {
if ($msql == "") {
$this->merror = "No introdujo la sentencia SQL";
@ -214,7 +214,7 @@ class Conexion_Mysql {
if(eregi("^([0-9]+)$",$valor)){
$valor = date("Y-m-d H:i:s",$valor);
}else{
// Estariá en el formato strtotime()
// Estari<EFBFBD> en el formato strtotime()
$valor = date("Y-m-d H:i:s",strtotime($valor));
}
}
@ -232,14 +232,14 @@ class Conexion_Mysql {
}
/**
* Devuelve el número de campos de una consulta.
* Devuelve el n<EFBFBD>mero de campos de una consulta.
*/
function contarCampos() {
return mysql_num_fields($this->mid_consulta);
}
/**
* Devuelve el número de registros de una consulta.
* Devuelve el n<EFBFBD>mero de registros de una consulta.
*/
function contarRegistros() {
return @mysql_num_rows($this->mid_consulta);

View File

@ -20,7 +20,6 @@ class user extends Conexion_Mysql {
var $cookieTime;
var $persist = false;
function user() {
parent::Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
$this->cookie_life = 60*24*3600;

View File

@ -16,6 +16,5 @@ define('DB_name', '[database]');
define('DB_User', '[userdb]');
define('DB_Password', '[dbpass]');
define('Table_prefix', 'gel_');
define('Absolute_Path', dirname(__FILE__).DIRECTORY_SEPARATOR);
?>

View File

@ -24,19 +24,28 @@
* classes/imgsize.php
*/
// PHP settings specific to Gelato
ini_set('pcre.backtrack_limit', '10000');
// Globals to be used throughout the application
$configFile = dirname(__FILE__).DIRECTORY_SEPARATOR."config.php";
define('Absolute_Path', dirname(__FILE__).DIRECTORY_SEPARATOR);
$installed = true;
$configFile = Absolute_Path.'config.php';
if (!file_exists($configFile)) {
header("Location: install.php");
if(strpos($_SERVER['REQUEST_URI'],'/admin'))$dir = "../"; else $dir = "";
if (!file_exists($configFile) and basename($_SERVER['PHP_SELF'])!='install.php'){
header("Location: {$dir}install.php");exit;
}else{
require(dirname(__FILE__).DIRECTORY_SEPARATOR."config.php");
include(Absolute_Path.'classes/install.class.php');
$install = new Install();
if(!$install->is_gelato_installed()){
if(basename($_SERVER['PHP_SELF'])!='install.php'){
header("Location: {$dir}install.php");exit;
}
$installed = false;
}
}
require($configFile);
require_once("classes/configuration.class.php");
require_once("classes/textile.class.php");
require_once("classes/gelato.class.php");
@ -50,17 +59,17 @@ require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'streams.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'gettext.class.php');
require_once(Absolute_Path.'classes'.DIRECTORY_SEPARATOR.'lang.functions.php');
if($installed){
// Globals to be used throughout the application
$user = new user();
$tumble = new gelato();
$conf = new configuration();
$db = new Conexion_Mysql(DB_name, DB_Server, DB_User, DB_Password);
session_start();
$feeds = new feeds();
$feeds->updateFeeds();
unset($feeds);
}
?>

View File

@ -1,5 +1,5 @@
<?php
if(!defined('entry'))define('entry', true);
if(!defined('entry') || !entry) define('entry',true);
/* ===========================
gelato CMS - A PHP based tumblelog CMS
@ -11,15 +11,20 @@ if(!defined('entry'))define('entry', true);
=========================== */
require('entry.php');
// Received a valid request, better start setting globals we'll need throughout the app in entry.php
require_once('entry.php');
$configFile = Absolute_Path."config.php";
if(file_exists($configFile)){
require($configFile);
}else{
exit("You need to rename config-sample.php to config.php and fill out the required details.");
}
global $user, $conf, $tumble;
include('classes/install.class.php');
$install = new Install();
$install->data = $_POST;
$install->check_form();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">