Permalink
Browse files

Move installation check to index.php

* It makes more sense to perform the installation check in index.php;
before the Kohana framework is bootstrapped. In light of this change,
config.php has to be created from the provided template and has also
been added as entry in .gitignore. The same goes for encryption.php and
auth.php - these files are now automatically created by the installer.
Consequently, the "requirements" view in the installer has also been
updated to reflect this change

* The v.93-94 DB upgrade seems to have left out the changes from to the
main setup script (ushahidi.sql)
  • Loading branch information...
ekala committed Jun 17, 2012
1 parent 1e935ed commit 9e0f9c630ea30a683f77b3aee3938cf5b914b676
View
@@ -5,5 +5,8 @@
application/logs/*
application/cache/*
media/uploads/*
+application/config/auth.php
+application/config/config.php
application/config/database.php
+application/config/encryption.php
tests/phpunit/phpunit.xml
@@ -28,7 +28,7 @@
* will be increased by the total number of offsets.
* CHANGE ME: THIS SHOULD BE UNIQUE TO YOUR DEPLOYMENT
*/
-$config['salt_pattern'] = '3, 5, 6, 10, 24, 26, 35, 36, 37, 40';
+$config['salt_pattern'] = '8, 10, 12, 21, 22, 23, 29, 34, 38, 39';
/**
* Set the auto-login (remember me) cookie lifetime, in seconds. The default
@@ -18,7 +18,7 @@
*
* This can be removed by using URL rewriting.
*/
-$config['index_page'] = '';
+$config['index_page'] = 'index.php';
/**
* Whether or not you want to have the auto upgrader enabled.
@@ -154,10 +154,10 @@
*/
$config['modules'] = array
(
- MODPATH.'auth', // Authentication
- MODPATH.'csrf', // CSRF Handling
+ MODPATH.'auth', // Authentication
+ MODPATH.'csrf', // CSRF Handling
// MODPATH.'forge', // Form generation
- // MODPATH.'formation', // Form generation
+ // MODPATH.'formation', // Form generation
// MODPATH.'kodoc', // Self-generating documentation
// MODPATH.'media', // Media caching and compression
// MODPATH.'archive', // Archive utility
@@ -18,7 +18,7 @@
*
* This can be removed by using URL rewriting.
*/
-$config['index_page'] = '';
+$config['index_page'] = 'index.php';
/**
* Whether or not you want to have the auto upgrader enabled.
@@ -154,10 +154,10 @@
*/
$config['modules'] = array
(
- MODPATH.'auth', // Authentication
- MODPATH.'csrf', // CSRF Handling
+ MODPATH.'auth', // Authentication
+ MODPATH.'csrf', // CSRF Handling
// MODPATH.'forge', // Form generation
- // MODPATH.'formation', // Form generation
+ // MODPATH.'formation', // Form generation
// MODPATH.'kodoc', // Self-generating documentation
// MODPATH.'media', // Media caching and compression
// MODPATH.'archive', // Archive utility
@@ -906,7 +906,7 @@ public function geocode()
/**
* Retrieves Cities
- * @param int $country_id Id of teh country whose cities are to be fetched
+ * @param int $country_id Id of the country whose cities are to be fetched
* @return array
*/
private function _get_cities($country_id)
@@ -1,30 +0,0 @@
-<?php defined('SYSPATH') or die('No direct script access.');
-/**
-* Initiate Instance. Verify Install
-* If we can't find application/config/database.php, we assume Ushahidi
-* is not installed so redirect user to installer
-*/
-
-if (Kohana::config('config.installer_check') == TRUE)
-{
- if ( ! file_exists(DOCROOT."application/config/database.php"))
- {
- if ($_SERVER["SERVER_PORT"] != "80" AND $_SERVER["SERVER_PORT"] != "443")
- {
- $url = $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
- }
- else
- {
- $url = $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
- }
-
- $installer = "http://${url}installer/";
-
- if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on')
- {
- $installer = str_replace('http://', 'https://', $installer);
- }
-
- url::redirect($installer);
- }
-}
View
@@ -115,12 +115,12 @@
is_link(KOHANA) and chdir(dirname(realpath(__FILE__)));
// Define application and system paths
-define('APPPATH', str_replace('\\', '/', realpath($kohana_application)).'/');
-define('THEMEPATH', str_replace('\\', '/', realpath($kohana_themes)).'/');
-define('PLUGINPATH', str_replace('\\', '/', realpath($kohana_plugins)).'/');
-define('MODPATH', str_replace('\\', '/', realpath($kohana_modules)).'/');
-define('SYSPATH', str_replace('\\', '/', realpath($kohana_system)).'/');
-define('MEDIAPATH', str_replace('\\', '/', realpath($kohana_media)).'/');
+define('APPPATH', str_replace('\\', '/', realpath($kohana_application)).DIRECTORY_SEPARATOR);
+define('THEMEPATH', str_replace('\\', '/', realpath($kohana_themes)).DIRECTORY_SEPARATOR);
+define('PLUGINPATH', str_replace('\\', '/', realpath($kohana_plugins)).DIRECTORY_SEPARATOR);
+define('MODPATH', str_replace('\\', '/', realpath($kohana_modules)).DIRECTORY_SEPARATOR);
+define('SYSPATH', str_replace('\\', '/', realpath($kohana_system)).DIRECTORY_SEPARATOR);
+define('MEDIAPATH', str_replace('\\', '/', realpath($kohana_media)).DIRECTORY_SEPARATOR);
// Clean up
unset($kohana_application, $kohana_themes, $kohana_plugins, $kohana_modules, $kohana_system, $kohana_media);
@@ -154,6 +154,30 @@
}
}
-
-// Initialize.
-require SYSPATH.'core/Bootstrap'.EXT;
+//
+// Check if the application has been installed
+// This has to be done before bootstrapping the Kohana framework
+//
+if ( ! file_exists(APPPATH.'config'.DIRECTORY_SEPARATOR.'database.php'))
+{
+ // Get the server protocol
+ $protocol = (isset($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'on')
+ ? 'https'
+ : 'http';
+
+ // Server port
+ $port = ! in_array($_SERVER['SERVER_PORT'], array("80", "443"))
+ ? ':'.$_SERVER['SERVER_PORT']
+ : '';
+
+ // Generate the redirect URL
+ $url = $protocol.'://'.$_SERVER['SERVER_NAME'].$port.'/installer';
+
+ // Redirect to the installer
+ header(sprintf("Location: %s", $url));
+}
+else
+{
+ // Initialize.
+ require SYSPATH.'core/Bootstrap'.EXT;
+}
View
@@ -1,4 +1,5 @@
<?php
+// ini_set('display_errors', 'On');
/**
* This file acts as the bootstrap for the installer.
* It forwards all HTTP requests to the Install_Wizard class
@@ -15,18 +16,18 @@
require INSTALLER_DIR . 'utils.php';
// Bootstrap the installer
-Install_Wizard::init();
+Installer_Wizard::init();
if ($_POST)
{
if (isset($_POST['previous']))
{
- Install_Wizard::previous();
+ Installer_Wizard::previous();
}
else
{
// Show the next step
- Install_Wizard::next();
+ Installer_Wizard::next();
}
}
@@ -16,7 +16,7 @@
<div class="feedback success">
<h2>Installation Successful!</h2>
</div>
- <p>To login, go to <a href="<?php echo $base_url; ?>/admin" target="_blank">
+ <p>To login, go to <a href="<?php echo $base_url; ?>admin" target="_blank">
<?php echo $base_url."admin"; ?></a> and use the following credentials:<br /><br />
<strong>Login Email:</strong> <?php echo $admin_email; ?><br />
<strong>Password:</strong> (not shown)</p>
@@ -20,8 +20,6 @@
<div class="feedback info">
<p>Before you get started, you will need to make sure the following files and folders are writable by your webserver. This involves changing file permissions.</p>
<ul>
- <li>application/config/config.php</li>
- <li>application/config/encryption.php</li>
<li>application/config</li>
<li>application/cache</li>
<li>application/logs</li>
Oops, something went wrong.

3 comments on commit 9e0f9c6

@rjmackay

This comment has been minimized.

Show comment Hide comment
@rjmackay

rjmackay Jun 17, 2012

Owner

Does this mean the installer_check setting in config.php will no longer work?

/**
 * Check if we should launch the installer or not
 */
$config['installer_check'] = TRUE;

Probably not a major issue unless this is a problem for Crowdmap - ie. they never want to see the installer

Owner

rjmackay replied Jun 17, 2012

Does this mean the installer_check setting in config.php will no longer work?

/**
 * Check if we should launch the installer or not
 */
$config['installer_check'] = TRUE;

Probably not a major issue unless this is a problem for Crowdmap - ie. they never want to see the installer

@ekala

This comment has been minimized.

Show comment Hide comment
@ekala

ekala Jun 18, 2012

Collaborator

We could still supress the installer check in index.php. All the same, pinging @brianherbert and @evansims

Collaborator

ekala replied Jun 18, 2012

We could still supress the installer check in index.php. All the same, pinging @brianherbert and @evansims

@brianherbert

This comment has been minimized.

Show comment Hide comment
@brianherbert

brianherbert Jun 18, 2012

Contributor
Contributor

brianherbert replied Jun 18, 2012

Please sign in to comment.