aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2008-11-12 12:41:27 +0000
committerpatdenice <patdenice@piwigo.org>2008-11-12 12:41:27 +0000
commitb5b089670a796b2a6a510330bc081e42ddd937c2 (patch)
tree5561d9df86a9caa6e5ab42fa914d94e494872bdc
parentdf2f3a4f4d3bc0402d3cb7be38506b131f18e12c (diff)
merge -c2863 from trunk to branch 2.0
- 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/branches/2.0@2864 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--admin/template/goto/upgrade.tpl1
-rw-r--r--install/db/65-database.php34
-rw-r--r--install/upgrade_1.3.1.php11
-rw-r--r--language/de_DE/upgrade.lang.php2
-rw-r--r--language/en_UK/upgrade.lang.php2
-rw-r--r--language/es_ES/upgrade.lang.php2
-rw-r--r--language/fr_FR/upgrade.lang.php4
-rw-r--r--language/it_IT/upgrade.lang.php2
-rw-r--r--language/nl_NL/upgrade.lang.php2
-rw-r--r--upgrade.php31
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; }
</style>
{/literal}
<title>Piwigo {$RELEASE} - {'Upgrade'|@translate}</title>
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
@@ -102,25 +102,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();
$query='
@@ -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 <i>include/mysql.inc.php</i>, before <b>?></b>, 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 <i>include/mysql.inc.php</i>, before <b>?></b>, 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 <i>include/mysql.inc.php</i>, before <b>?></b>, 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 <i>include/mysql.inc.php</i>, avant <b>?></b>, 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 <i>include/mysql.inc.php</i>, before <b>?></b>, 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 <i>include/mysql.inc.php</i>, before <b>?></b>, 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:') . '
+<p><textarea rows="5" cols="40">'.implode("\r\n\r\n" , $mysql_changes).'</textarea></p>'
+ );
+ }
+ }
+
// 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')
);