From 1ce8643b8056266139552045fcdb48bbdb9c665b Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 28 Aug 2009 15:17:07 -0700 Subject: Fix for #440. Basically add a check that the mysql version is > 5.0.0. It was felt that actually listing the requirements might be overwhelming to novice users. --- installer/installer.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index b0af561e..456cffaa 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -104,6 +104,13 @@ class installer { mysql_select_db($config["dbname"]); } + static function verify_version($config) { + $result = mysql_query("SHOW VARIABLES WHERE variable_name = \"version\""); + $row = mysql_fetch_object($result); + $version = substr($row->Value, 0, strpos($row->Value, "-")); + return version_compare($version, "5.0.0", ">="); + } + static function db_empty($config) { $query = "SHOW TABLES IN {$config['dbname']} LIKE '{$config['prefix']}items'"; return mysql_num_rows(mysql_query($query)) == 0; -- cgit v1.2.3 From fd954fe86e2852c245dd599f9476fdf8ea3642e4 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 30 Aug 2009 13:43:29 -0700 Subject: Print out the version of MySQL that we found along with our error message, which should resolve http://gallery.menalto.com/node/90646 --- installer/installer.php | 8 ++++++-- installer/views/invalid_db_version.html.php | 2 +- installer/web.php | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index 456cffaa..58d264ec 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -104,11 +104,15 @@ class installer { mysql_select_db($config["dbname"]); } - static function verify_version($config) { + 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); $version = substr($row->Value, 0, strpos($row->Value, "-")); - return version_compare($version, "5.0.0", ">="); + return $version; } static function db_empty($config) { diff --git a/installer/views/invalid_db_version.html.php b/installer/views/invalid_db_version.html.php index 8776ac35..5b021ba2 100644 --- a/installer/views/invalid_db_version.html.php +++ b/installer/views/invalid_db_version.html.php @@ -1,5 +1,5 @@

Uh oh!

- The MySql database that you are referencing is less than the minimum version of 5.0.0. + Gallery requires at least MySQL version 5.0.0. You're using version

diff --git a/installer/web.php b/installer/web.php index aceb5368..eb0211a6 100644 --- a/installer/web.php +++ b/installer/web.php @@ -41,7 +41,7 @@ if (installer::already_installed()) { if (!installer::connect($config)) { $content = render("invalid_db_info.html.php"); - } else if (!installer::verify_version($config)) { + } else if (!installer::verify_mysql_version($config)) { $content = render("invalid_db_version.html.php"); } else if (!installer::select_db($config)) { $content = render("missing_db.html.php"); -- cgit v1.2.3 From 31dcdcc6ad6ce47c03265f3d6e499774a17ff727 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 30 Aug 2009 15:18:20 -0700 Subject: Remove unnecessary cleverness in stripping off the hyphen for mysql version checks that was causing problems in the case where there's no hyphen. version_compare handles hypens fine. --- installer/installer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index 58d264ec..50657d80 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -110,9 +110,7 @@ class installer { static function mysql_version($config) { $result = mysql_query("SHOW VARIABLES WHERE variable_name = \"version\""); - $row = mysql_fetch_object($result); - $version = substr($row->Value, 0, strpos($row->Value, "-")); - return $version; + return $row->Value; } static function db_empty($config) { -- cgit v1.2.3 From e4eedadcbb42e831f9649e6b52bd1ee9bf86f544 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 30 Aug 2009 21:12:35 -0700 Subject: Add back mysql_fetch_object() call that I accidentally removed in my rush to catch a plane. --- installer/installer.php | 1 + 1 file changed, 1 insertion(+) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index 50657d80..fedb4251 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -110,6 +110,7 @@ class installer { static function mysql_version($config) { $result = mysql_query("SHOW VARIABLES WHERE variable_name = \"version\""); + $row = mysql_fetch_object($result); return $row->Value; } -- cgit v1.2.3 From b3cac5c17320af380b18552a40ff809e598668cd Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 31 Aug 2009 21:26:14 -0700 Subject: Suppress errors to mysql_connect(). We had this before, but it appears to have been accidentally removed in 177a854d --- installer/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index fedb4251..7173a7ee 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -92,7 +92,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) { -- cgit v1.2.3 From 064038a24fe10c63328a3b9f679a8a7fd80f6b0e Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 1 Sep 2009 21:12:42 -0700 Subject: Escape backslashes (\) in the $salt in create_admin() as they will interfere with our hand rolled UPDATE statement. Big thanks to paulepanter. --- installer/installer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index 7173a7ee..7fed25c7 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -127,7 +127,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)) { -- cgit v1.2.3 From b8053c9ddf3e393f76594e7dccc2f81f7116fd85 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 10 Sep 2009 21:10:20 -0700 Subject: Rename "after_installer" to "welcome_message" in the code to make it clearer what its purpose is. Add some spacing in the theme for it so that it's less cramped. --- installer/installer.php | 5 +++ modules/gallery/controllers/after_install.php | 30 ------------------ modules/gallery/controllers/welcome_message.php | 30 ++++++++++++++++++ modules/gallery/helpers/gallery_theme.php | 4 +-- modules/gallery/views/after_install.html.php | 29 ----------------- .../gallery/views/after_install_loader.html.php | 7 ----- modules/gallery/views/welcome_message.html.php | 36 ++++++++++++++++++++++ .../gallery/views/welcome_message_loader.html.php | 7 +++++ themes/default/css/screen.css | 4 +++ 9 files changed, 84 insertions(+), 68 deletions(-) delete mode 100644 modules/gallery/controllers/after_install.php create mode 100644 modules/gallery/controllers/welcome_message.php delete mode 100644 modules/gallery/views/after_install.html.php delete mode 100644 modules/gallery/views/after_install_loader.html.php create mode 100644 modules/gallery/views/welcome_message.html.php create mode 100644 modules/gallery/views/welcome_message_loader.html.php (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index 7fed25c7..4480e35e 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; } diff --git a/modules/gallery/controllers/after_install.php b/modules/gallery/controllers/after_install.php deleted file mode 100644 index b640092f..00000000 --- a/modules/gallery/controllers/after_install.php +++ /dev/null @@ -1,30 +0,0 @@ -admin) { - url::redirect(item::root()->url()); - } - - $v = new View("after_install.html"); - $v->user = user::active(); - print $v; - } -} diff --git a/modules/gallery/controllers/welcome_message.php b/modules/gallery/controllers/welcome_message.php new file mode 100644 index 00000000..a4b690e3 --- /dev/null +++ b/modules/gallery/controllers/welcome_message.php @@ -0,0 +1,30 @@ +admin) { + url::redirect(item::root()->url()); + } + + $v = new View("welcome_message.html"); + $v->user = user::active(); + print $v; + } +} diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 69c5a091..8c97f124 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -70,9 +70,9 @@ class gallery_theme_Core { return L10n_Client_Controller::l10n_form(); } - if ($session->get("after_install")) { + if (true || $session->get("after_install")) { $session->delete("after_install"); - return new View("after_install_loader.html"); + return new View("welcome_message_loader.html"); } } diff --git a/modules/gallery/views/after_install.html.php b/modules/gallery/views/after_install.html.php deleted file mode 100644 index 897946a2..00000000 --- a/modules/gallery/views/after_install.html.php +++ /dev/null @@ -1,29 +0,0 @@ - -

