diff options
-rw-r--r-- | core/controllers/after_install.php | 30 | ||||
-rw-r--r-- | core/helpers/core_installer.php | 8 | ||||
-rw-r--r-- | core/helpers/core_theme.php | 4 | ||||
-rw-r--r-- | core/views/after_install.html.php | 28 | ||||
-rw-r--r-- | core/views/after_install_loader.html.php | 6 | ||||
-rw-r--r-- | installer/install.sql | 20 | ||||
-rw-r--r-- | installer/installer.php | 19 | ||||
-rw-r--r-- | installer/views/success.html.php | 2 | ||||
-rw-r--r-- | installer/web.php | 1 | ||||
-rw-r--r-- | modules/user/helpers/user.php | 11 |
10 files changed, 113 insertions, 16 deletions
diff --git a/core/controllers/after_install.php b/core/controllers/after_install.php new file mode 100644 index 00000000..ac5756b9 --- /dev/null +++ b/core/controllers/after_install.php @@ -0,0 +1,30 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class After_Install_Controller extends Controller { + public function index() { + if (!user::active()->admin) { + url::redirect("albums/1"); + } + + $v = new View("after_install.html"); + $v->user = user::active(); + print $v; + } +} diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index 06cd8d91..5c3b9ff0 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -82,7 +82,7 @@ class core_installer { PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`), KEY `type` (`type`), - KEY `random` (`rand_key` DESC)) + KEY `random` (`rand_key`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); $db->query("CREATE TABLE {logs} ( @@ -122,7 +122,7 @@ class core_installer { PRIMARY KEY (`id`), UNIQUE KEY(`name`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - + $db->query("CREATE TABLE {permissions} ( `id` int(9) NOT NULL auto_increment, `name` varchar(64) default NULL, @@ -195,9 +195,9 @@ class core_installer { access::register_permission("edit", "Edit"); $root = ORM::factory("item"); - $root->type = 'album'; + $root->type = "album"; $root->title = "Gallery"; - $root->description = "Welcome to your Gallery3"; + $root->description = ""; $root->left = 1; $root->right = 2; $root->parent_id = 0; diff --git a/core/helpers/core_theme.php b/core/helpers/core_theme.php index db40f368..eed64ded 100644 --- a/core/helpers/core_theme.php +++ b/core/helpers/core_theme.php @@ -88,6 +88,10 @@ class core_theme_Core { if (Session::instance()->get("l10n_mode", false)) { return L10n_Client_Controller::l10n_form(); } + + if (Input::instance()->get("after_install")) { + return new View("after_install_loader.html"); + } } static function admin_page_bottom($theme) { diff --git a/core/views/after_install.html.php b/core/views/after_install.html.php new file mode 100644 index 00000000..443141b5 --- /dev/null +++ b/core/views/after_install.html.php @@ -0,0 +1,28 @@ +<h1 style="display: none"> + <?= t("Welcome to Gallery 3!") ?> +</h1> + +<p> + <?= t("Congratulations on choosing Gallery to host your photos. We're confident that you're going to have a great experience.") ?> +</p> + +<p> + <?= t("You're logged in to the <b>%user_name</b> account. The very first thing you should do is to change your password to something that you'll remember.", array("user_name" => $user->name)) ?> +</p> + +<p> + <a href="<?= url::site("form/edit/users/{$user->id}") ?>" + title="<?= t("Edit Your Profile") ?>" + id="gAfterInstallChangePasswordLink"><?= t("Change Password Now") ?></a> + <script> + $("#gAfterInstallChangePasswordLink").bind("click", handleDialogEvent); + </script> +</p> + +<p> + <?= t("Want to learn more about Gallery? The <a href=\"%url\">Gallery website</a> has news and information about Gallery and the Gallery community.", array("url" => "http://gallery.menalto.com")) ?> +</p> + +<p> + <?= t("Having problems? We've got lots of information in our <a href=\"%codex_url\">documentation site</a> or you can <a href=\"%forum_url\">ask for help in the forums!</a>", array("codex_url" => "http://codex.gallery2.org/Main_Page", "forum_url" => "http://gallery.menalto.com/forum")) ?> +</ul> diff --git a/core/views/after_install_loader.html.php b/core/views/after_install_loader.html.php new file mode 100644 index 00000000..0e0ea1d0 --- /dev/null +++ b/core/views/after_install_loader.html.php @@ -0,0 +1,6 @@ +<span id="gAfterInstall" + title="<?= t("Welcome to Gallery 3") ?>" + href="<?= url::site("after_install") ?>"/> +<script type="text/javascript"> + $(document).ready(function(){openDialog($("#gAfterInstall"));}); +</script> diff --git a/installer/install.sql b/installer/install.sql index a3ae66ef..4afa2399 100644 --- a/installer/install.sql +++ b/installer/install.sql @@ -136,18 +136,18 @@ CREATE TABLE {items} ( `updated` int(9) default NULL, `view_count` int(9) default '0', `width` int(9) default NULL, + `rand_key` float default NULL, + `sort_column` varchar(64) default NULL, `view_1` tinyint(2) NOT NULL default '0', `view_2` tinyint(2) NOT NULL default '0', - `rand_key` float default NULL, - `sort_column` varchar(255) default NULL, PRIMARY KEY (`id`), KEY `parent_id` (`parent_id`), KEY `type` (`type`), - KEY `random` (`rand_key` DESC) + KEY `random` (`rand_key`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {items} VALUES (NULL,1234232381,'Welcome to your Gallery3',NULL,1,1,1,NULL,NULL,2,0,NULL,NULL,1,2,NULL,NULL,1,'Gallery','album',1234232381,0,NULL,1,1,NULL,NULL); -DROP TABLE IF EXISTS `items_tags`; +INSERT INTO {items} VALUES (NULL,1236547219,'',NULL,1,1,1,NULL,NULL,NULL,0,NULL,NULL,1,2,NULL,NULL,1,'Gallery','album',1236547219,0,NULL,NULL,NULL,1,1); +DROP TABLE IF EXISTS {items_tags}; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE {items_tags} ( @@ -238,8 +238,8 @@ CREATE TABLE {search_records} ( FULLTEXT KEY `data` (`data`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {search_records} VALUES (1,1,0,'Welcome to your Gallery3 Gallery '); -DROP TABLE IF EXISTS `sessions`; +INSERT INTO {search_records} VALUES (1,1,0,' Gallery '); +DROP TABLE IF EXISTS {sessions}; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; CREATE TABLE {sessions} ( @@ -275,7 +275,7 @@ CREATE TABLE {tasks} ( `status` varchar(255) default NULL, `owner_id` int(9) default NULL, PRIMARY KEY (`id`), - KEY (`owner_id`) + KEY `owner_id` (`owner_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; DROP TABLE IF EXISTS {themes}; @@ -311,7 +311,7 @@ CREATE TABLE {users} ( UNIQUE KEY `hash` (`hash`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {users} VALUES (1,'guest','Guest User','[oS\\615de701682051a9970409c02c94ca94',0,0,NULL,0,1,NULL,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); +INSERT INTO {users} VALUES (1,'guest','Guest User','ep^Of48514725fd40c706ceb2565ccceacb3',0,0,NULL,0,1,NULL,NULL,NULL),(2,'admin','Gallery Administrator','',0,0,NULL,1,0,NULL,NULL,NULL); DROP TABLE IF EXISTS {vars}; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; @@ -324,4 +324,4 @@ CREATE TABLE {vars} ( UNIQUE KEY `module_name` (`module_name`,`name`) ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; SET character_set_client = @saved_cs_client; -INSERT INTO {vars} VALUES (1,'core','active_site_theme','default'),(2,'core','active_admin_theme','admin_default'),(3,'core','page_size','9'),(4,'core','thumb_size','200'),(5,'core','resize_size','640'),(6,'core','default_locale','en_US'),(7,'core','graphics_toolkit','imagemagick'),(8,'core','graphics_toolkit_path','/usr/bin'),(9,'core','blocks_dashboard_sidebar','a:4:{i:373668224;a:2:{i:0;s:4:\"core\";i:1;s:11:\"block_adder\";}i:838141216;a:2:{i:0;s:4:\"core\";i:1;s:5:\"stats\";}i:26528;a:2:{i:0;s:4:\"core\";i:1;s:13:\"platform_info\";}i:1914449606;a:2:{i:0;s:4:\"core\";i:1;s:12:\"project_news\";}}'),(10,'core','blocks_dashboard_center','a:4:{i:551308471;a:2:{i:0;s:4:\"core\";i:1;s:7:\"welcome\";}i:412910748;a:2:{i:0;s:4:\"core\";i:1;s:12:\"photo_stream\";}i:1418841915;a:2:{i:0;s:4:\"core\";i:1;s:11:\"log_entries\";}i:690142318;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(11,'core','version','3.0'),(12,'comment','spam_caught','0'); +INSERT INTO {vars} VALUES (1,'core','active_site_theme','default'),(2,'core','active_admin_theme','admin_default'),(3,'core','page_size','9'),(4,'core','thumb_size','200'),(5,'core','resize_size','640'),(6,'core','default_locale','en_US'),(7,'core','graphics_toolkit','imagemagick'),(8,'core','graphics_toolkit_path','/usr/bin'),(9,'core','blocks_dashboard_sidebar','a:1:{i:1792454813;a:2:{i:0;s:4:\"core\";i:1;s:12:\"project_news\";}}'),(10,'core','blocks_dashboard_center','a:1:{i:295582972;a:2:{i:0;s:7:\"comment\";i:1;s:15:\"recent_comments\";}}'),(11,'core','version','3.0'),(12,'comment','spam_caught','0'); diff --git a/installer/installer.php b/installer/installer.php index 9ea551a8..ff727340 100644 --- a/installer/installer.php +++ b/installer/installer.php @@ -98,6 +98,25 @@ class installer { return array("admin", $password); } + static function create_admin_session($config) { + $session_id = md5(time() * rand()); + $user_agent = $_SERVER["HTTP_USER_AGENT"]; + $user_agent_len = strlen($user_agent); + $now = time(); + $data = "session_id|s:32:\"$session_id\""; + $data .= ";user_agent|s:{$user_agent_len}:\"$user_agent\""; + $data .= ";user|i:2"; + $data .= ";last_activity|i:$now"; + $data = base64_encode($data); + $sql = "INSERT INTO {sessions} VALUES('$session_id', $now, '$data')"; + $sql = self::prepend_prefix($config["prefix"], $sql); + if (mysql_query($sql)) { + setcookie("g3sid", $session_id, 0, "/", "", false, false); + } else { + throw new Exception(mysql_error()); + } + } + static function create_private_key($config) { $key = md5(uniqid(mt_rand(), true)) . md5(uniqid(mt_rand(), true)); $sql = self::prepend_prefix($config["prefix"], diff --git a/installer/views/success.html.php b/installer/views/success.html.php index 4bca2fb1..d7dbc4d1 100644 --- a/installer/views/success.html.php +++ b/installer/views/success.html.php @@ -19,5 +19,5 @@ </p> <?php endif ?> -<h2> <a href="..">Start using Gallery</a> </h2> +<h2> <a href="..?after_install=1">Start using Gallery</a> </h2> diff --git a/installer/web.php b/installer/web.php index 27124cd9..387a26bb 100644 --- a/installer/web.php +++ b/installer/web.php @@ -54,6 +54,7 @@ if (installer::already_installed()) { } else { try { list ($user, $password) = installer::create_admin($config); + installer::create_admin_session($config); $content = render("success.html.php", array("user" => $user, "password" => $password)); installer::create_private_key($config); diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index 22fe6a28..a15fa463 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -118,6 +118,13 @@ class user_Core { $session->set("user", $user = user::guest()); } + // The installer cannot set a user into the session, so it just sets an id which we should + // upconvert into a user. + if ($user === 2) { + $user = model_cache::get("user", 2); + $session->set("user", $user); + } + if (!$session->get("group_ids")) { $ids = array(); foreach ($user->groups as $group) { @@ -142,7 +149,9 @@ class user_Core { * @return User_Model */ static function active() { - return Session::instance()->get("user", self::guest()); + // @todo (maybe) cache this object so we're not always doing session lookups. + $user = Session::instance()->get("user", self::guest()); + return $user; } /** |