index.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. /**
  11. * Initializes the modx manager
  12. *
  13. * @package modx
  14. * @subpackage manager
  15. */
  16. @include dirname(__FILE__) . '/config.core.php';
  17. if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(__DIR__) . '/core/');
  18. /* define this as true in another entry file, then include this file to simply access the API
  19. * without executing the MODX request handler */
  20. if (!defined('MODX_API_MODE')) {
  21. define('MODX_API_MODE', false);
  22. }
  23. /* check for correct version of php */
  24. $php_ver_comp = version_compare(phpversion(),'5.3.3');
  25. if ($php_ver_comp < 0) {
  26. die('Wrong php version! You\'re using PHP version "'.phpversion().'", and MODX Revolution only works on 5.3.3 or higher.');
  27. }
  28. /* set the document_root */
  29. if(!isset($_SERVER['DOCUMENT_ROOT']) || empty($_SERVER['DOCUMENT_ROOT'])) {
  30. $_SERVER['DOCUMENT_ROOT'] = str_replace($_SERVER['PATH_INFO'], '', str_replace('\\\\', '/', $_SERVER['PATH_TRANSLATED'])) . '/';
  31. }
  32. /* include the modX class */
  33. if (!(include_once MODX_CORE_PATH . 'model/modx/modx.class.php')) {
  34. include MODX_CORE_PATH . 'error/unavailable.include.php';
  35. die('Site temporarily unavailable!');
  36. }
  37. /* @var modX $modx create the modX object */
  38. $modx= new modX('', array(xPDO::OPT_CONN_INIT => array(xPDO::OPT_CONN_MUTABLE => true)));
  39. if (!is_object($modx) || !($modx instanceof modX)) {
  40. $errorMessage = '<a href="../setup/">MODX not installed. Install now?</a>';
  41. include MODX_CORE_PATH . 'error/unavailable.include.php';
  42. header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
  43. echo "<html><title>Error 503: Site temporarily unavailable</title><body><h1>Error 503</h1><p>{$errorMessage}</p></body></html>";
  44. exit();
  45. }
  46. $modx->initialize('mgr');
  47. $modx->getRequest();
  48. $modx->getParser();
  49. if (!MODX_API_MODE) {
  50. $modx->request->handleRequest();
  51. }
  52. @session_write_close();
  53. exit();