Changeset 2863 for trunk/upgrade.php


Ignore:
Timestamp:
Nov 12, 2008, 1:40:20 PM (15 years ago)
Author:
patdenice
Message:
  • 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upgrade.php

    r2862 r2863  
    3030define('PHPWG_ROOT_PATH', './');
    3131
    32 if (!file_exists(PHPWG_ROOT_PATH.'include/mysql.inc.php'))
    33 {
    34   die('Could not find include/mysql.inc.php file.');
     32// load config file
     33$config_file = PHPWG_ROOT_PATH.'include/mysql.inc.php';
     34$config_file_contents = @file_get_contents($config_file);
     35if ($config_file_contents === false)
     36{
     37  die('Cannot load '.$config_file);
     38}
     39$php_end_tag = strrpos($config_file_contents, '?'.'>');
     40if ($php_end_tag === false)
     41{
     42  die('Cannot find php end tag in '.$config_file);
    3543}
    3644
     
    225233$page['infos'] = array();
    226234$page['errors'] = array();
     235$mysql_changes = array();
    227236
    228237if (isset($_POST['username']) and isset($_POST['password']))
     
    239248    $conf['die_on_sql_error'] = false;
    240249    include($upgrade_file);
     250
     251    // Something to add in mysql.inc.php?
     252    if (!empty($mysql_changes))
     253    {
     254      $config_file_contents =
     255        substr($config_file_contents, 0, $php_end_tag) . "\r\n"
     256        . implode("\r\n\r\n" , $mysql_changes) . "\r\n"
     257        . substr($config_file_contents, $php_end_tag);
     258
     259      if (!@file_put_contents($config_file, $config_file_contents))
     260      {
     261        array_push($page['infos'],
     262          l10n('in include/mysql.inc.php, before ?>, insert:') . '
     263<p><textarea rows="5" cols="40">'.implode("\r\n\r\n" , $mysql_changes).'</textarea></p>'
     264          );
     265      }
     266    }
    241267
    242268    // Plugins deactivation
     
    270296
    271297    array_push($page['infos'],
    272       l10n('delete upgrade files'),
    273298      l10n('perform a maintenance check')
    274299      );
Note: See TracChangeset for help on using the changeset viewer.