forked from modxcms/revolution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
64 lines (55 loc) · 2.08 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/*
* This file is part of MODX Revolution.
*
* Copyright (c) MODX, LLC. All Rights Reserved.
*
* For complete copyright and license information, see the COPYRIGHT and LICENSE
* files found in the top-level directory of this distribution.
*/
$tstart = microtime(true);
/* define this as true in another entry file, then include this file to simply access the API
* without executing the MODX request handler */
if (!defined('MODX_API_MODE')) {
define('MODX_API_MODE', false);
}
/* include custom core config and define core path */
@include(dirname(__FILE__) . '/config.core.php');
if (!defined('MODX_CORE_PATH')) {
define('MODX_CORE_PATH', dirname(__FILE__) . '/core/');
}
if (!defined('MODX_CONFIG_KEY')) {
define('MODX_CONFIG_KEY', 'config');
}
/* include the autoloader */
if (!@require_once MODX_CORE_PATH . "vendor/autoload.php") {
$errorMessage = 'Site temporarily unavailable';
@include MODX_CORE_PATH . 'error/unavailable.include.php';
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
echo "<html><title>Error 503: Site temporarily unavailable</title><body><h1>Error 503</h1><p>{$errorMessage}</p></body></html>";
exit();
}
/* start output buffering */
ob_start();
/* Create an instance of the modX class */
$modx = new \MODX\Revolution\modX();
if (!is_object($modx) || !($modx instanceof \MODX\Revolution\modX)) {
ob_get_level() && @ob_end_flush();
$errorMessage = '<a href="setup/">MODX not installed. Install now?</a>';
@include MODX_CORE_PATH . 'error/unavailable.include.php';
header($_SERVER['SERVER_PROTOCOL'] . ' 503 Service Unavailable');
echo "<html><title>Error 503: Site temporarily unavailable</title><body><h1>Error 503</h1><p>{$errorMessage}</p></body></html>";
exit();
}
/* Set the actual start time */
$modx->startTime = $tstart;
/* Initialize a context */
$contextKey = 'web';
if (is_readable(__DIR__ . '/config.context.php')) {
$contextKey = require __DIR__ . '/config.context.php';
}
$modx->initialize($contextKey);
/* execute the request handler */
if (!MODX_API_MODE) {
$modx->handleRequest();
}