load config.php sooner
This commit is contained in:
parent
d95855411d
commit
1e8e5adbbf
@ -222,53 +222,47 @@ class Database {
|
|||||||
* stored in config.php in the root shimmie folder
|
* stored in config.php in the root shimmie folder
|
||||||
*/
|
*/
|
||||||
public function Database() {
|
public function Database() {
|
||||||
if(is_readable("config.php")) {
|
global $database_dsn;
|
||||||
require_once "config.php";
|
|
||||||
|
|
||||||
if(substr($database_dsn, 0, 5) == "mysql") {
|
if(substr($database_dsn, 0, 5) == "mysql") {
|
||||||
$this->engine = new MySQL();
|
$this->engine = new MySQL();
|
||||||
}
|
}
|
||||||
else if(substr($database_dsn, 0, 5) == "pgsql") {
|
else if(substr($database_dsn, 0, 5) == "pgsql") {
|
||||||
$this->engine = new PostgreSQL();
|
$this->engine = new PostgreSQL();
|
||||||
}
|
}
|
||||||
else if(substr($database_dsn, 0, 6) == "sqlite") {
|
else if(substr($database_dsn, 0, 6) == "sqlite") {
|
||||||
$this->engine = new SQLite();
|
$this->engine = new SQLite();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db = @NewADOConnection($database_dsn);
|
$this->db = @NewADOConnection($database_dsn);
|
||||||
|
|
||||||
if(isset($cache)) {
|
if(isset($cache)) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
preg_match("#(memcache)://(.*)#", $cache, $matches);
|
preg_match("#(memcache)://(.*)#", $cache, $matches);
|
||||||
if($matches[1] == "memcache") {
|
if($matches[1] == "memcache") {
|
||||||
$this->cache = new MemCache($matches[2]);
|
$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 "
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Internal error - Shimmie-$version</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
Internal error: Could not connect to database
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
";
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
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 "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Internal error - Shimmie-$version</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Internal error: Could not connect to database
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user