Source for file index.php

Documentation is available at index.php

  1. <?php
  2. /**
  3. * Bumblebee base file
  4. *
  5. * All HTTP calls go directly through this object and are then handled through
  6. * the ActionFactory to work out what should be done.
  7. *
  8. @author     Stuart Prescott
  9. @copyright  Copyright Stuart Prescott
  10. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11. @version    $Id$
  12. @package    Bumblebee
  13. *
  14. *  path (bumblebee root)/index.php
  15. */
  16.  
  17. error_reporting(E_ALL E_STRICT);
  18.  
  19. // prevent output for the moment to permit session headers
  20.  
  21. define('BUMBLEBEE'true);
  22. /** Load ancillary functions */
  23. require_once 'inc/typeinfo.php';
  24.  
  25.  
  26. /** Load in PHP4/5 compatability layer */
  27. require_once 'inc/compat.php';
  28.  
  29. /** Load in the user configuration data */
  30. require_once 'inc/config.php';
  31.  
  32. /** start the database session */
  33. require_once 'inc/db.php';
  34.  
  35. $conf ConfigReader::getInstance();
  36. $conf->mergeDatabaseTable();
  37. $conf->ParseConfig();
  38.  
  39.  
  40. /** load the language pack */
  41. require_once 'inc/i18n.php';
  42.  
  43.  
  44. $auth null;
  45. if ($conf->status->offline{
  46.   /** check the user's credentials, create a session to record them */
  47.   require_once 'inc/bb/auth.php';
  48.   $auth new BumblebeeAuth($_POST);
  49. }
  50.  
  51. /** Load the action factory to work out what should be done in this instance of the script */
  52. require_once 'inc/actions/actionfactory.php';
  53. $action new ActionFactory($auth$conf->status->offline "offline" null);
  54. if ($action->ob_flush_ok()) {
  55.   // some actions will dump back a file, so we might not actually want to output content so far.
  56.   // all is ready to roll now, start the output again.
  57.     ob_end_flush();
  58. }
  59.  
  60. makeMainPage($action$auth);
  61.  
  62. if ($action->ob_flush_ok()) {
  63.   // some actions will dump back a file, and we never want all the HTML guff to end up in it...
  64.     ob_end_clean();
  65.   $action->returnBufferedStream();
  66. }
  67.  
  68. #################################################################################################
  69.  
  70. /**
  71. * Create the start of a form
  72. *
  73. @param string   $url       URL that the form should be submitted to
  74. @param string   $magicTag  form validation tag to show that the form was not spoofed
  75. @param string   $id        xml ID of the form element
  76. @param boolean  $showAutocomplete    include a (non-standard) comment about form Autocompletion
  77. */
  78. function formStart($url$magicTag$id='bumblebeeform'$showAutocomplete=true{
  79.   $conf ConfigReader::getInstance();
  80.   $autocomplete "";
  81.   if ($showAutocomplete &&
  82.         $conf->value('display''AllowAutocomplete'=== null ||
  83.           $conf->value('display''AllowAutocomplete'))
  84.      {
  85.     $autocomplete "AUTOCOMPLETE='off'";
  86.   }
  87.  
  88.   return "
  89.     <form method='post'
  90.       accept-charset='utf-8'
  91.       action='$url'
  92.       id='$id'
  93.       $autocomplete >
  94.     "
  95.     .sprintf('<input type="hidden" name="magicTag" value="%s" />'xssqw($magicTag));
  96. }
  97.  
  98. /**
  99. * Finish a form
  100. *
  101. */
  102. function formEnd({
  103.   return '</form>';
  104. }
  105.  
  106. function pageStart($action$auth{
  107.   $conf ConfigReader::getInstance();
  108.  
  109.   // $usermenu variable is used inside the template
  110.   /** load the user and/or admin menu */
  111.   require_once 'inc/menu.php';
  112.   $usermenu new UserMenu($auth$action->verb());
  113.   $usermenu->showMenu ($conf->status->offline &&
  114.                             $auth->isLoggedIn(&&
  115.                             $action->verb(!= 'logout');
  116.   $usermenu->actionListing $action->actionListing;
  117.  
  118.   // $page* variables can be used in theme/pageheader.php
  119.   $pagetitle  $action->title ' : ' $conf->value('main''SiteTitle');
  120.   $pageheader $action->title;
  121.   $pageBaseRef makeURL($action->verb());
  122.  
  123.   /** display the HTML header section */
  124.   include 'theme/pageheader.php';
  125.   /** display the start of the html content */
  126.   include 'theme/contentheader.php';
  127.   /** popup information control */
  128.   include 'inc/popups.php';
  129. }
  130.  
  131.  
  132. function pageShowErrors($auth{
  133.   $conf ConfigReader::getInstance();
  134.  
  135.   // Login Errors
  136.   if ($auth->isLoggedIn(&& $err $auth->loginError()) {
  137.     echo '<div class="error">' $err '</div>';
  138.   }
  139.  
  140.   // Installer still present error
  141.   if ($auth->isSystemAdmin(&& file_exists('install'&& $conf->value('error_handling''ignore_installer'false)) {
  142.     printf('<div class="error">%s</div>',
  143.         T_('The installer still exists. This is a security risk. Please delete it.'));
  144.   }
  145. }
  146.  
  147. function pageStop({
  148.   global $BUMBLEBEEVERSION;
  149.   /** display the page footer and close off the html page */
  150.   include 'theme/pagefooter.php';
  151. }
  152.  
  153.  
  154. function makeMainPage($action$auth{
  155.   $conf ConfigReader::getInstance();
  156.  
  157.   pageStart($action$auth);
  158.  
  159.   echo '<div id="bumblebeecontent">';
  160.  
  161.   if ($conf->status->offline{
  162.     echo formStart(makeURL($action->nextaction)$auth->makeValidationTag());
  163.     pageShowErrors($auth);
  164.   else {
  165.     echo formStart(makeURL($action->nextaction)'');
  166.   }
  167.  
  168.   $action->go();
  169.  
  170.   echo formEnd();
  171.   echo '</div>';
  172.  
  173.   pageStop();
  174. }
  175.  
  176. ?>

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