Source for file upgrade.php

Documentation is available at upgrade.php

  1. <?php
  2. /**
  3. * Simple Bumblebee upgrader -- performs everything necessary/possible to upgrade a user to newer version
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Installer
  11. */
  12.  
  13.  
  14. define('BUMBLEBEE'true);
  15.  
  16.  
  17. $sqlSetupFilename 'bumbelebeeupgrade.sql';
  18.  
  19. require_once 'installer/upgradedatabase.php';
  20. require_once 'installer/forms.php';
  21. require_once 'installer/sqlload.php';
  22. require_once 'installer/fileoutput.php';
  23. require_once 'installer/loadconfig.php';
  24.  
  25. require_once 'inc/db.php';
  26. require_once 'inc/formslib/sql.php';
  27.  
  28. require_once 'inc/bb/configreader.php';
  29. $conf ConfigReader::getInstance();
  30.  
  31. require_once 'installer/installstep.php';
  32.  
  33. $steps new InstallStepCollection();
  34. $steps->addStep(new InstallStep('Release notes',      'do_releasenotes'));
  35. $steps->addStep(new InstallStep('Check database',     'do_checkdb'));
  36. $steps->addStep(new InstallStep('Upgrade database',   'do_dbupgrade'));
  37. $steps->addStep(new InstallStep('Clean-up',           'do_cleanup'));
  38.  
  39. $data $_POST;
  40.  
  41. $steps->setCurrent(1);
  42. if (isset($_POST['havedata']|| isset($_POST['do_releasenotes'])) {
  43.   printStepReleaseNotes($data$steps);
  44.   exit;
  45. }
  46.  
  47. $steps->increment();
  48. if (empty($_POST['old_db_version']|| isset($_POST['do_checkdb'])) {
  49.   $data['old_db_version'getCurrentDBVersion();
  50.   $data['old_version']    $data['old_db_version'];
  51.   $data['new_version']    $BUMBLEBEEVERSION;
  52.   $data['new_db_version'$data['new_version']#substr($data['new_version'], 0, strrpos($data['new_version'], '.'));
  53.     if (version_compare($data['old_db_version']$data['new_db_version']== -1{
  54.     // then the db needs upgrading
  55.         $data['db_upgrade'true;
  56.   else {
  57.     $data["db_upgrade"false;
  58.   }
  59.   printStepUpgradeCheck($data$steps);
  60.   exit;
  61. }
  62.  
  63. $old_db_version $data['old_db_version'];
  64.  
  65. $steps->increment();
  66. if (isset($_POST['do_dbupgrade'])) {
  67.   list($sql$notesmakeUpgradeSQL($old_db_version);
  68.   $data['db-notes'$notes;
  69.   printStepDBUpgrade($data$steps);
  70.   exit;
  71. }
  72. if (isset($_POST['submitsql'])) {
  73.   list($sql$notesmakeUpgradeSQL($old_db_version);
  74.   outputTextFile($sqlSetupFilename$sql);
  75.   exit;
  76. }
  77. if (isset($_POST['submitsqlload'])) {
  78.   list($sql$notesmakeUpgradeSQL($old_db_version);
  79.   $results loadSQL($sql$conf->value('database''host')$_POST['sqlAdminUsername']$_POST['sqlAdminPassword']);
  80.   $data['db-notes']   $notes;
  81.   $data['db-results'$results;
  82.   printStepDBUpgrade($data$steps);
  83.   exit;
  84. }
  85.  
  86. $steps->increment();
  87. if (isset($_POST['do_cleanup'])) {
  88.   printStepCleanup($data$steps);
  89.   exit;
  90. }
  91.  
  92.  
  93.  
  94. printErrorMessage("I can't work out what you want me to do");
  95. exit;
  96.  
  97.  
  98.  
  99.  
  100. /**
  101. * Tell the user to look at the release notes
  102. */
  103. function printStepReleaseNotes($data$steps{
  104.   startHTML_upgrade($data$steps);
  105.   ?>
  106.   <fieldset>
  107.     <legend>Upgrade information</legend>
  108.     <p>Before proceeding you should have:</p>
  109.     <ol>
  110.     <li>Read the
  111.       <a href='http://bumblebeeman.sourceforge.net/documentation/upgrade'>upgrade instructions</a>
  112.       before proceeding. No really, I mean it.</li>
  113.     <li>Backed up your data including the database and the Bumblebee installation
  114.       (or at least the <code>theme</code> and <code>config</code> directories)</li>
  115.     <li>Unpacked the archive you downloaded on your webserver; you can copy your old
  116.       <code>theme</code> and <code>config</code> directories back into the new installation
  117.       (instead of using the new ones).
  118.       You might find that many config options have been added to the <code>bumblebee.ini</code>
  119.       file that you won't even know about unless you at least look at the new file;
  120.       all new options have sensible defaults.</li>
  121.     </ol>
  122.       <p>After you have done these things, I'll guide you through the upgrade process.
  123.       It shouldn't be too hard, but we'll see how we go.</p>
  124.  
  125.   </fieldset>
  126.     <div id='buttonbar'>
  127.       <?php print $steps->getPrevNextButtons()?>
  128.     </div>
  129.   <?php
  130.   endHTML();
  131. }
  132. /**
  133. * Find out from the user what username and passwords to use for connecting to the database etc
  134. */
  135. function printStepUpgradeCheck($data$steps{
  136.   startHTML_upgrade($data$steps);
  137.   ?>
  138.     <fieldset>
  139.       <legend>Upgrade information</legend>
  140.       <p>Looking at your installation (you should have installed the new version of Bumblebee at this stage).</p>
  141.       <p>It appears you are trying to upgrade to Bumblebee version <?php echo $data['new_version']?>.</p>
  142.       <p>Your old version of Bumblebee appears to be using the database format used with version
  143.       <?php echo $data['old_db_version']?>.</p>
  144.       <?php
  145.         if ($data['db_upgrade']{
  146.           echo "<p>Your database needs upgrading.</p>";
  147.         else {
  148.           echo "<p>Your database doesn't need upgrading. Great!!</p>";
  149.         }
  150.       ?>
  151.     </fieldset>
  152.     <div id='buttonbar'>
  153.       <?php print $data['db_upgrade'$steps->getPrevNextButtons($steps->getPrevSkipToButtons(1)?>
  154.     </div>
  155.   <?php
  156.   endHTML();
  157. }
  158.  
  159. /**
  160. * Show the user what data they have given and give options for what to do next
  161. */
  162. function printStepDBUpgrade($data$steps{
  163.   startHTML_upgrade($data$steps);
  164.   if (isset($data['db-notes']&& $data['db-notes'&& isset($data['db-results'])) {
  165.     ?>
  166.       <fieldset>
  167.         <legend>Database Upgrade Notes</legend>
  168.         <p>Please make sure you understand the following upgrade notes regarding your database before proceeding.</p>
  169.         <blockquote>
  170.           <?php print $data['db-notes']?>
  171.         </blockquote>
  172.       </fieldset>
  173.     <?php
  174.   }
  175.   if (isset($data['db-results'])) {
  176.     ?>
  177.       <fieldset>
  178.         <legend>Database Upgrade Results</legend>
  179.         <p>The setup script tried running the database upgrade and this is what MySQL said:</p>
  180.         <blockquote>
  181.           <?php print $data['db-results']?>
  182.         </blockquote>
  183.         <p>If it all went well, then proceed to the next step. Otherwise, try to fix any
  184.         errors (wrong username and password, perhaps) in the forms and have another go using
  185.         the script or try to fix it up using phpMyAdmin.</p>
  186.       </fieldset>
  187.     <?php
  188.   }
  189.   ?>
  190.     <div id='buttonbar'>
  191.       <?php print $steps->getPrevNextButtons()?>
  192.     </div>
  193.   <?php
  194.   endHTML();
  195. }
  196.  
  197. function printStepCleanup($values$steps{
  198.   $conf ConfigReader::getInstance();
  199.   $values['BASEURL'$conf->BaseURL;
  200.   startHTML_upgrade($values$steps);
  201.   genericCleanupInstructions($values$steps);
  202.   endHTML();
  203. }
  204.  
  205. function T_($m{
  206.   return $m;
  207. }
  208.  
  209. ?>

Documentation generated on Tue, 06 Mar 2007 10:02:06 +0000 by phpDocumentor 1.3.0