Changeset 4410


Ignore:
Timestamp:
12/02/09 21:27:06 (9 years ago)
Author:
nikrou
Message:

Feature 1255 :

  • add postgres database engine
  • change installation process to allow postgres or mysql database
Location:
trunk
Files:
4 added
10 edited
1 moved

Legend:

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

    r3768 r4410  
    8585      <th colspan="3">{'step1_title'|@translate}</th> 
    8686    </tr> 
     87    {if count($F_DB_ENGINES)>1} 
     88    <tr> 
     89      <td style="width: 30%;">{'step1_dbengine'|@translate}</td> 
     90      <td> 
     91        <select name="dblayer"> 
     92          {html_options options=$F_DB_ENGINES selected=$F_DB_LAYER} 
     93        </select>     
     94      </td> 
     95      <td>{'step1_dbengine_info'|@translate}</td> 
     96    {else} 
     97    <td colspan="3"> 
     98    <input type="hidden" name="dbengine" value="{$F_DB_LAYER}"> 
     99    </td> 
     100    {/if} 
     101    </tr> 
    87102    <tr> 
    88103      <td style="width: 30%;">{'step1_host'|@translate}</td> 
  • trunk/install.php

    r4385 r4410  
    2525define('PHPWG_ROOT_PATH','./'); 
    2626 
    27 /** 
    28  * loads an sql file and executes all queries 
    29  * 
    30  * Before executing a query, $replaced is... replaced by $replacing. This is 
    31  * useful when the SQL file contains generic words. Drop table queries are 
    32  * not executed. 
    33  * 
    34  * @param string filepath 
    35  * @param string replaced 
    36  * @param string replacing 
    37  * @return void 
    38  */ 
    39 function execute_sqlfile($filepath, $replaced, $replacing) 
    40 { 
    41   $sql_lines = file($filepath); 
    42   $query = ''; 
    43   foreach ($sql_lines as $sql_line) 
    44   { 
    45     $sql_line = trim($sql_line); 
    46     if (preg_match('/(^--|^$)/', $sql_line)) 
    47     { 
    48       continue; 
    49     } 
    50     $query.= ' '.$sql_line; 
    51     // if we reached the end of query, we execute it and reinitialize the 
    52     // variable "query" 
    53     if (preg_match('/;$/', $sql_line)) 
    54     { 
    55       $query = trim($query); 
    56       $query = str_replace($replaced, $replacing, $query); 
    57       // we don't execute "DROP TABLE" queries 
    58       if (!preg_match('/^DROP TABLE/i', $query)) 
    59       { 
    60         global $install_charset_collate; 
    61         if ( !empty($install_charset_collate) ) 
    62         { 
    63           if ( preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches) ) 
    64           { 
    65             $query = $matches[1].' '.$install_charset_collate.';'; 
    66           } 
    67         } 
    68         pwg_query($query); 
    69       } 
    70       $query = ''; 
    71     } 
    72   } 
    73 } 
     27include(PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php'); 
    7428 
    7529@set_magic_quotes_runtime(0); // Disable magic_quotes_runtime 
     
    150104$dbpasswd = (!empty($_POST['dbpasswd'])) ? $_POST['dbpasswd'] : ''; 
    151105$dbname = (!empty($_POST['dbname'])) ? $_POST['dbname'] : ''; 
     106$dblayer = (!empty($_POST['dblayer'])) ? $_POST['dblayer'] : 'mysql'; 
    152107 
    153108if (isset($_POST['install'])) 
     
    183138include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); 
    184139@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); 
    185 include(PHPWG_ROOT_PATH . 'include/dblayer/functions_mysql.inc.php'); 
     140include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$dblayer.'.inc.php'); 
    186141include(PHPWG_ROOT_PATH . 'include/constants.php'); 
    187142include(PHPWG_ROOT_PATH . 'include/functions.inc.php'); 
     
    233188//----------------------------------------------------- template initialization 
    234189include( PHPWG_ROOT_PATH .'include/template.class.php'); 
    235 $template=new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma'); 
     190$template = new Template(PHPWG_ROOT_PATH.'admin/template/goto', 'roma'); 
    236191$template->set_filenames( array('install'=>'install.tpl') ); 
    237192$step = 1; 
     
    239194if ( isset( $_POST['install'] )) 
    240195{ 
    241   if ( @mysql_connect( $_POST['dbhost'], 
    242                        $_POST['dbuser'], 
    243                        $_POST['dbpasswd'] ) ) 
    244   { 
    245     if ( @mysql_select_db($_POST['dbname'] ) ) 
    246     { 
    247       array_push( $infos, l10n('step1_confirmation') ); 
     196  if (($pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'],  
     197                                     $_POST['dbpasswd'], $_POST['dbname']))!==false)  
     198  { 
     199 
     200    array_push( $infos, l10n('step1_confirmation') ); 
     201 
     202    $required_version = constant('REQUIRED_'.strtoupper($conf['dblayer']).'_VERSION'); 
     203    if ( version_compare(pwg_get_db_version(), $required_version, '>=') ) 
     204    { 
     205      $pwg_charset = 'utf-8'; 
     206      $pwg_db_charset = 'utf8'; 
     207      if ($dblayer=='mysql') 
     208      { 
     209        $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; 
     210      } 
     211      else  
     212      { 
     213        $install_charset_collate = ''; 
     214      } 
    248215    } 
    249216    else 
    250217    { 
    251       array_push( $errors, l10n('step1_err_db') ); 
    252     } 
    253     if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 
    254     { 
    255       $pwg_charset='utf-8'; 
    256       $pwg_db_charset='utf8'; 
    257       $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; 
    258     } 
    259     else 
    260     { 
    261       $pwg_charset='iso-8859-1'; 
    262       $pwg_db_charset='latin1'; 
     218      $pwg_charset = 'iso-8859-1'; 
     219      $pwg_db_charset = 'latin1'; 
    263220      $install_charset_collate = ''; 
    264221      if ( !array_key_exists($language, get_languages($pwg_charset) ) ) 
     
    293250    $step = 2; 
    294251    $file_content = '<?php 
    295 $conf[\'dblayer\'] = \'mysql\'; 
     252$conf[\'dblayer\'] = \''.$dblayer.'\'; 
    296253$conf[\'db_base\'] = \''.$dbname.'\'; 
    297254$conf[\'db_user\'] = \''.$dbuser.'\'; 
     
    327284    // tables creation, based on piwigo_structure.sql 
    328285    execute_sqlfile( 
    329       PHPWG_ROOT_PATH.'install/piwigo_structure.sql', 
     286      PHPWG_ROOT_PATH.'install/piwigo_structure-'.$dblayer.'.sql', 
    330287      DEFAULT_PREFIX_TABLE, 
    331288      $table_prefix 
     
    337294      $table_prefix 
    338295      ); 
     296 
     297    $query = ' 
     298INSERT INTO piwigo_config (param,value,comment)  
     299   VALUES (\'secret_key\',\'md5('.pwg_db_cast_to_text(DB_RANDOM_FUNCTION.'()').')\', 
     300   \'a secret key specific to the gallery for internal use\');'; 
     301    pwg_query($query); 
    339302 
    340303    // fill $conf global array 
     
    390353 
    391354//------------------------------------------------------ start template output 
     355$dbengines = available_engines(); 
     356 
    392357foreach (get_languages('utf-8') as $language_code => $language_name) 
    393358{ 
     
    403368  array( 
    404369    'T_CONTENT_ENCODING' => 'utf-8', 
    405     'RELEASE'=>PHPWG_VERSION, 
     370    'RELEASE' => PHPWG_VERSION, 
    406371    'F_ACTION' => 'install.php?language=' . $language, 
    407     'F_DB_HOST'=>$dbhost, 
    408     'F_DB_USER'=>$dbuser, 
    409     'F_DB_NAME'=>$dbname, 
     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, 
    410377    'F_DB_PREFIX' => $table_prefix, 
    411     'F_ADMIN'=>$admin_name, 
    412     'F_ADMIN_EMAIL'=>$admin_mail, 
    413     'L_INSTALL_HELP'=>sprintf(l10n('install_help'), PHPWG_URL.'/forum'), 
     378    'F_ADMIN' => $admin_name, 
     379    'F_ADMIN_EMAIL' => $admin_mail, 
     380    'L_INSTALL_HELP' => sprintf(l10n('install_help'), PHPWG_URL.'/forum'), 
    414381    )); 
    415382 
  • trunk/install/config.sql

    r3445 r4410  
    1818INSERT INTO piwigo_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website'); 
    1919INSERT INTO piwigo_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?'); 
    20 INSERT INTO piwigo_config (param,value,comment) VALUES ('secret_key', MD5(RAND()), 'a secret key specific to the gallery for internal use'); 
    2120INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_html_mail','true','Send mail on HTML format for notification by mail'); 
    2221INSERT INTO piwigo_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail'); 
  • trunk/language/de_DE/install.lang.php

    r4280 r4410  
    3737$lang['step1_err_server'] = 'Es konnte keine Verbindung zum Datenbankserver aufgebaut werden'; 
    3838 
    39 $lang['step1_host'] = 'MySQL Host'; 
     39$lang['step1_dbengine'] = 'Database type'; 
     40$lang['step1_dbengine_info'] = 'The type of database your piwigo data will be store in'; 
     41$lang['step1_host'] = 'Host'; 
    4042$lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; 
    4143$lang['step1_user'] = 'Benutzer'; 
  • trunk/language/en_UK/install.lang.php

    r4280 r4410  
    4040$lang['step1_err_copy'] = '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)'; 
    4141 
    42 $lang['step1_host'] = 'MySQL host'; 
     42$lang['step1_dbengine'] = 'Database type'; 
     43$lang['step1_dbengine_info'] = 'The type of database your piwigo data will be store in'; 
     44$lang['step1_host'] = 'Host'; 
    4345$lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; 
    4446$lang['step1_user'] = 'User'; 
  • trunk/language/es_ES/install.lang.php

    r4280 r4410  
    3737$lang['step1_err_server'] = 'Imposible conectarse al servidor'; 
    3838 
    39 $lang['step1_host'] = 'Huésped MySQL'; 
     39$lang['step1_dbengine'] = 'Database type'; 
     40$lang['step1_dbengine_info'] = 'The type of database your piwigo data will be store in'; 
     41$lang['step1_host'] = 'Huésped'; 
    4042$lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; 
    4143$lang['step1_user'] = 'Utilizador'; 
  • trunk/language/fr_FR/install.lang.php

    r4280 r4410  
    3737$lang['step1_err_server'] = 'Impossible de se connecter au serveur'; 
    3838 
    39 $lang['step1_host'] = 'Hôte MySQL'; 
     39$lang['step1_dbengine'] = 'Type de base de données'; 
     40$lang['step1_dbengine_info'] = 'La base de données à utiliser pour installer piwigo'; 
     41$lang['step1_host'] = 'Hôte'; 
    4042$lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; 
    4143$lang['step1_user'] = 'Utilisateur'; 
  • trunk/language/it_IT/install.lang.php

    r4280 r4410  
    3737$lang['step1_err_server'] = 'Non è stato possibile connettersi al server'; 
    3838 
    39 $lang['step1_host'] = 'MySQL host'; 
     39$lang['step1_dbengine'] = 'Database type'; 
     40$lang['step1_dbengine_info'] = 'The type of database your piwigo data will be store in'; 
     41$lang['step1_host'] = 'Host'; 
    4042$lang['step1_host_info'] = 'localhost, sql.multimania.com, pluto.libero.it'; 
    4143$lang['step1_user'] = 'Utente'; 
  • trunk/language/nl_NL/install.lang.php

    r4280 r4410  
    4040$lang['step1_err_copy'] = 'Kopieer de tekst tussen de lijnen en plak deze in het bestand "include/config_database.inc.php"(Waarschuwing: config_database.inc.php mag alleen het roze gedeelte bevatten, geen return of extra spatie). Dit moet alleen wanneer dit bestand geen schrijfrechten'; 
    4141 
    42 $lang['step1_host'] = 'MySQL host'; 
     42$lang['step1_dbengine'] = 'Database type'; 
     43$lang['step1_dbengine_info'] = 'The type of database your piwigo data will be store in'; 
     44$lang['step1_host'] = 'Host'; 
    4345$lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; 
    4446$lang['step1_user'] = 'Gebruiker'; 
  • trunk/language/pl_PL/install.lang.php

    r4280 r4410  
    4040$lang['step1_err_copy'] = 'Skopiuj tekst zaznaczony na różowo pomiędzy cudzysłowiami i wklej do pliku "include/config_database.inc.php"(Uwaga : config_database.inc.php musi zawierać tylko to co jest na różowo bez żadnych znaków końca linii czy spacji)'; 
    4141 
    42 $lang['step1_host'] = 'MySQL host'; 
     42$lang['step1_dbengine'] = 'Database type'; 
     43$lang['step1_dbengine_info'] = 'The type of database your piwigo data will be store in'; 
     44$lang['step1_host'] = 'Host'; 
    4345$lang['step1_host_info'] = 'localhost, sql.multimania.com, toto.freesurf.fr'; 
    4446$lang['step1_user'] = 'Uzytkownik'; 
Note: See TracChangeset for help on using the changeset viewer.