From 58f723374b68a796eb79971dc1738a757017672f Mon Sep 17 00:00:00 2001 From: Graham Eames Date: Wed, 22 Mar 2006 21:03:47 +0000 Subject: [PATCH] Adding in the next page of the installer Note that this still falls back to the old code part-way through the install git-svn-id: file:///svn/phpbb/trunk@5702 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/adm/style/install_install.html | 1 + phpBB/install/index.php | 4 +- phpBB/install/install_install.php | 147 +++++++++++++++++++++++++-- phpBB/install/install_main.php | 2 +- phpBB/language/en/install.php | 2 + 5 files changed, 145 insertions(+), 11 deletions(-) diff --git a/phpBB/adm/style/install_install.html b/phpBB/adm/style/install_install.html index 8e982fca44..1ba18adc5c 100755 --- a/phpBB/adm/style/install_install.html +++ b/phpBB/adm/style/install_install.html @@ -42,6 +42,7 @@
+ {S_HIDDEN}
diff --git a/phpBB/install/index.php b/phpBB/install/index.php index ce44daf0f1..421631b149 100755 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -483,7 +483,7 @@ class module /** * Generate the relevant HTML for an input field and the assosciated label and explanatory text */ - function input_field($name, $lang_key, $type, $value='', $options='') + function input_field($name, $type, $value='', $options='') { global $lang; $tpl_type = explode(':', $type); @@ -496,7 +496,7 @@ class module $size = (int) $tpl_type[1]; $maxlength = (int) $tpl_type[2]; - $tpl = ''; + $tpl = ''; break; case 'textarea': diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index eaeb045b0f..402e7d4c34 100755 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -19,7 +19,7 @@ if (!empty($setmodules)) 'module_filename' => substr(basename(__FILE__), 0, -strlen($phpEx)-1), 'module_order' => 10, 'module_subs' => '', - 'module_stages' => array('INTRO', 'REQUIREMENTS', 'BASIC', 'CONFIG_FILE', 'ADVANCED', 'FINAL'), + 'module_stages' => array('INTRO', 'REQUIREMENTS', 'DATABASE', 'CONFIG_FILE', 'ADVANCED', 'FINAL'), 'module_reqs' => '' ); @@ -37,7 +37,7 @@ class install_install extends module { global $lang, $template; - switch($sub) + switch ($sub) { case 'intro' : $this->page_title = $lang['SUB_INTRO']; @@ -55,6 +55,11 @@ class install_install extends module $this->check_server_requirements($mode, $sub); break; + + case 'database' : + $this->obtain_database_settings($mode, $sub); + + break; } $this->tpl_name = 'install_install'; @@ -305,12 +310,12 @@ class install_install extends module $write = $exists = false; } - $exists = ($exists) ? '' . $lang['FILE_FOUND'] . '' : '' . $lang['FILE_NOT_FOUND'] . ''; - $write = ($write) ? ', ' . $lang['FILE_WRITEABLE'] . '' : (($exists) ? ', ' . $lang['FILE_UNWRITEABLE'] . '' : ''); + $exists_str = ($exists) ? '' . $lang['FILE_FOUND'] . '' : '' . $lang['FILE_NOT_FOUND'] . ''; + $write_str = ($write) ? ', ' . $lang['FILE_WRITEABLE'] . '' : (($exists) ? ', ' . $lang['FILE_UNWRITEABLE'] . '' : ''); $template->assign_block_vars('checks', array( 'TITLE' => $dir, - 'RESULT' => $exists . $write, + 'RESULT' => $exists_str . $write_str, 'S_EXPLAIN' => false, 'S_LEGEND' => false, @@ -319,9 +324,7 @@ class install_install extends module // And finally where do we want to go next (well today is taken isn't it :P) $s_hidden_fields = ($img_imagick) ? '' : ''; -// $url = ($passed['php'] && $passed['db'] && $passed['files']) ? $this->p_master->module_url . "?mode=$mode&sub=database" : $this->p_master->module_url . "?mode=$mode&sub=requirements"; -// The road ahead is still under construction, follow the diversion back to the olod installer..... ;) - $url = ($passed['php'] && $passed['db'] && $passed['files']) ? "install.$phpEx?stage=1" : $this->p_master->module_url . "?mode=$mode&sub=requirements"; + $url = ($passed['php'] && $passed['db'] && $passed['files']) ? $this->p_master->module_url . "?mode=$mode&sub=database" : $this->p_master->module_url . "?mode=$mode&sub=requirements"; $submit = ($passed['php'] && $passed['db'] && $passed['files']) ? $lang['INSTALL_START'] : $lang['INSTALL_TEST']; @@ -332,6 +335,117 @@ class install_install extends module )); } + /** + * Obtain the information required to connect to the database + */ + function obtain_database_settings($mode, $sub) + { + global $lang, $template, $phpEx; + + $this->page_title = $lang['STAGE_DATABASE']; + + // Has the user opted to test the connection? +/* if (isset($_POST['testdb'])) + { + // If the module for the selected database isn't loaded, let's try and load it now + if (!@extension_loaded($available_dbms[$dbms]['MODULE'])) + { + if (!$this->can_load_dll($available_dbms[$dbms]['MODULE'])) + { + $error['db'][] = $lang['INST_ERR_NO_DB'];; + } + } + + $this->connect_check_db(true, $error, $dbms, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport); + } +*/ + // Update the list of available DBMS modules to only contain those which can be used + $available_dbms_temp = array(); + foreach ($this->available_dbms as $type => $dbms_ary) + { + if (!extension_loaded($dbms_ary['MODULE'])) + { + if (!$this->can_load_dll($dbms_ary['MODULE'])) + { + continue; + } + } + + $available_dbms_temp[$type] = $dbms_ary; + } + + $this->available_dbms = &$available_dbms_temp; + + // Obtain any submitted data + foreach ($this->request_vars as $var) + { + $$var = request_var($var, ''); + } + + // And now for the main part of this page + $config_options = array( + 'legend' => 'DB_CONFIG', + 'dbms' => array('lang' => 'DBMS', 'type' => 'select', 'options' => '$this->module->dbms_select(\'{VALUE}\')', 'explain' => false), + 'dbhost' => array('lang' => 'DB_HOST', 'type' => 'text:25:100', 'explain' => true), + 'dbport' => array('lang' => 'DB_PORT', 'type' => 'text:25:100', 'explain' => true), + 'dbname' => array('lang' => 'DB_NAME', 'type' => 'text:25:100', 'explain' => false), + 'dbuser' => array('lang' => 'DB_USERNAME', 'type' => 'text:25:100', 'explain' => false), + 'dbpasswd' => array('lang' => 'DB_PASSWORD', 'type' => 'password:25:100', 'explain' => false), + 'table_prefix' => array('lang' => 'TABLE_PREFIX', 'type' => 'text:25:100', 'explain' => false), + ); + + $table_prefix = (!empty($table_prefix) ? $table_prefix : 'phpbb_'); + + foreach ($config_options as $config_key => $vars) + { + if (!is_array($vars) && strpos($config_key, 'legend') === false) + { + continue; + } + + if (strpos($config_key, 'legend') !== false) + { + $template->assign_block_vars('options', array( + 'S_LEGEND' => true, + 'LEGEND' => $lang[$vars]) + ); + + continue; + } + + $options = isset($vars['options']) ? $vars['options'] : ''; + + $template->assign_block_vars('options', array( + 'KEY' => $config_key, + 'TITLE' => $lang[$vars['lang']], + 'S_EXPLAIN' => $vars['explain'], + 'S_LEGEND' => false, + 'TITLE_EXPLAIN' => ($vars['explain']) ? $lang[$vars['lang'] . '_EXPLAIN'] : '', + 'CONTENT' => $this->p_master->input_field($config_key, $vars['type'], $$config_key, $options), + ) + ); + } + + // And finally where do we want to go next (well today is taken isn't it :P) + $s_hidden_fields = ($img_imagick) ? '' : ''; + +// $url = $this->p_master->module_url . "?mode=$mode&sub=administrator"; +// The road ahead is still under construction, follow the diversion back to the old installer..... ;) + $s_hidden_fields .= ''; + $url = "install.$phpEx?stage=1"; + $submit = $lang['NEXT_STEP']; + + + $template->assign_vars(array( + 'L_SUBMIT' => $submit, + 'S_HIDDEN' => $s_hidden_fields, + 'U_ACTION' => $url, + )); + } + + /** + * Determine if we are able to load a specified PHP module + */ function can_load_dll($dll) { global $suffix; @@ -339,6 +453,23 @@ class install_install extends module return ((@ini_get('enable_dl') || strtolower(@ini_get('enable_dl')) == 'on') && (!@ini_get('safe_mode') || strtolower(@ini_get('safe_mode')) == 'off') && @dl($dll . ".$suffix")) ? true : false; } + function dbms_select($default='') + { + $dbms_options = ''; + foreach ($this->available_dbms as $dbms_name => $details) + { + $selected = ($dbms_name == $default) ? ' selected="selected"' : ''; + $dbms_options .= ''; + } + return $dbms_options; + } + + /** + * The variables that we will be passing between pages + * Used to retrieve data quickly on each page + */ + var $request_vars = array('language', 'dbms', 'dbhost', 'dbport', 'dbuser', 'dbpasswd', 'dbname', 'table_prefix', 'admin_name', 'admin_pass1', 'admin_pass2', 'board_email1', 'board_email2', 'server_name', 'server_port', 'script_path', 'img_imagick', 'ftp_path', 'ftp_user', 'ftp_pass'); + /** * Specific PHP modules we may require for certain optional or extended features */ diff --git a/phpBB/install/install_main.php b/phpBB/install/install_main.php index 271705b51d..cde8bcb3f2 100755 --- a/phpBB/install/install_main.php +++ b/phpBB/install/install_main.php @@ -36,7 +36,7 @@ class install_main extends module { global $lang, $template; - switch($sub) + switch ($sub) { case 'intro' : $title = $lang['SUB_INTRO']; diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 6df64608c0..a5463698f7 100755 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -127,6 +127,7 @@ $lang = array_merge($lang, array( 'INST_ERR_PASSWORD_MISMATCH'=> 'The passwords you entered did not match.', 'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.', + 'NEXT_STEP' => 'Proceed to next step', 'NO_LOCATION' => 'Cannot determine location', // TODO: Write some explanatory introduction text 'OVERVIEW_BODY' => '

Some brief explanatory text about phpBB will go here.

This installation system will guide you through the process of installing phpBB, converting from a different software package or updating to the latest version of phpBB. For more information on each option, select it from the menu above

', @@ -155,6 +156,7 @@ $lang = array_merge($lang, array( 'SERVER_NAME_EXPLAIN' => 'The domain name this board runs from', 'SERVER_PORT' => 'Server port', 'SERVER_PORT_EXPLAIN' => 'The port your server is running on, usually 80, only change if different', + 'STAGE_DATABASE' => 'Database Settings', 'STAGE_INTRO' => 'Introduction', 'STAGE_REQUIREMENTS' => 'Requirements', 'SUB_INTRO' => 'Introduction',