aboutsummaryrefslogtreecommitdiffstats
path: root/upgrade.php
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2008-11-12 12:40:20 +0000
committerpatdenice <patdenice@piwigo.org>2008-11-12 12:40:20 +0000
commitcd9f45fd1dd2ebc2e6795c15a3f3eddb38e95e7d (patch)
treea1313450a3956f3be90cb6ad1f3309a93d32705d /upgrade.php
parent1d9821abd15519ad4732854e277ae9163f5e2a7d (diff)
- 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
Diffstat (limited to 'upgrade.php')
-rw-r--r--upgrade.php31
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')
);