From cd9f45fd1dd2ebc2e6795c15a3f3eddb38e95e7d Mon Sep 17 00:00:00 2001 From: patdenice Date: Wed, 12 Nov 2008 12:40:20 +0000 Subject: - Remove advises of file removal at the end of install/upgrade. - Automatic change mysql.inc.php if file is writable, else purpose manual change to user. git-svn-id: http://piwigo.org/svn/trunk@2863 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/template/goto/upgrade.tpl | 1 + install/db/65-database.php | 34 +++++----------------------------- install/upgrade_1.3.1.php | 11 ++--------- language/de_DE/upgrade.lang.php | 2 +- language/en_UK/upgrade.lang.php | 2 +- language/es_ES/upgrade.lang.php | 2 +- language/fr_FR/upgrade.lang.php | 4 ++-- language/it_IT/upgrade.lang.php | 2 +- language/nl_NL/upgrade.lang.php | 2 +- upgrade.php | 31 ++++++++++++++++++++++++++++--- 10 files changed, 43 insertions(+), 48 deletions(-) diff --git a/admin/template/goto/upgrade.tpl b/admin/template/goto/upgrade.tpl index 222805d1b..6e2e0730b 100644 --- a/admin/template/goto/upgrade.tpl +++ b/admin/template/goto/upgrade.tpl @@ -22,6 +22,7 @@ table { margin: 0px; } td { padding: 3px 10px; } +textarea { margin-left: 20px; } {/literal} Piwigo {$RELEASE} - {'Upgrade'|@translate} diff --git a/install/db/65-database.php b/install/db/65-database.php index c445b0ab6..6a26a1478 100644 --- a/install/db/65-database.php +++ b/install/db/65-database.php @@ -101,25 +101,6 @@ if ( !defined('PWG_CHARSET') ) { $upgrade_log = ''; -// +-----------------------------------------------------------------------+ -// load the config file - $config_file = PHPWG_ROOT_PATH.'include/mysql.inc.php'; - $config_file_contents = @file_get_contents($config_file); - if ($config_file_contents === false) - { - die('CANNOT LOAD '.$config_file); - } - $php_end_tag = strrpos($config_file_contents, '?'.'>'); - if ($php_end_tag === false) - { - die('CANNOT FIND PHP END TAG IN '.$config_file); - } - if (!is_writable($config_file)) - { - die('FILE NOT WRITABLE '.$config_file); - } - - // +-----------------------------------------------------------------------+ // load all the user languages $all_langs=array(); @@ -274,17 +255,12 @@ ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8; // +-----------------------------------------------------------------------+ -// write the result to file and update #user_infos.language - $config_file_contents = - substr($config_file_contents, 0, $php_end_tag).' -define(\'PWG_CHARSET\', \''.$pwg_charset.'\'); +// changes to write in mysql.inc.php + array_push($mysql_changes, +'define(\'PWG_CHARSET\', \''.$pwg_charset.'\'); define(\'DB_CHARSET\', \''.$db_charset.'\'); -define(\'DB_COLLATE\', \'\'); -'.substr($config_file_contents, $php_end_tag); - - $fp = @fopen( $config_file, 'w' ); - @fputs($fp, $config_file_contents, strlen($config_file_contents)); - @fclose($fp); +define(\'DB_COLLATE\', \'\');' + ); foreach ($all_langs as $old_lang=>$lang_data) { diff --git a/install/upgrade_1.3.1.php b/install/upgrade_1.3.1.php index 436f25953..fa7708f6a 100644 --- a/install/upgrade_1.3.1.php +++ b/install/upgrade_1.3.1.php @@ -595,15 +595,8 @@ if (!is_writable($config_file)) die('FILE NOT WRITABLE '.$config_file); } -// Insert define('PHPWG_INSTALLED', true); in mysql.inc.php -$config_file_contents = - substr($config_file_contents, 0, $php_end_tag).' -define(\'PHPWG_INSTALLED\', true); -'.substr($config_file_contents, $php_end_tag); - -$fp = @fopen( $config_file, 'w' ); -@fputs($fp, $config_file_contents, strlen($config_file_contents)); -@fclose($fp); +// changes to write in mysql.inc.php +array_push($mysql_changes, 'define(\'PHPWG_INSTALLED\', true);'); // Send infos $page['infos'] = array_merge( diff --git a/language/de_DE/upgrade.lang.php b/language/de_DE/upgrade.lang.php index d01a05d4f..a3d684ea4 100644 --- a/language/de_DE/upgrade.lang.php +++ b/language/de_DE/upgrade.lang.php @@ -31,11 +31,11 @@ $lang['total upgrade time'] = 'total upgrade time'; $lang['total SQL time'] = 'total SQL time'; $lang['SQL queries'] = 'SQL queries'; $lang['Upgrade informations'] = 'Upgrade informations'; -$lang['delete upgrade files'] = '[Security] Delete files "upgrade.php", "upgrade_feed.php", "install.php" and "install" directory'; $lang['perform a maintenance check'] = 'Perform a maintenance check in [Administration>Specials>Maintenance] if you encounter any problem.'; $lang['deactivated plugins'] = 'As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:'; $lang['upgrade login message'] = 'Only administrator can run upgrade: please sign in below.'; $lang['You do not have access rights to run upgrade'] = 'You do not have access rights to run upgrade'; +$lang['in include/mysql.inc.php, before ?>, insert:'] = 'In include/mysql.inc.php, before ?>, insert:'; // Upgrade informations from upgrade_1.3.1.php $lang['all sub-categories of private categories become private'] = 'All sub-categories of private categories become private'; diff --git a/language/en_UK/upgrade.lang.php b/language/en_UK/upgrade.lang.php index 2c25f3146..b1f3a2e05 100644 --- a/language/en_UK/upgrade.lang.php +++ b/language/en_UK/upgrade.lang.php @@ -30,11 +30,11 @@ $lang['total upgrade time'] = 'total upgrade time'; $lang['total SQL time'] = 'total SQL time'; $lang['SQL queries'] = 'SQL queries'; $lang['Upgrade informations'] = 'Upgrade informations'; -$lang['delete upgrade files'] = '[Security] Delete files "upgrade.php", "upgrade_feed.php", "install.php" and "install" directory'; $lang['perform a maintenance check'] = 'Perform a maintenance check in [Administration>Specials>Maintenance] if you encounter any problem.'; $lang['deactivated plugins'] = 'As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:'; $lang['upgrade login message'] = 'Only administrator can run upgrade: please sign in below.'; $lang['You do not have access rights to run upgrade'] = 'You do not have access rights to run upgrade'; +$lang['in include/mysql.inc.php, before ?>, insert:'] = 'In include/mysql.inc.php, before ?>, insert:'; // Upgrade informations from upgrade_1.3.1.php $lang['all sub-categories of private categories become private'] = 'All sub-categories of private categories become private'; diff --git a/language/es_ES/upgrade.lang.php b/language/es_ES/upgrade.lang.php index e74f5d047..8f32ac49e 100644 --- a/language/es_ES/upgrade.lang.php +++ b/language/es_ES/upgrade.lang.php @@ -30,11 +30,11 @@ $lang['total upgrade time'] = 'tiempo total de la puesta al día'; $lang['total SQL time'] = 'tiempo total de la demanda SQL'; $lang['SQL queries'] = 'número de demanda SQL'; $lang['Upgrade informations'] = 'Informaciones sobre la puesta al día'; -$lang['delete upgrade files'] = '[Seguridad] Borre los ficheros "upgrade.php", "upgrade_feed.php", "install.php" así como el expediente "install"'; $lang['perform a maintenance check'] = 'Por favor, efectúes un mantenimiento en [Administración>Especiales>Mantenimiento] si usted encuentra problemas.'; $lang['deactivated plugins'] = 'Por precaución, el plugins siguiente han sido desactivados. Verifique si existen unas posturas al día antes de reactivarlas:'; $lang['upgrade login message'] = 'Sólo un administrador puede lanzar la puesta al día: por favor, identifiqúese más abajo.'; $lang['You do not have access rights to run upgrade'] = 'Usted no tiene los derechos necessaires para lanzar la puesta al día.'; +/* TODO */$lang['in include/mysql.inc.php, before ?>, insert:'] = 'In include/mysql.inc.php, before ?>, insert:'; // Upgrade informations from upgrade_1.3.1.php $lang['all sub-categories of private categories become private'] = 'Todas las subcategorías de categorías privadas se vuelven privadas'; diff --git a/language/fr_FR/upgrade.lang.php b/language/fr_FR/upgrade.lang.php index dacdb824f..698156cfb 100644 --- a/language/fr_FR/upgrade.lang.php +++ b/language/fr_FR/upgrade.lang.php @@ -30,11 +30,11 @@ $lang['total upgrade time'] = 'temps total de la mise à jour'; $lang['total SQL time'] = 'temps total des requêtes SQL'; $lang['SQL queries'] = 'nombre de requêtes SQL'; $lang['Upgrade informations'] = 'Informations sur la mise à jour'; -$lang['delete upgrade files'] = '[Sécurité] Effacez les fichiers "upgrade.php", "upgrade_feed.php", "install.php" ainsi que le dossier "install"'; $lang['perform a maintenance check'] = 'Veuillez effectuer une maintenance dans [Administration>Spéciales>Maintenance] si vous rencontrez des problèmes.'; $lang['deactivated plugins'] = 'Par précaution, les plugins suivants ont été désactivés. Vérifiez s\'il existe des mises à jour avant de les réactiver:'; -$lang['upgrade login message'] = 'Seul un adminitrateur peut lancer la mise à jour: veuillez vous identifier ci-dessous.'; +$lang['upgrade login message'] = 'Seul un administrateur peut lancer la mise à jour: veuillez vous identifier ci-dessous.'; $lang['You do not have access rights to run upgrade'] = 'Vous n\'avez pas les droits necessaires pour lancer la mise à jour.'; +$lang['in include/mysql.inc.php, before ?>, insert:'] = 'Dans le fichier include/mysql.inc.php, avant ?>, insérez:'; // Upgrade informations from upgrade_1.3.1.php $lang['all sub-categories of private categories become private'] = 'Toutes les sous-catégories de catégories privées deviennent privées'; diff --git a/language/it_IT/upgrade.lang.php b/language/it_IT/upgrade.lang.php index 38642c678..ab6ff10c1 100644 --- a/language/it_IT/upgrade.lang.php +++ b/language/it_IT/upgrade.lang.php @@ -30,11 +30,11 @@ $lang['total upgrade time'] = 'tempo totale per aggiornamento'; $lang['total SQL time'] = 'tempo totale delle esecuzioni SQL'; $lang['SQL queries'] = 'numero delle esecuzioni SQL'; $lang['Upgrade informations'] = 'Informazioni sul\'aggiornamento'; -$lang['delete upgrade files'] = '[Sicurezza] Cancellare i files "upgrade.php", "upgrade_feed.php", "install.php" e la directory "install"'; $lang['perform a maintenance check'] = 'Se riscontrate dei problemi, effettuare una manutezione in [Amministrazione>Speciale>Manutenzione].'; $lang['deactivated plugins'] = 'Per precauzione, i plugins sono stati disattivati. Verificate se non esistono degli aggiornamenti prima di riattivarli:'; $lang['upgrade login message'] = 'Solo un\'amministratore può eseguire l\'aggiornamento: identificatevi.'; $lang['You do not have access rights to run upgrade'] = 'Non avete le autorizzazioni necessarie per effettuare l\'aggiornamento'; +/* TODO */$lang['in include/mysql.inc.php, before ?>, insert:'] = 'In include/mysql.inc.php, before ?>, insert:'; // Upgrade informations from upgrade_1.3.1.php $lang['all sub-categories of private categories become private'] = 'Tutte le sotto categorie delle categorie private diventono private'; diff --git a/language/nl_NL/upgrade.lang.php b/language/nl_NL/upgrade.lang.php index d01a05d4f..a3d684ea4 100644 --- a/language/nl_NL/upgrade.lang.php +++ b/language/nl_NL/upgrade.lang.php @@ -31,11 +31,11 @@ $lang['total upgrade time'] = 'total upgrade time'; $lang['total SQL time'] = 'total SQL time'; $lang['SQL queries'] = 'SQL queries'; $lang['Upgrade informations'] = 'Upgrade informations'; -$lang['delete upgrade files'] = '[Security] Delete files "upgrade.php", "upgrade_feed.php", "install.php" and "install" directory'; $lang['perform a maintenance check'] = 'Perform a maintenance check in [Administration>Specials>Maintenance] if you encounter any problem.'; $lang['deactivated plugins'] = 'As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:'; $lang['upgrade login message'] = 'Only administrator can run upgrade: please sign in below.'; $lang['You do not have access rights to run upgrade'] = 'You do not have access rights to run upgrade'; +$lang['in include/mysql.inc.php, before ?>, insert:'] = 'In include/mysql.inc.php, before ?>, insert:'; // Upgrade informations from upgrade_1.3.1.php $lang['all sub-categories of private categories become private'] = 'All sub-categories of private categories become private'; diff --git a/upgrade.php b/upgrade.php index b042c0910..1255f0623 100644 --- a/upgrade.php +++ b/upgrade.php @@ -29,9 +29,17 @@ if (version_compare(PHP_VERSION, '5', '<')) define('PHPWG_ROOT_PATH', './'); -if (!file_exists(PHPWG_ROOT_PATH.'include/mysql.inc.php')) +// load config file +$config_file = PHPWG_ROOT_PATH.'include/mysql.inc.php'; +$config_file_contents = @file_get_contents($config_file); +if ($config_file_contents === false) { - die('Could not find include/mysql.inc.php file.'); + die('Cannot load '.$config_file); +} +$php_end_tag = strrpos($config_file_contents, '?'.'>'); +if ($php_end_tag === false) +{ + die('Cannot find php end tag in '.$config_file); } include_once(PHPWG_ROOT_PATH.'include/functions.inc.php'); @@ -224,6 +232,7 @@ else // +-----------------------------------------------------------------------+ $page['infos'] = array(); $page['errors'] = array(); +$mysql_changes = array(); if (isset($_POST['username']) and isset($_POST['password'])) { @@ -239,6 +248,23 @@ if (isset($_POST['submit']) and check_upgrade()) $conf['die_on_sql_error'] = false; include($upgrade_file); + // Something to add in mysql.inc.php? + if (!empty($mysql_changes)) + { + $config_file_contents = + substr($config_file_contents, 0, $php_end_tag) . "\r\n" + . implode("\r\n\r\n" , $mysql_changes) . "\r\n" + . substr($config_file_contents, $php_end_tag); + + if (!@file_put_contents($config_file, $config_file_contents)) + { + array_push($page['infos'], + l10n('in include/mysql.inc.php, before ?>, insert:') . ' +

' + ); + } + } + // Plugins deactivation if (in_array(PREFIX_TABLE.'plugins', $tables)) { @@ -269,7 +295,6 @@ if (isset($_POST['submit']) and check_upgrade()) ); array_push($page['infos'], - l10n('delete upgrade files'), l10n('perform a maintenance check') ); -- cgit v1.2.3