diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2009-01-18 18:13:54 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2009-01-18 18:13:54 +0000 |
commit | 72e7d50176a61eb5bb866ebe64607de6e23d21f2 (patch) | |
tree | 9764172de28115630ea6df7ca8277e4b6fb50f16 | |
parent | dd5be1ece03427f9ad7dada7891df8791ab7b2e1 (diff) |
Remove the install.php file and move its contents into
installer::command_line method. Create an index.php that is can be
used to install Gallery3 from the web or command line. At this point
all that works is the command line installer and if the web installer
tries to run, it is redirected to the album main page.
-rw-r--r-- | installer/helpers/installer.php | 39 | ||||
-rw-r--r-- | installer/index.php (renamed from installer/install.php) | 50 |
2 files changed, 59 insertions, 30 deletions
diff --git a/installer/helpers/installer.php b/installer/helpers/installer.php index 6d866b90..871308d4 100644 --- a/installer/helpers/installer.php +++ b/installer/helpers/installer.php @@ -23,6 +23,45 @@ class installer { private static $database = null; private static $config_errors = false; + static function command_line() { + // remove the script name from the arguments + array_shift($_SERVER["argv"]); + + //$_SERVER["HTTP_USER_AGENT"] = phpversion(); + //date_default_timezone_set('America/Los_Angeles'); + + set_error_handler(create_function('$errno, $errstr, $errfile, $errline', + 'throw new ErrorException($errstr, 0, $errno, $errfile, $errline);')); + + // Set exception handler + set_exception_handler(array("installer", "print_exception")); + + // @todo Log the results of failed call + if (!installer::environment_check()) { + self::display_requirements(); + die; + } + + self::parse_cli_parms($_SERVER["argv"]); + + $config_valid = true; + + try { + $config_valid = self::check_database_authorization(); + } catch (Exception $e) { + self::print_exception($e); + die("Specifed User does not have sufficient authority to install Gallery3\n"); + } + + $config_valid &= self::check_docroot_writable(); + + self::display_requirements(!$config_valid); + + if ($config_valid) { + print self::install(); + } + } + static function environment_check() { $failed = false; $section = array("header" => "Environment Test", diff --git a/installer/install.php b/installer/index.php index c33dff49..a8cc4aae 100644 --- a/installer/install.php +++ b/installer/index.php @@ -18,8 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /** - * Batch Install program this is to only be run from the command line. The web interface uses - * a different approach to invoking the installer + * The main install program to install Gallery3. * Command line parameters: * -h Database host (default: localhost) * -u Database user (default: root) @@ -35,44 +34,35 @@ * on the command line will override values contained in this file */ -function exception_handler($exception) { - installer::print_exception($exception); - exit; -} - -if (PHP_SAPI != "cli") { - $redirect = str_replace("install.php", "index.php", $_SERVER["REQUEST_URI"]); - - header("Location: $redirect"); - return; -} - -if (file_exists("var/installed")) { - die("Gallery3 is already installed... exiting\n"); -} +define("DOCROOT", dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR); -array_shift($argv); // remove the script name from the arguments +// Define application and system paths +define('APPPATH', DOCROOT . 'core' . DIRECTORY_SEPARATOR); +define('MODPATH', DOCROOT . 'modules' . DIRECTORY_SEPARATOR); +define('THEMEPATH', DOCROOT . 'themes' . DIRECTORY_SEPARATOR); +define('SYSPATH', DOCROOT . 'kohana' . DIRECTORY_SEPARATOR); -define("DOCROOT", dirname(dirname(__FILE__)) . "/"); -chdir(DOCROOT); -define('APPPATH', realpath('core') . '/'); -define('MODPATH', realpath('modules') . '/'); -define('THEMEPATH', realpath('themes') . '/'); -define('SYSPATH', realpath('kohana') . '/'); -define('VARPATH', realpath('var') . '/'); +define('VARPATH', DOCROOT . 'var' . DIRECTORY_SEPARATOR); define('TEST_MODE', 0); define('EXT', ".php"); -$_SERVER["HTTP_USER_AGENT"] = phpversion(); -date_default_timezone_set('America/Los_Angeles'); +include DOCROOT . "installer/helpers/installer.php"; + +if (PHP_SAPI == "cli") { + installer::command_line(); + exit; +} + +if (file_exists(VARPATH . "installed")) { + header("Location: ../index.php/albums/1"); + exit; +} set_error_handler(create_function('$errno, $errstr, $errfile, $errline', 'throw new ErrorException($errstr, 0, $errno, $errfile, $errline);')); // Set exception handler -set_exception_handler('exception_handler'); - -include DOCROOT . "installer/helpers/installer.php"; +set_exception_handler(array("installer", "print_exception")); // @todo Log the results of failed call if (!installer::environment_check()) { |