From 1e8e5adbbf642085689d779fc4ebd1f9501e008c Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 9 Aug 2009 13:10:59 +0100 Subject: [PATCH] load config.php sooner --- core/database.class.php | 76 +++++++++++++++++++---------------------- index.php | 1 + 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/core/database.class.php b/core/database.class.php index 453edfb5..57a91073 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -222,53 +222,47 @@ class Database { * stored in config.php in the root shimmie folder */ public function Database() { - if(is_readable("config.php")) { - require_once "config.php"; + global $database_dsn; - if(substr($database_dsn, 0, 5) == "mysql") { - $this->engine = new MySQL(); - } - else if(substr($database_dsn, 0, 5) == "pgsql") { - $this->engine = new PostgreSQL(); - } - else if(substr($database_dsn, 0, 6) == "sqlite") { - $this->engine = new SQLite(); - } + if(substr($database_dsn, 0, 5) == "mysql") { + $this->engine = new MySQL(); + } + else if(substr($database_dsn, 0, 5) == "pgsql") { + $this->engine = new PostgreSQL(); + } + else if(substr($database_dsn, 0, 6) == "sqlite") { + $this->engine = new SQLite(); + } - $this->db = @NewADOConnection($database_dsn); + $this->db = @NewADOConnection($database_dsn); - if(isset($cache)) { - $matches = array(); - preg_match("#(memcache)://(.*)#", $cache, $matches); - if($matches[1] == "memcache") { - $this->cache = new MemCache($matches[2]); - } - } - else { - $this->cache = new NoCache(); - } - - if($this->db) { - $this->db->SetFetchMode(ADODB_FETCH_ASSOC); - $this->engine->init($this->db); - } - else { - $version = VERSION; - print " - - - Internal error - Shimmie-$version - - - Internal error: Could not connect to database - - - "; - exit; + if(isset($cache)) { + $matches = array(); + preg_match("#(memcache)://(.*)#", $cache, $matches); + if($matches[1] == "memcache") { + $this->cache = new MemCache($matches[2]); } } else { - header("Location: install.php"); + $this->cache = new NoCache(); + } + + if($this->db) { + $this->db->SetFetchMode(ADODB_FETCH_ASSOC); + $this->engine->init($this->db); + } + else { + $version = VERSION; + print " + + + Internal error - Shimmie-$version + + + Internal error: Could not connect to database + + + "; exit; } } diff --git a/index.php b/index.php index 20fb5d20..6c2794e8 100644 --- a/index.php +++ b/index.php @@ -61,6 +61,7 @@ if(!file_exists("config.php")) { exit; } +require_once "config.php"; require_once "core/util.inc.php"; _version_check(); _sanitise_environment();