From b5b089670a796b2a6a510330bc081e42ddd937c2 Mon Sep 17 00:00:00 2001 From: patdenice Date: Wed, 12 Nov 2008 12:41:27 +0000 Subject: 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 --- upgrade.php | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'upgrade.php') 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