Beispiel #1
0
 public static function init()
 {
     ///////////////////////////////////
     // Try to be smart about the paths:
     // Define default constants
     if (!defined('MIDCOM_ROOT')) {
         define('MIDCOM_ROOT', dirname(__FILE__));
     }
     require MIDCOM_ROOT . '/compat/environment.php';
     midcom_compat_environment::initialize();
     if (!defined('MIDCOM_STATIC_ROOT')) {
         $pos = strrpos(MIDCOM_ROOT, '/');
         if ($pos === false) {
             // No slash, this is strange
             _midcom_stop_request('MIDCOM_ROOT did not contain a slash, this should not happen and is most probably the cause of a configuration error.');
         }
         define('MIDCOM_STATIC_ROOT', substr(MIDCOM_ROOT, 0, $pos) . '/static');
     }
     if (!defined('MIDCOM_STATIC_URL')) {
         define('MIDCOM_STATIC_URL', '/midcom-static');
     }
     if (!defined('MIDCOM_CONFIG_FILE_BEFORE')) {
         define('MIDCOM_CONFIG_FILE_BEFORE', '/etc/midgard/midcom.conf');
     }
     if (!defined('MIDCOM_CONFIG_FILE_AFTER')) {
         define('MIDCOM_CONFIG_FILE_AFTER', '/etc/midgard/midcom-after.conf');
     }
     ///////////////////////////////////////
     //Constants, Globals and Configuration
     require MIDCOM_ROOT . '/constants.php';
     require MIDCOM_ROOT . '/midcom/connection.php';
     require MIDCOM_ROOT . '/midcom/config/midcom_config.php';
     ini_set('track_errors', '1');
     require MIDCOM_ROOT . '/errors.php';
     // Register autoloader so we get all MidCOM classes loaded automatically
     spl_autoload_register(array('midcom', 'autoload'));
     if (file_exists(MIDCOM_ROOT . '/../vendor/autoload.php')) {
         $loader = (require MIDCOM_ROOT . '/../vendor/autoload.php');
         $loader->register();
     }
     /////////////////////
     // Start the Debugger
     require MIDCOM_ROOT . '/midcom/debug.php';
     debug_add("Start of MidCOM run: {$_SERVER['REQUEST_URI']}");
     self::$_services['auth'] = new midcom_services_auth();
     self::$_services['auth']->initialize();
     /* Load and start up the cache system, this might already end the request
      * on a content cache hit. Note that the cache check hit depends on the i18n and auth code.
      */
     self::$_services['cache'] = new midcom_services_cache();
     /////////////////////////////////////
     // Instantiate the MidCOM main class
     self::$_application = new midcom_application();
     if (!empty($GLOBALS['midcom_config']['midcom_use_superglobal'])) {
         require_once MIDCOM_ROOT . '/compat/superglobal.php';
         $_MIDCOM = new midcom_compat_superglobal();
     }
     self::$_application->initialize();
     if (file_exists(MIDCOM_CONFIG_FILE_AFTER)) {
         include MIDCOM_CONFIG_FILE_AFTER;
     }
 }