Source for file configreader.php

Documentation is available at configreader.php

  1. <?php
  2. /**
  3. * Configuration reading object
  4. *
  5. * Parses the {@link bumblebee.ini } file
  6. *
  7. @author    Stuart Prescott
  8. @copyright  Copyright Stuart Prescott
  9. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10. @version    $Id: configreader.php,v 1.8 2007/02/16 23:10:22 themill Exp $
  11. @package    Bumblebee
  12. @subpackage Misc
  13. */
  14.  
  15. /** Load ancillary functions */
  16. require_once 'inc/typeinfo.php';
  17.  
  18. /** include parent */
  19. require_once 'inc/bb/basicconfigreader.php';
  20. /** include parent */
  21. require_once 'inc/systemstatus.php';
  22.  
  23. class ConfigReader extends BasicConfigReader {
  24.  
  25.   /** @var string  used for generating links to the administrator for more information, help etc */
  26.   var $AdminEmail;
  27.  
  28.   var $BasePath;
  29.   /** @var string  prepended to all URLs generated by the system so that the links work */
  30.   var $BaseURL;
  31.   /** @var string  Location of the session array (make sure the session variables don't clash with others systems that are setting session vars) */
  32.   var $SessionIndex;
  33.  
  34.   /** @var boolean  Echo all SQL statements to the browser for debugging purposes */
  35.   var $VerboseSQL = false;
  36.   /** @var boolean  user supplied data will be dumped to the browser for debugging purposes */
  37.   var $VerboseData = false;
  38.  
  39.   /** @var SystemStatus    maintain tabs on the system status */
  40.   var $status = null;
  41.  
  42.   function ConfigReader({
  43.     parent::BasicConfigReader();
  44.     $this->status = new SystemStatus();
  45.   }
  46.  
  47.   function ParseConfig($fatalErrors=true{
  48.     if ($this->status === null$this->status = new SystemStatus();
  49.  
  50.  
  51.     $this->AdminEmail = $this->value('main''AdminEmail''');  ///FIXME: work out a default?
  52.  
  53.     $script_source preg_replace('@//+@''/'$_SERVER['SCRIPT_NAME']);
  54.  
  55.     $this->BasePath   = $this->value('main''BasePath');
  56.     if ($this->BasePath === null || substr($this->BasePath01!= '/'{
  57.       if (preg_match('@install/\w+.php@'$script_source)) {
  58.         $this->BasePath = preg_replace('@install/\w+.php@'''$script_source);
  59.       else {
  60.         $this->BasePath = preg_replace('@/index.php@'''$script_source);
  61.       }
  62.       if (strlen($this->BasePath== 0$this->BasePath = '/';
  63.     }
  64.  
  65. //     if (substr($this->BasePath, 0, 1) != '/' && ! $this->configError) {
  66. //       // the first character of the path must be a slash
  67. //       // the user is never going to be able to log on when it's like this, so let's kill it off.
  68. //       trigger_error('Bumblebee misconfiguration: please make sure that the BasePath parameter in bumblebee.ini is only the path portion of the URL and does not include the server name. (Hint: should start with a "/" and be something like "/bumblebee" or "/departments/chemistry/equipment")', $fatalErrors ? E_USER_ERROR : E_USER_NOTICE);
  69. //     }
  70.  
  71.     $this->BaseURL    = $this->value('main''BaseURL');    //FIXME: work out a default?
  72.     if ($this->BaseURL === null || (substr($this->BaseURL01!= '/' && substr($this->BaseURL04!= 'http')) {
  73.       if (preg_match('@install/\w+.php@'$script_source)) {
  74.         $this->BaseURL = preg_replace('@install/\w+.php@''index.php'$script_source);
  75.       else {
  76.         $this->BaseURL = $script_source;
  77.       }
  78.     }
  79.  
  80.     if ($fatalErrors{
  81.       if (defined('LOAD_ALL_PHP_FILES')) {
  82.         if ($this->data['error_handling']['AllWarnings']{
  83.           //this is nice for development but probably turn it off for production
  84.           error_reporting(E_ALL E_STRICT)#force all warnings to be echoed
  85.           #error_reporting(E_ALL); #force all warnings to be echoed
  86.           /** load all php files */
  87.           define('LOAD_ALL_PHP_FILES'1);
  88.         else {
  89.           error_reporting(E_ERROR)#only errors should be echoed
  90.           /** load only the php files required to fullfill this request) */
  91.           define('LOAD_ALL_PHP_FILES'0);
  92.         }
  93.       }
  94.     }
  95.  
  96.     $this->VerboseSQL  = $this->value('error_handling''VerboseSQL'false);
  97.     $this->VerboseData = $this->value('error_handling''VerboseData'false);
  98.  
  99. //     echo "'$script_source'";
  100.     $this->SessionIndex = md5($script_source);
  101.   }
  102.  
  103. }
  104.  
  105. ?>

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