diff --git a/admin/install.php b/admin/install.php index 7565d72182..cb0cddaded 100644 --- a/admin/install.php +++ b/admin/install.php @@ -106,11 +106,15 @@ function InsertData( $p_table, $p_data ) { $t_install_state = gpc_get_int( 'install', 0 ); html_begin(); +html_head_begin(); +html_css_link( 'admin.css' ); +html_content_type(); +html_title( 'Administration - Installation' ); +html_javascript_link( 'jquery-1.9.1.min.js' ); +html_javascript_link( 'install.js' ); +html_head_end(); ?> - - MantisBT Administration - Installation - - + @@ -149,7 +153,6 @@ function InsertData( $p_table, $p_data ) {


-
@@ -164,28 +167,72 @@ function InsertData( $p_table, $p_data ) { $t_config_filename = $g_absolute_path . 'config_inc.php'; $t_config_exists = file_exists( $t_config_filename ); -$f_hostname = null; -$f_db_type = null; -$f_database_name = null; -$f_db_username = null; -$f_db_password = null; -if( $t_config_exists ) { - if( 0 == $t_install_state ) { - print_test( "Config File Exists - Upgrade", true ); - } +# Initialize Oracle-specific values for prefix and suffix, and set +# values for other db's as per config defaults +$t_prefix_defaults = array( + 'oci8' => array( + 'db_table_prefix' => 'm', + 'db_table_plugin_prefix' => 'plg', + 'db_table_suffix' => '', + ) , +); +foreach( $t_prefix_defaults['oci8'] as $t_key => $t_value ) { + $t_prefix_defaults['other'][$t_key] = config_get( $t_key, '' ); +} + +if( $t_config_exists && $t_install_state <= 1 ) { # config already exists - probably an upgrade + $f_dsn = config_get( 'dsn', '' ); + $f_hostname = config_get( 'hostname', '' ); + $f_db_type = config_get( 'db_type', '' ); + $f_database_name = config_get( 'database_name', '' ); + $f_db_schema = config_get( 'db_schema', '' ); + $f_db_username = config_get( 'db_username', '' ); + $f_db_password = config_get( 'db_password', '' ); + $f_timezone = config_get( 'default_timezone', '' ); + $f_crypto_master_salt = config_get( 'crypto_master_salt', '' ); + + # Set default prefix/suffix form variables ($f_db_table_XXX) + foreach( $t_prefix_defaults['other'] as $t_key => $t_value ) { + ${'f_' . $t_key} = $t_value; + } +} else { + # read control variables with defaults + $f_dsn = gpc_get( 'dsn', config_get( 'dsn', '' ) ); + $f_hostname = gpc_get( 'hostname', config_get( 'hostname', 'localhost' ) ); + $f_db_type = gpc_get( 'db_type', config_get( 'db_type', '' ) ); + $f_database_name = gpc_get( 'database_name', config_get( 'database_name', 'bugtracker' ) ); + $f_db_schema = gpc_get( 'db_schema', config_get( 'db_schema', '' ) ); + $f_db_username = gpc_get( 'db_username', config_get( 'db_username', '' ) ); + $f_db_password = gpc_get( 'db_password', config_get( 'db_password', '' ) ); + if( CONFIGURED_PASSWORD == $f_db_password ) { + $f_db_password = config_get( 'db_password' ); + } + $f_timezone = gpc_get( 'timezone', config_get( 'default_timezone' ) ); + $f_crypto_master_salt = gpc_get( 'crypto_master_salt', config_get( 'crypto_master_salt' ) ); - $f_dsn = config_get( 'dsn', '' ); - $f_hostname = config_get( 'hostname', '' ); - $f_db_type = config_get( 'db_type', '' ); - $f_database_name = config_get( 'database_name', '' ); - $f_db_username = config_get( 'db_username', '' ); - $f_db_password = config_get( 'db_password', '' ); + # Set default prefix/suffix form variables ($f_db_table_XXX) + $t_prefix_type = $f_db_type == 'oci8' ? $f_db_type : 'other'; + foreach( $t_prefix_defaults[$t_prefix_type] as $t_key => $t_value ) { + ${'f_' . $t_key} = gpc_get( $t_key, $t_value ); + } +} +$f_admin_username = gpc_get( 'admin_username', '' ); +$f_admin_password = gpc_get( 'admin_password', '' ); +if( CONFIGURED_PASSWORD == $f_admin_password ) { + $f_admin_password = ''; +} +$f_log_queries = gpc_get_bool( 'log_queries', false ); +$f_db_exists = gpc_get_bool( 'db_exists', false ); +if( $t_config_exists ) { if( 0 == $t_install_state ) { + print_test( "Config File Exists - Upgrade", true ); + print_test( 'Setting Database Type', '' !== $f_db_type, true, 'database type is blank?' ); + # @TODO: dsn config seems to be undefined, remove ? $t_db_conn_exists = ( $f_dsn !== '' || ( $f_database_name !== '' && $f_db_username !== '' && $f_hostname !== '' ) ); # Oracle supports binding in two ways: # - hostname, username/password and database name @@ -227,23 +274,8 @@ function InsertData( $p_table, $p_data ) { print_test( 'Config File Exists but Database does not', false, false, 'Bad config_inc.php?' ); } } -} else { - # read control variables with defaults - $f_hostname = gpc_get( 'hostname', config_get( 'hostname', 'localhost' ) ); - $f_db_type = gpc_get( 'db_type', config_get( 'db_type', '' ) ); - $f_database_name = gpc_get( 'database_name', config_get( 'database_name', 'bugtrack' ) ); - $f_db_username = gpc_get( 'db_username', config_get( 'db_username', '' ) ); - $f_db_password = gpc_get( 'db_password', config_get( 'db_password', '' ) ); - if( CONFIGURED_PASSWORD == $f_db_password ) { - $f_db_password = config_get( 'db_password' ); - } } -$f_admin_username = gpc_get( 'admin_username', '' ); -$f_admin_password = gpc_get( 'admin_password', '' ); -$f_log_queries = gpc_get_bool( 'log_queries', false ); -$f_db_exists = gpc_get_bool( 'db_exists', false ); -$f_db_schema = ''; if( $f_db_type == 'db2' ) { # If schema name is supplied, then separate it from database name. @@ -278,16 +310,14 @@ function InsertData( $p_table, $p_data ) { ?> - - - - - @@ -353,6 +379,12 @@ function InsertData( $p_table, $p_data ) { } else { print_test_result( GOOD ); } + + # due to a bug in ADODB, this call prompts warnings, hence the @ + # the check only works on mysql if the database is open + $t_version_info = @$g_db->ServerInfo(); + echo '
Running ' . $f_db_type . ' version ' . nl2br( $t_version_info['description'] ); + } else { print_test_result( BAD, true, 'Does administrative user have access to the database? ( ' . db_error_msg() . ' )' ); } @@ -394,9 +426,6 @@ function InsertData( $p_table, $p_data ) { @@ -440,20 +469,51 @@ function InsertData( $p_table, $p_data ) { if( 1 == $t_install_state ) { ?> + + + +
Checking Database Server Version ServerInfo(); echo '
Running ' . $f_db_type . ' version ' . nl2br( $t_version_info['description'] ); ?>
+ - + + + + - + - + - - + +} # end install-only fields +?> + @@ -544,28 +601,88 @@ function InsertData( $p_table, $p_data ) { Admin Password (to if required) + 'Database Table Prefix', + 'db_table_plugin_prefix' => 'Database Plugin Table Prefix', + 'db_table_suffix' => 'Database Table Suffix', + ); + foreach( $t_prefix_defaults[$t_prefix_type] as $t_key => $t_value ) { + echo "\n\t\n\t\n\n\n"; + } +?> + + + + + + + + + + + + + + + -
- + + +
Type of Database - + 'MySQL (default)', @@ -473,69 +533,66 @@ function InsertData( $p_table, $p_data ) { foreach( $t_db_list as $t_db => $t_db_descr ) { echo ''; + $t_db_descr . "\n"; } - ?> +?>
Hostname (for Database Server) - +
Username (for Database) - +
Password (for Database) - "> +
Database name (for Database) - +
Admin Username (to if required) - +
- +
\n"; + echo "\t\t${t_prefix_labels[$t_key]}\n"; + echo "\t\n\t\t"; + echo ''; + echo "\n\t
+ Default Time Zone + + +
+ Master salt value for cryptographic hashing + (Refer to documentation for details) + + + +
Print SQL Queries instead of Writing to the Database - > + >
- Attempt Installation + - +
- - - - - - - - - + + + + + + + + + + # must post # rather than the following line $t_install_state++; } # end install_state == 4 @@ -881,38 +995,39 @@ function InsertData( $p_table, $p_data ) { $t_value ) { + $t_new_value = ${'f_' . $t_key}; + if( $t_new_value != $t_value ) { + $t_config .= '$' . str_pad( $t_key, 25 ) . "= '" . ${'f_' . $t_key} . "';\n"; + $t_insert_line = true; + } + } + if( $t_insert_line ) { + $t_config .= "\n"; } + $t_config .= + "\$g_default_timezone = '$f_timezone';\n" + . "\n" + . "\$g_crypto_master_salt = '$f_crypto_master_salt';\n"; + $t_write_failed = true; if( !$t_config_exists ) { @@ -1080,10 +1195,13 @@ function InsertData( $p_table, $p_data ) { +
+ @@ -1094,23 +1212,32 @@ function InsertData( $p_table, $p_data ) {
Please correct failed checks - - - - - - - - - - - +
+ + + + + + + + + + + +
- diff --git a/admin/admin.css b/css/admin.css similarity index 98% rename from admin/admin.css rename to css/admin.css index 9a857b9e72..f41c553a4d 100644 --- a/admin/admin.css +++ b/css/admin.css @@ -81,6 +81,8 @@ th { border-color: black; } +.hidden { display: none; } + #mantisbt-header-logo { text-align: center; } diff --git a/javascript/install.js b/javascript/install.js new file mode 100644 index 0000000000..75b33968fa --- /dev/null +++ b/javascript/install.js @@ -0,0 +1,52 @@ +/* +# Mantis - a php based bugtracking system + +# Copyright 2000 - 2002 Kenzaburo Ito - kenito@300baud.org +# Copyright 2013 MantisBT Team - mantisbt-dev@lists.sourceforge.net + +# Mantis 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. +# +# Mantis 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 Mantis. If not, see . + */ + + +$(document).ready( function() { + +/** + * On Change event for database type selection list + * Preset prefix, plugin prefix and suffix fields when changing db type + */ +$('#db_type').change( + function () { + var db; + if ($(this).val() == 'oci8') { + db = 'oci8'; + } else { + db = 'other'; + } + + $('#default_' + db + ' span').each( + function (i, el) { + var target = $('#' + $(el).attr('name')); + var oldVal = target.data('defval'); + // Only change the value if not changed from default + if (typeof oldVal === 'undefined' || oldVal == target.val()) { + target.val($(el).text()); + } + // Store default value + target.data('defval', $(el).text()); + } + ); + } +).change(); + +})