From 0b9fe18a6bf4036a05db7f9479d7b55d3fe5c782 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 27 Feb 2009 19:26:21 +0000 Subject: 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. --- installer/installer.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'installer/installer.php') 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 -- cgit v1.2.3