Source for file forms.php

Documentation is available at forms.php

  1. <?php
  2. /**
  3. * Simple Forms library for Bumblebee installer
  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. function startHTML($title$head=''{
  15.   ?>
  16.     <html>
  17.       <head>
  18.         <title><?php echo $title?></title>
  19.         <style>
  20.               .good  { color: green;  font-weight: bolder; }
  21.               .warn  { color: orange; font-weight: bolder; }
  22.               .error { color: red;    font-weight: bolder; }
  23.               blockquote {border: 1px solid #333399; margin: 1em; padding: 1em;}
  24.               fieldset { background-color: #f9f9ff;}
  25.               fieldset fieldset {background-color: #f9ffff;}
  26.               h2 { padding-top: 0; margin-top: 0;}
  27.         </style>
  28.         <?php echo $head?>
  29.       </head>
  30.       <body>
  31.   <?php
  32. }
  33.  
  34. function startHTML_install($data$steps{
  35.   $title 'Bumblebee setup';
  36.   startHTML($title);
  37.   ?>
  38.       <h1>Bumblebee Setup Script</h1>
  39.       <form action='install.php' method='POST'>
  40.       <input type='hidden' name='havedata' value='1' />
  41.       <div id="stepnum">Step <?php print $steps->getIndex()?> of <?php print $steps->numSteps();?></div>
  42.       <div id="stepbar">
  43.       <?php
  44.         print $steps->getStepButtons();
  45.       ?>
  46.       </div>
  47.       <p>Please use this script in conjunction with the
  48.       <a href='http://bumblebeeman.sourceforge.net/documentation/install'>installation instructions</a>.
  49.       </p>
  50.   <?php
  51. }
  52.  
  53. function startHTML_upgrade($data$steps{
  54.   $title 'Bumblebee upgrade';
  55.   startHTML($title);
  56.   ?>
  57.       <h1>Bumblebee Upgrade Script</h1>
  58.       <form action='upgrade.php' method='POST'>
  59.       <input type='hidden' name='havedata' value='1' />
  60.       <div id="stepnum">Step <?php print $steps->getIndex()?> of <?php print $steps->numSteps();?></div>
  61.       <div id="stepbar">
  62.       <?php
  63.         print $steps->getStepButtons();
  64.       ?>
  65.       </div>
  66.       <p>Please use this script in conjunction with the
  67.       <a href='http://bumblebeeman.sourceforge.net/documentation/upgrade'>upgrade instructions</a>.</p>
  68.   <?php
  69.   if (isset($data['old_db_version']))
  70.       echo "<input type='hiddenname='old_db_versionvalue='{$data['old_db_version']}' />";
  71. }
  72.  
  73. function endHTML({
  74.   ?>
  75.       </form>
  76.       </body>
  77.     </html>
  78.   <?php
  79. }
  80.  
  81.  
  82.  
  83. /**
  84. * Find out from the user what username and passwords to use for connecting to the database etc
  85. */
  86. function printInstallFormFields($values$hidden$reallyhidden=false{
  87.   if ($reallyhidden{
  88.     printField('sqlHost'$values['sqlHost']$hidden$reallyhidden);
  89.     printField('sqlDB'$values['sqlDB']$hidden$reallyhidden);
  90.     printField('sqlTablePrefix'$values['sqlTablePrefix']$hidden$reallyhidden);
  91.     printField('sqlUser'$values['sqlUser']$hidden$reallyhidden);
  92.     printField('sqlPass'$values['sqlPass']$hidden$reallyhidden);
  93.     printField('bbAdmin'$values['bbAdmin']$hidden$reallyhidden);
  94.     printField('bbAdminPass'$values['bbAdminPass']$hidden$reallyhidden);
  95.     printField('bbAdminName'$values['bbAdminName']$hidden$reallyhidden);
  96.     return;
  97.   }
  98.   ?>
  99.   <tr>
  100.     <td>MySQL host</td>
  101.     <td><?php printField('sqlHost'$values['sqlHost']$hidden);?></td>
  102.   </tr>
  103.   <tr>
  104.     <td>MySQL database</td>
  105.     <td><?php printField('sqlDB'$values['sqlDB']$hidden);?></td>
  106.   </tr>
  107.   <tr>
  108.     <td>MySQL table prefix</td>
  109.     <td><?php printField('sqlTablePrefix'$values['sqlTablePrefix']$hidden);?></td>
  110.   </tr>
  111.   <tr>
  112.     <td>MySQL username</td>
  113.     <td><?php printField('sqlUser'$values['sqlUser']$hidden);?></td>
  114.   </tr>
  115.   <tr>
  116.     <td>MySQL user password</td>
  117.     <td><?php printField('sqlPass'$values['sqlPass']$hidden);?></td>
  118.   </tr>
  119.   <tr>
  120.     <td>Bumblebee admin username</td>
  121.     <td><?php printField('bbAdmin'$values['bbAdmin']$hidden);?></td>
  122.   </tr>
  123.   <tr>
  124.     <td>Bumblebee admin password</td>
  125.     <td><?php printField('bbAdminPass'$values['bbAdminPass']$hidden);?></td>
  126.   </tr>
  127.   <tr>
  128.     <td>Bumblebee admin user's real name</td>
  129.     <td><?php printField('bbAdminName'$values['bbAdminName']$hidden);?></td>
  130.   </tr>
  131.   <input type='hidden' name='havedata' value='1' />
  132.  
  133.   <?php
  134. }
  135.  
  136. /**
  137. * Display an individual field
  138. */
  139. function printField($name$value$hidden$type='text'{
  140.   if ($hidden{
  141.     print "<input type='hiddenname='$namevalue='$value' />".($type===true '' $value);
  142.   else {
  143.     print "<input type='$typename='$namevalue='$value' />";
  144.   }
  145. }
  146.  
  147. function printDatabaseSetupForm($values{
  148.   ?>
  149.   <fieldset id='dbsetup'>
  150.     <legend>Database setup</legend>
  151.     <label>
  152.       <input type='checkbox' name='includeAdmin' value='1' checked='checked' />
  153.       include commands to create the database and MySQL user ("CREATE" and "GRANT" commands)
  154.     </label><br /><br />
  155.     <label>
  156.       <input type='checkbox' name='sqlUseDropTable' value='1' checked='checked' />
  157.       include commands to remove any existing databases and tables ("DROP" commands)
  158.     </label><br /><br />
  159.     You can either download the database setup script and load it manually into the database
  160.     or you can enter the username and password of a database user who is permitted
  161.     to add database users, grant them permissions and create databases (<i>e.g.</i> root)
  162.     and I'll try to setup database for you.
  163.     <table>
  164.     <tr><td width='50%' valign='top'>
  165.     <fieldset>
  166.       <legend>Manual setup</legend>
  167.       <input type='submit' name='submitsql' value='Download database script' />
  168.             <br/>
  169.             Save the SQL file and then load it into the database using either phpMyAdmin or
  170.             the mysql command line tools, <i>e.g.</i>:
  171.             <code style="white-space: nowrap;">mysql -p --user root &lt; bumbelebee.sql</code>
  172.     </fieldset>
  173.     </td><td width='50%' valign='top'>
  174.     <fieldset>
  175.       <legend>Automated setup</legend>
  176.       <input type='submit' name='submitsqlload' value='Automated setup' />
  177.             (needs username and password)
  178.       <table>
  179.         <tr>
  180.           <td>MySQL admin username</td>
  181.           <td><?php printField('sqlAdminUsername''root'false);?></td>
  182.         </tr>
  183.         <tr>
  184.           <td>MySQL admin password</td>
  185.           <td><?php printField('sqlAdminPassword'''false'password');?></td>
  186.         </tr>
  187.       </table>
  188.     </fieldset>
  189.     </td></tr>
  190.     </table>
  191.   </fieldset>
  192.   <?php
  193. }
  194.  
  195. function printErrorMessage($message{
  196.   startHTML('Error');
  197.   ?>
  198.   <h1>Error</h1>
  199.   <p>I'm sorry, an error has occurred within the script. </p>
  200.   <blockquote>
  201.     <?php echo $message?>
  202.   </blockquote>
  203.   <p><a href="<?php echo $_SERVER['PHP_SELF']?>">Back to the script</a></p>
  204.   <?php
  205.   endHTML();
  206. }
  207.  
  208. function genericCleanupInstructions($values$steps{
  209.   ?>
  210.     <fieldset>
  211.       <legend>Post-installation clean-up</legend>
  212.       <p>Now that you've installed Bumblebee and all seems to be working well,
  213.       you should either delete the <code>install</code> directory from your server
  214.       or limit access to it so that only you can get to it.</p>
  215.       <p>The installer can reveal information about your setup to others, so you
  216.       probably don't want to leave it the way it is!</p>
  217.       <p>Once you've done that, you can go to your
  218.       <a href='<?php echo $values['BASEURL']?>'>Bumblebee installation</a></p>
  219.     </fieldset>
  220.     <div id='buttonbar'>
  221.       <?php print $steps->getPrevNextButtons()?>
  222.     </div>
  223.   <?php
  224. }
  225.  
  226. ?>

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