diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-27 19:26:21 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-02-27 19:26:21 +0000 |
commit | 0b9fe18a6bf4036a05db7f9479d7b55d3fe5c782 (patch) | |
tree | 2d9905f25634fdc9fecec88362d1911e393a4b4b /installer/installer.php | |
parent | dc4f784558db725eb555ce9668231b89aabb8954 (diff) |
Both the command line and web installer installer now supports
creating tables with a table prefix.
There are still some queries that haven't been converted, so don't
start using prefixes yet. However, if you do, you can login and
modify the user profile.
Diffstat (limited to 'installer/installer.php')
-rw-r--r-- | installer/installer.php | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/installer/installer.php b/installer/installer.php index 32511541..9fec1185 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -48,11 +48,12 @@ class installer { return true; } - static function unpack_sql() { + static function unpack_sql($config) { + $prefix = $config["prefix"]; foreach (file(DOCROOT . "installer/install.sql") as $line) { $buf .= $line; if (preg_match("/;$/", $buf)) { - if (!mysql_query($buf)) { + if (!mysql_query(self::prepend_prefix($prefix, $buf))) { return false; } $buf = ""; @@ -87,7 +88,9 @@ class installer { } $password = substr(md5(time() * rand()), 0, 6); $hashed_password = $salt . md5($salt . $password); - if (mysql_query("UPDATE `users` SET `password` = '$hashed_password' WHERE `id` = 2")) { + $sql = self::prepend_prefix($config["prefix"], + "UPDATE `[users]` SET `password` = '$hashed_password' WHERE `id` = 2"); + if (mysql_query($sql)) { } else { throw new Exception(mysql_error()); } @@ -95,11 +98,17 @@ class installer { return array("admin", $password); } - static function create_private_key() { + static function create_private_key($config) { $key = md5(uniqid(mt_rand(), true)) . md5(uniqid(mt_rand(), true)); - if (mysql_query("INSERT INTO `vars` VALUES(NULL, 'core', 'private_key', '$key')")) { + $sql = self::prepend_prefix($config["prefix"], + "INSERT INTO `[vars]` VALUES(NULL, 'core', 'private_key', '$key')"); + if (mysql_query($sql)) { } else { throw new Exception(mysql_error()); } } + + static function prepend_prefix($prefix, $sql) { + return preg_replace("#\[([a-zA-Z0-9_]+)\]#", "{$prefix}$1", $sql); + } }
\ No newline at end of file |