summaryrefslogtreecommitdiff
path: root/installer/installer.php
diff options
context:
space:
mode:
authorroot <root@sleepydogs.net>2009-09-13 09:01:55 -0700
committerroot <root@sleepydogs.net>2009-09-13 09:01:55 -0700
commitc62d1f440f077ba806b7ff0c6b90ef89c79b2fd3 (patch)
treeb64f05e2a7bd8db7200e3c407904e255826b4cf2 /installer/installer.php
parentb96ac1eb81b7ccd5bd050ffab0ca9ce1feec8f4f (diff)
parentcaa2002d7777e0ceb884d4c628650804620ca2b6 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'installer/installer.php')
-rw-r--r--installer/installer.php22
1 files changed, 19 insertions, 3 deletions
diff --git a/installer/installer.php b/installer/installer.php
index b0af561e..7a417634 100644
--- a/installer/installer.php
+++ b/installer/installer.php
@@ -47,6 +47,11 @@ class installer {
}
static function unpack_var() {
+ if (!file_exists(VARPATH)) {
+ mkdir(VARPATH);
+ chmod(VARPATH, 0777);
+ }
+
include(DOCROOT . "installer/init_var.php");
return true;
}
@@ -55,7 +60,7 @@ class installer {
$prefix = $config["prefix"];
$buf = null;
foreach (file(DOCROOT . "installer/install.sql") as $line) {
- $buf .= $line;
+ $buf .= trim($line);
if (preg_match("/;$/", $buf)) {
if (!mysql_query(self::prepend_prefix($prefix, $buf))) {
return false;
@@ -92,7 +97,7 @@ class installer {
}
}
- return mysql_connect($config["host"], $config["user"], $config["password"]);
+ return @mysql_connect($config["host"], $config["user"], $config["password"]);
}
static function select_db($config) {
@@ -104,6 +109,16 @@ class installer {
mysql_select_db($config["dbname"]);
}
+ static function verify_mysql_version($config) {
+ return version_compare(installer::mysql_version($config), "5.0.0", ">=");
+ }
+
+ static function mysql_version($config) {
+ $result = mysql_query("SHOW VARIABLES WHERE variable_name = \"version\"");
+ $row = mysql_fetch_object($result);
+ return $row->Value;
+ }
+
static function db_empty($config) {
$query = "SHOW TABLES IN {$config['dbname']} LIKE '{$config['prefix']}items'";
return mysql_num_rows(mysql_query($query)) == 0;
@@ -117,7 +132,8 @@ class installer {
$salt .= chr($char);
}
$password = substr(md5(time() * rand()), 0, 6);
- $hashed_password = $salt . md5($salt . $password);
+ // Escape backslash in preparation for our UPDATE statement.
+ $hashed_password = str_replace("\\", "\\\\", $salt . md5($salt . $password));
$sql = self::prepend_prefix($config["prefix"],
"UPDATE {users} SET `password` = '$hashed_password' WHERE `id` = 2");
if (mysql_query($sql)) {