- -

- -

- -

- -

- %user_name account. The very first thing you should do is to change your password to something that you'll remember.", array("user_name" => $user->name)) ?> -

- -

- id}") ?>" - title="for_html_attr() ?>" - id="gAfterInstallChangePasswordLink" class="gButtonLink ui-state-default ui-corners-all"> - -

- -

- Gallery website has news and information about the Gallery project and community.", array("url" => "http://gallery.menalto.com")) ?> -

- -

- documentation site or you can ask for help in the forums!", array("codex_url" => "http://codex.gallery2.org/Main_Page", "forum_url" => "http://gallery.menalto.com/forum")) ?> - diff --git a/modules/gallery/views/after_install_loader.html.php b/modules/gallery/views/after_install_loader.html.php deleted file mode 100644 index c2e3e1d9..00000000 --- a/modules/gallery/views/after_install_loader.html.php +++ /dev/null @@ -1,7 +0,0 @@ - -for_html_attr() ?>" - href=""/> - diff --git a/modules/gallery/views/welcome_message.html.php b/modules/gallery/views/welcome_message.html.php new file mode 100644 index 00000000..5515c3dc --- /dev/null +++ b/modules/gallery/views/welcome_message.html.php @@ -0,0 +1,36 @@ + +

+

+ +

+ +

+

+ +

+

+ +

+ %user_name account. You should change your password to something that you'll remember.", array("user_name" => $user->name)) ?> +

+ +

+ id}") ?>" + title="for_html_attr() ?>" + id="gAfterInstallChangePasswordLink" + class="gButtonLink ui-state-default ui-corners-all"> + + + +

+ +

+ Gallery website has news and information about the Gallery project and community.", array("url" => "http://gallery.menalto.com")) ?> +

+ +

+ documentation site or you can ask for help in the forums!", array("codex_url" => "http://codex.gallery2.org/Main_Page", "forum_url" => "http://gallery.menalto.com/forum")) ?> +

+
diff --git a/modules/gallery/views/welcome_message_loader.html.php b/modules/gallery/views/welcome_message_loader.html.php new file mode 100644 index 00000000..2c6bffca --- /dev/null +++ b/modules/gallery/views/welcome_message_loader.html.php @@ -0,0 +1,7 @@ + +for_html_attr() ?>" + href=""/> + diff --git a/themes/default/css/screen.css b/themes/default/css/screen.css index fec618e6..d4c23155 100644 --- a/themes/default/css/screen.css +++ b/themes/default/css/screen.css @@ -773,6 +773,10 @@ form .gError, text-decoration: underline; } +#gWelcomeMessage p { + padding-bottom: 1em; +} + /* Pagination ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ .gPager { -- cgit v1.2.3 From 3dd40bf97c45c4cb2cc40e9f20796a799f4e1255 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 10 Sep 2009 21:22:07 -0700 Subject: Trim the input line to get rid of carriage returns on Windows. Fixes ticket #740. Thanks to jankoprowski! --- installer/installer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'installer/installer.php') diff --git a/installer/installer.php b/installer/installer.php index 4480e35e..7a417634 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -60,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; -- cgit v1.2.3