Source for file install.php

Documentation is available at install.php

  1. <?php
  2. /**
  3. * Simple Bumblebee installer -- creates an SQL and ini files from user input
  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. define('BUMBLEBEE'true);
  14.  
  15. $sqlSourceFile 'setup-tables.sql';
  16. $sqlSetupFilename 'bumblebee.sql';
  17. $iniSourceFile 'db.ini';
  18. $iniSetupFilename 'db.ini';
  19.  
  20.  
  21.  
  22. require_once 'installer/forms.php';
  23. require_once 'installer/fileoutput.php';
  24. require_once 'installer/sqlload.php';
  25. require_once 'installer/checks.php';
  26. require_once 'installer/createdatabase.php';
  27. require_once 'installer/constructini.php';
  28.  
  29. require_once 'installer/installstep.php';
  30.  
  31. $steps new InstallStepCollection();
  32. $steps->addStep(new InstallStep('Usernames',          'do_userdata'));
  33. $steps->addStep(new InstallStep('Pre-install check',  'do_preinst'));
  34. $steps->addStep(new InstallStep('Create database',    'do_database'));
  35. $steps->addStep(new InstallStep('Copy db.ini',        'do_dbini'));
  36. $steps->addStep(new InstallStep('Customise',          'do_customise'));
  37. $steps->addStep(new InstallStep('Post-install check''do_postinst'));
  38. $steps->addStep(new InstallStep('Clean-up',           'do_cleanup'));
  39.  
  40. $steps->setCurrent(1);
  41. $userSubmitted array_merge(getSetupDefaults()$_POST);
  42.  
  43. if (isset($_POST['havedata']|| isset($_POST['do_userdata'])) {
  44.   printStepUserForm($userSubmitted$steps);
  45.   exit;
  46. }
  47.  
  48. $steps->increment();
  49. if (isset($_POST['do_preinst'])) {
  50.   $userSubmitted['preinst-results'check_preinst($userSubmitted);
  51.   printStepPreInst($userSubmitted$steps);
  52.   exit;
  53. }
  54.  
  55. $steps->increment();
  56. if (isset($_POST['do_database'])) {
  57.   printStepDatabase($userSubmitted$steps);
  58.   exit;
  59. }
  60. // do the database setup parts
  61. if (isset($_POST['submitsql'])) {
  62.   $includeAdmin = isset($_POST['includeAdmin']$_POST['includeAdmin'false;
  63.   $s constructSQL($sqlSourceFile$userSubmitted$includeAdmin);
  64.   outputTextFile($sqlSetupFilename$s);
  65.   exit;
  66. }
  67. if (isset($_POST['submitsqlload'])) {
  68.   $s constructSQL($sqlSourceFile$userSubmitted$_POST['includeAdmin']);
  69.   $userSubmitted['loadsql-results'loadSQL($s$_POST['sqlHost']$_POST['sqlAdminUsername'],
  70.                                                   $_POST['sqlAdminPassword']);
  71.   printStepDatabase($userSubmitted$steps);
  72.   exit;
  73. }
  74.  
  75. $steps->increment();
  76. if (isset($_POST['do_dbini'])) {
  77.   printStepDBini($userSubmitted$steps);
  78.   exit;
  79. }
  80. if (isset($_POST['submitini'])) {
  81.   $s constructini($iniSourceFile$userSubmitted);
  82.   outputTextFile($iniSetupFilename$s);
  83.   exit;
  84. }
  85.  
  86. $steps->increment();
  87. if (isset($_POST['do_customise'])) {
  88.   printStepCustomise($userSubmitted$steps);
  89.   exit;
  90. }
  91.  
  92. $steps->increment();
  93. if (isset($_POST['do_postinst'])) {
  94.   $userSubmitted['preinst-results']  check_preinst($userSubmitted);
  95.   $userSubmitted['postinst-results'check_postinst($userSubmitted);
  96.   printStepPostInst($userSubmitted$steps);
  97.   exit;
  98. }
  99.  
  100. $steps->increment();
  101. if (isset($_POST['do_cleanup'])) {
  102.   require_once 'installer/loadconfig.php';
  103.   $conf ConfigReader::getInstance();
  104.   $userSubmitted['BASEURL'$conf->BaseURL;
  105.   printStepCleanup($userSubmitted$steps);
  106.   exit;
  107. }
  108.  
  109. printErrorMessage("I can't work out what you want me to do");
  110. exit;
  111.  
  112.  
  113.  
  114.  
  115.  
  116. /**
  117. * Find out from the user what username and passwords to use for connecting to the database etc
  118. */
  119. function printStepUserForm($values$steps{
  120.   startHTML_install($values$steps);
  121.   ?>
  122.     <fieldset>
  123.       <legend>Input data</legend>
  124.       <table>
  125.         <?php
  126.           printInstallFormFields($valuesfalse);
  127.         ?>
  128.       </table>
  129.     </fieldset>
  130.     <div id='buttonbar'>
  131.       <?php print $steps->getPrevNextButtons()?>
  132.     </div>
  133.   <?php
  134.   endHTML();
  135. }
  136.  
  137.  
  138. function reflectUserData($values$visible=true{
  139.   if ($visible{
  140.     ?>
  141.     <fieldset>
  142.       <legend>Input data</legend>
  143.       <table>
  144.         <?php printInstallFormFields($valuestrue);?>
  145.       </table>
  146.       <input type='submit' name='do_userdata' value='&laquo; Go back and change data' />
  147.     </fieldset>
  148.     <?php
  149.   else {
  150.     printInstallFormFields($valuestruetrue);
  151.   }
  152. }
  153.  
  154. function printStepPreInst($values$steps{
  155.   startHTML_install($values$steps);
  156.   reflectUserData($values);
  157.   ?>
  158.     <fieldset>
  159.       <legend>Pre-installation check</legend>
  160.       <p>The setup script is having a look around your system to see if everything is OK for Bumblebee...</p>
  161.       <blockquote>
  162.         <?php print $values['preinst-results']?>
  163.       </blockquote>
  164.       <p>If you're happy with the results of the pre-install check, then proceed to the next step.</p>
  165.     </fieldset>
  166.     <div id='buttonbar'>
  167.       <?php print $steps->getPrevReloadNextButtons(NULL'Rerun test'NULL)?>
  168.     </div>
  169.   <?php
  170.   endHTML();
  171. }
  172.  
  173. function printStepDatabase($values$steps{
  174.   startHTML_install($values$steps);
  175.   reflectUserData($valuesfalse);
  176.   if (isset($values['loadsql-results'])) {
  177.     ?>
  178.       <fieldset>
  179.         <legend>Loading SQL into Database</legend>
  180.         <p>The setup script tried running the database upgrade and this is what MySQL said:</p>
  181.         <blockquote>
  182.           <?php print $values['loadsql-results']?>
  183.         </blockquote>
  184.         <p>If it all went well, then proceed to the next step. Otherwise, try to fix any
  185.         errors (wrong username and password, perhaps) in the forms and have another go using
  186.         the script or try to fix it up using phpMyAdmin.</p>
  187.       </fieldset>
  188.     <?php
  189.   }
  190.   ?>
  191.     <div id='buttonbar'>
  192.       <?php print $steps->getPrevNextButtons()?>
  193.     </div>
  194.   <?php
  195.   endHTML();
  196. }
  197.  
  198. function printStepDBini($values$steps{
  199.   startHTML_install($values$steps);
  200.   reflectUserData($valuesfalse);
  201.   ?>
  202.     <fieldset id='dbini'>
  203.       <legend>Config file generation</legend>
  204.       Bumblebee needs to know what username and password to use for connecting to your database.
  205.       Download the <code>db.ini</code> file (which will contain the values specified above)
  206.       and save it into your Bumblebee installation on the webserver as <code>config/db.ini</code>.<br />
  207.       <input type='submit' name='submitini' value='Generate db.ini file' />
  208.     </fieldset>
  209.     <div id='buttonbar'>
  210.       <?php print $steps->getPrevNextButtons()?>
  211.     </div>
  212.   <?php
  213.   endHTML();
  214. }
  215.  
  216. function printStepCustomise($values$steps{
  217.   startHTML_install($values$steps);
  218.   reflectUserData($valuesfalse);
  219.   ?>
  220.     <fieldset id='dbini'>
  221.       <legend>Customise Installation</legend>
  222.       <p>You now need to customise your <code>bumblebee.ini</code> file. This file can be found in
  223.       the <code>config/</code> directory of your installation. The most important things for you
  224.       to customise are in the first couple of sections of the file.</p>
  225.       <p>Please refer to the
  226.       <a href="http://bumblebeeman.sourceforge.net/documentation/configure">documentation</a>
  227.       for more information on how to do this.</p>
  228.     </fieldset>
  229.     <div id='buttonbar'>
  230.       <?php print $steps->getPrevNextButtons()?>
  231.     </div>
  232.   <?php
  233.   endHTML();
  234. }
  235.  
  236. function printStepPostInst($values$steps{
  237.   startHTML_install($values$steps);
  238.   reflectUserData($valuesfalse);
  239.   ?>
  240.     <fieldset>
  241.       <legend>Post-installation check</legend>
  242.       <p>The setup script is having a look around your system to see if everything is OK for Bumblebee
  243.       (just as it did before) as well as looking at how your installation went...</p>
  244.       <blockquote>
  245.         <?php print $values['preinst-results']?>
  246.       </blockquote>
  247.       <blockquote>
  248.         <?php print $values['postinst-results']?>
  249.       </blockquote>
  250.       <p>If you're happy with the results of the post-install check, then you're almost finished!</p>
  251.     </fieldset>
  252.     <div id='buttonbar'>
  253.       <?php print $steps->getPrevReloadNextButtons(NULL'Rerun test'NULL)?>
  254.     </div>
  255.   <?php
  256.   endHTML();
  257. }
  258.  
  259. function printStepCleanup($values$steps{
  260.   startHTML_install($values$steps);
  261.   reflectUserData($valuesfalse);
  262.   genericCleanupInstructions($values$steps);
  263.   endHTML();
  264. }
  265.  
  266. ?>

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