Changeset 4423


Ignore:
Timestamp:
Dec 4, 2009, 7:59:05 PM (11 years ago)
Author:
nikrou
Message:

Feature 1255 : migration script

Location:
trunk
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/template/goto/install.tpl

    r4410 r4423  
    163163{else}
    164164<p>
    165   <br />
    166   <input type="button" name="home" value="{'home'|@translate}" onClick="window.open('index.php');"/>
    167   <input type="button" name="admin" value="{'admin'|@translate}" onClick="window.open('admin.php');"/>
     165  <input type="button" name="home" value="{'home'|@translate}" onClick="window.open('index.php');">
     166  <input type="button" name="admin" value="{'admin'|@translate}" onClick="window.open('admin.php');">
    168167</p>
    169168
     169{if !isset($migration)}
    170170<div class="infos">
    171171  <ul>
     
    175175
    176176<p>
    177   <br />
    178   <input type="button" name="subscribe" value="{'Subscribe %s'|@translate|@sprintf:$F_ADMIN_EMAIL}" onClick="window.open('{$SUBSCRIBE_BASE_URL}{$F_ADMIN_EMAIL}');"/>
     177  <input type="button" name="subscribe" value="{'Subscribe %s'|@translate|@sprintf:$F_ADMIN_EMAIL}" onClick="window.open('{$SUBSCRIBE_BASE_URL}{$F_ADMIN_EMAIL}');">
    179178</p>
     179{/if}
    180180{/if}
    181181</div> {* content *}
  • trunk/install.php

    r4410 r4423  
    123123$errors = array();
    124124
     125// database config file migration : mysql.inc.php et config_database.inc.php
     126$old_config_file = PHPWG_ROOT_PATH . 'include/mysql.inc.php';
     127$config_file = PHPWG_ROOT_PATH . 'include/config_database.inc.php';
     128if (!file_exists($config_file) && file_exists($old_config_file))
     129{
     130  $step = 3;
     131  include $old_config_file;
     132  $file_content = '<?php
     133$conf[\'dblayer\'] = \'mysql\';
     134$conf[\'db_base\'] = \''.$cfgBase.'\';
     135$conf[\'db_user\'] = \''.$cfgUser.'\';
     136$conf[\'db_password\'] = \''.$cfgPassword.'\';
     137$conf[\'db_host\'] = \''.$cfgHote.'\';
     138
     139$prefixeTable = \''.$prefixeTable.'\';
     140
     141define(\'PHPWG_INSTALLED\', true);
     142define(\'PWG_CHARSET\', \''.PWG_CHARSET.'\');
     143define(\'DB_CHARSET\', \''.DB_CHARSET.'\');
     144define(\'DB_COLLATE\', \''.DB_COLLATE.'\');
     145
     146?'.'>';
     147}
    125148// Open config.php ... if it exists
    126 $config_file = PHPWG_ROOT_PATH.'include/config_database.inc.php';
    127 if (@file_exists($config_file))
     149elseif (@file_exists($config_file))
    128150{
    129151  include($config_file);
     
    176198define('PHPWG_URL', 'http://'.PHPWG_DOMAIN);
    177199
    178 load_language( 'common.lang', '', array('language'=>$language, 'target_charset'=>'utf-8') );
    179 load_language( 'admin.lang', '', array('language'=>$language, 'target_charset'=>'utf-8') );
    180 load_language( 'install.lang', '', array('language'=>$language, 'target_charset'=>'utf-8') );
     200if ($step != 3)
     201{
     202  load_language('common.lang', '', array('language' => $language, 'target_charset'=>'utf-8'));
     203  load_language('admin.lang', '', array('language' => $language, 'target_charset'=>'utf-8'));
     204  load_language('install.lang', '', array('language' => $language, 'target_charset'=>'utf-8'));
     205}
    181206
    182207//------------------------------------------------- check php version
     
    189214include( PHPWG_ROOT_PATH .'include/template.class.php');
    190215$template = new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma');
    191 $template->set_filenames( array('install'=>'install.tpl') );
    192 $step = 1;
     216$template->set_filenames( array('install' => 'install.tpl') );
     217if (!isset($step))
     218{
     219  $step = 1;
     220}
    193221//---------------------------------------------------------------- form analyze
    194222if ( isset( $_POST['install'] ))
     
    353381
    354382//------------------------------------------------------ start template output
    355 $dbengines = available_engines();
    356 
    357 foreach (get_languages('utf-8') as $language_code => $language_name)
    358 {
    359   if ($language == $language_code)
    360   {
    361     $template->assign('language_selection', $language_code);
    362   }
    363   $languages_options[$language_code] = $language_name;
    364 }
    365 $template->assign('language_options', $languages_options);
    366 
    367 $template->assign(
    368   array(
    369     'T_CONTENT_ENCODING' => 'utf-8',
    370     'RELEASE' => PHPWG_VERSION,
    371     'F_ACTION' => 'install.php?language=' . $language,
    372     'F_DB_ENGINES' => $dbengines,
    373     'F_DB_LAYER' => $dblayer,
    374     'F_DB_HOST' => $dbhost,
    375     'F_DB_USER' => $dbuser,
    376     'F_DB_NAME' => $dbname,
    377     'F_DB_PREFIX' => $table_prefix,
    378     'F_ADMIN' => $admin_name,
    379     'F_ADMIN_EMAIL' => $admin_mail,
    380     'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'),
    381     ));
     383if ($step == 3)
     384{
     385  @umask(0111);
     386  // writing the new configuration file
     387  if ( !($fp = @fopen( $config_file, 'w' )))
     388  {
     389    $html_content = htmlentities( $file_content, ENT_QUOTES );
     390    $html_content = nl2br( $html_content );
     391    $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)');
     392    $error_copy .= '<br>--------------------------------------------------------------------<br>';
     393    $error_copy .= '<span class="sql_content">' . $html_content . '</span>';
     394    $error_copy .= '<br>--------------------------------------------------------------------<br>';
     395  }
     396  else
     397  {
     398    @fputs($fp, $file_content, strlen($file_content));
     399    @fclose($fp);
     400
     401    @unlink($old_config_file);
     402    header("Location: index.php");
     403    exit();
     404  }
     405
     406  $template->assign(
     407    array(
     408      'T_CONTENT_ENCODING' => 'utf-8',
     409      'migration' => true
     410          ));
     411}
     412else
     413{
     414  $dbengines = available_engines();
     415
     416  foreach (get_languages('utf-8') as $language_code => $language_name)
     417  {
     418    if ($language == $language_code)
     419    {
     420      $template->assign('language_selection', $language_code);
     421    }
     422    $languages_options[$language_code] = $language_name;
     423  }
     424  $template->assign('language_options', $languages_options);
     425
     426  $template->assign(
     427    array(
     428      'T_CONTENT_ENCODING' => 'utf-8',
     429      'RELEASE' => PHPWG_VERSION,
     430      'F_ACTION' => 'install.php?language=' . $language,
     431      'F_DB_ENGINES' => $dbengines,
     432      'F_DB_LAYER' => $dblayer,
     433      'F_DB_HOST' => $dbhost,
     434      'F_DB_USER' => $dbuser,
     435      'F_DB_NAME' => $dbname,
     436      'F_DB_PREFIX' => $table_prefix,
     437      'F_ADMIN' => $admin_name,
     438      'F_ADMIN_EMAIL' => $admin_mail,
     439      'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'),
     440      ));
     441}
    382442
    383443//------------------------------------------------------ errors & infos display
     
    385445{
    386446  $template->assign('install', true);
     447}
     448elseif ($step == 3)
     449{
     450  if (isset($error_copy))
     451  {
     452    array_push($errors, $error_copy);
     453  }
    387454}
    388455else
Note: See TracChangeset for help on using the changeset viewer.