index.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. $tstart= microtime(true);
  11. /* define this as true in another entry file, then include this file to simply access the API
  12. * without executing the MODX request handler */
  13. if (!defined('MODX_API_MODE')) {
  14. define('MODX_API_MODE', false);
  15. }
  16. /* include custom core config and define core path */
  17. @include(dirname(__FILE__) . '/config.core.php');
  18. if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__FILE__) . '/core/');
  19. /* include the modX class */
  20. if (!@include_once (MODX_CORE_PATH . "model/modx/modx.class.php")) {
  21. $errorMessage = 'Site temporarily unavailable';
  22. @include(MODX_CORE_PATH . 'error/unavailable.include.php');
  23. header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
  24. echo "<html><title>Error 503: Site temporarily unavailable</title><body><h1>Error 503</h1><p>{$errorMessage}</p></body></html>";
  25. exit();
  26. }
  27. /* start output buffering */
  28. ob_start();
  29. /* Create an instance of the modX class */
  30. $modx= new modX();
  31. if (!is_object($modx) || !($modx instanceof modX)) {
  32. ob_get_level() && @ob_end_flush();
  33. $errorMessage = '<a href="setup/">MODX not installed. Install now?</a>';
  34. @include(MODX_CORE_PATH . 'error/unavailable.include.php');
  35. header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
  36. echo "<html><title>Error 503: Site temporarily unavailable</title><body><h1>Error 503</h1><p>{$errorMessage}</p></body></html>";
  37. exit();
  38. }
  39. /* Set the actual start time */
  40. $modx->startTime= $tstart;
  41. /* Initialize the default 'web' context */
  42. $modx->initialize('web');
  43. /* execute the request handler */
  44. if (!MODX_API_MODE) {
  45. $modx->handleRequest();
  46. }