summaryrefslogtreecommitdiff
path: root/installer/installer.php
diff options
context:
space:
mode:
Diffstat (limited to 'installer/installer.php')
-rw-r--r--installer/installer.php19
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