diff options
author | patdenice <patdenice@piwigo.org> | 2008-11-12 12:41:27 +0000 |
---|---|---|
committer | patdenice <patdenice@piwigo.org> | 2008-11-12 12:41:27 +0000 |
commit | b5b089670a796b2a6a510330bc081e42ddd937c2 (patch) | |
tree | 5561d9df86a9caa6e5ab42fa914d94e494872bdc /upgrade.php | |
parent | df2f3a4f4d3bc0402d3cb7be38506b131f18e12c (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
Diffstat (limited to 'upgrade.php')
-rw-r--r-- | upgrade.php | 31 |
1 files changed, 28 insertions, 3 deletions
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') ); |