diff --git a/admin/template/goto/install.tpl b/admin/template/goto/install.tpl index 27ab605a0..6976d8ccc 100644 --- a/admin/template/goto/install.tpl +++ b/admin/template/goto/install.tpl @@ -162,11 +162,11 @@ TD { {else}

-
- - + +

+{if !isset($migration)}

-
- +

{/if} +{/if} {* content *}
{$L_INSTALL_HELP}
{* the_page *} diff --git a/install.php b/install.php index 2f66dc7b7..81f936a32 100644 --- a/install.php +++ b/install.php @@ -122,9 +122,31 @@ $admin_mail = (!empty($_POST['admin_mail'])) ? $_POST['admin_mail'] : ''; $infos = array(); $errors = array(); +// database config file migration : mysql.inc.php et config_database.inc.php +$old_config_file = PHPWG_ROOT_PATH . 'include/mysql.inc.php'; +$config_file = PHPWG_ROOT_PATH . 'include/config_database.inc.php'; +if (!file_exists($config_file) && file_exists($old_config_file)) +{ + $step = 3; + include $old_config_file; + $file_content = ''; +} // Open config.php ... if it exists -$config_file = PHPWG_ROOT_PATH.'include/config_database.inc.php'; -if (@file_exists($config_file)) +elseif (@file_exists($config_file)) { include($config_file); // Is Piwigo already installed ? @@ -175,9 +197,12 @@ else { } define('PHPWG_URL', 'http://'.PHPWG_DOMAIN); -load_language( 'common.lang', '', array('language'=>$language, 'target_charset'=>'utf-8') ); -load_language( 'admin.lang', '', array('language'=>$language, 'target_charset'=>'utf-8') ); -load_language( 'install.lang', '', array('language'=>$language, 'target_charset'=>'utf-8') ); +if ($step != 3) +{ + load_language('common.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); + load_language('admin.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); + load_language('install.lang', '', array('language' => $language, 'target_charset'=>'utf-8')); +} //------------------------------------------------- check php version if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) @@ -188,8 +213,11 @@ if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) //----------------------------------------------------- template initialization include( PHPWG_ROOT_PATH .'include/template.class.php'); $template = new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma'); -$template->set_filenames( array('install'=>'install.tpl') ); -$step = 1; +$template->set_filenames( array('install' => 'install.tpl') ); +if (!isset($step)) +{ + $step = 1; +} //---------------------------------------------------------------- form analyze if ( isset( $_POST['install'] )) { @@ -352,39 +380,78 @@ INSERT INTO piwigo_config (param,value,comment) } //------------------------------------------------------ start template output -$dbengines = available_engines(); - -foreach (get_languages('utf-8') as $language_code => $language_name) +if ($step == 3) { - if ($language == $language_code) + @umask(0111); + // writing the new configuration file + if ( !($fp = @fopen( $config_file, 'w' ))) { - $template->assign('language_selection', $language_code); - } - $languages_options[$language_code] = $language_name; -} -$template->assign('language_options', $languages_options); + $html_content = htmlentities( $file_content, ENT_QUOTES ); + $html_content = nl2br( $html_content ); + $error_copy = l10n('Copy the text in pink between hyphens and paste it into the file "include/config_database.inc.php"(Warning : config_database.inc.php must only contain what is in pink, no line return or space character)'); + $error_copy .= '
--------------------------------------------------------------------
'; + $error_copy .= '' . $html_content . ''; + $error_copy .= '
--------------------------------------------------------------------
'; + } + else + { + @fputs($fp, $file_content, strlen($file_content)); + @fclose($fp); -$template->assign( - array( - 'T_CONTENT_ENCODING' => 'utf-8', - 'RELEASE' => PHPWG_VERSION, - 'F_ACTION' => 'install.php?language=' . $language, - 'F_DB_ENGINES' => $dbengines, - 'F_DB_LAYER' => $dblayer, - 'F_DB_HOST' => $dbhost, - 'F_DB_USER' => $dbuser, - 'F_DB_NAME' => $dbname, - 'F_DB_PREFIX' => $table_prefix, - 'F_ADMIN' => $admin_name, - 'F_ADMIN_EMAIL' => $admin_mail, - 'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'), - )); + @unlink($old_config_file); + header("Location: index.php"); + exit(); + } + + $template->assign( + array( + 'T_CONTENT_ENCODING' => 'utf-8', + 'migration' => true + )); +} +else +{ + $dbengines = available_engines(); + + foreach (get_languages('utf-8') as $language_code => $language_name) + { + if ($language == $language_code) + { + $template->assign('language_selection', $language_code); + } + $languages_options[$language_code] = $language_name; + } + $template->assign('language_options', $languages_options); + + $template->assign( + array( + 'T_CONTENT_ENCODING' => 'utf-8', + 'RELEASE' => PHPWG_VERSION, + 'F_ACTION' => 'install.php?language=' . $language, + 'F_DB_ENGINES' => $dbengines, + 'F_DB_LAYER' => $dblayer, + 'F_DB_HOST' => $dbhost, + 'F_DB_USER' => $dbuser, + 'F_DB_NAME' => $dbname, + 'F_DB_PREFIX' => $table_prefix, + 'F_ADMIN' => $admin_name, + 'F_ADMIN_EMAIL' => $admin_mail, + 'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'), + )); +} //------------------------------------------------------ errors & infos display if ($step == 1) { $template->assign('install', true); } +elseif ($step == 3) +{ + if (isset($error_copy)) + { + array_push($errors, $error_copy); + } +} else { array_push($infos, l10n('install_end_message')); diff --git a/install/db/84-database.php b/install/db/84-database.php new file mode 100644 index 000000000..9543d9db0 --- /dev/null +++ b/install/db/84-database.php @@ -0,0 +1,77 @@ +'; + +@umask(0111); +// writing the configuration file +if ( !($fp = @fopen( $config_file, 'w' ))) +{ + $html_content = htmlentities( $file_content, ENT_QUOTES, 'utf-8' ); + $html_content = nl2br( $html_content ); + $error_copy = l10n('step1_err_copy'); + $error_copy .= '
--------------------------------------------------------------------
'; + $error_copy .= '' . $html_content . ''; + $error_copy .= '
--------------------------------------------------------------------
'; +} +@fputs($fp, $file_content, strlen($file_content)); +@fclose($fp); + +if (isset($error_copy)) +{ + array_push($page['errors'], $error_copy); +} + +echo +"\n" +. $upgrade_description +."\n" +; +?>