Imagine a World
Without Free Knowledge

/* 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); } /* this can be used to disable caching in MODx absolutely */ $modx_cache_disabled= 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/'); /* include the modX class */ if (!@include_once (MODX_CORE_PATH . "model/modx/modx.class.php")) { $errorMessage = 'Site temporarily unavailable'; @include(MODX_CORE_PATH . 'error/unavailable.include.php'); header('HTTP/1.1 503 Service Unavailable'); echo "Error 503: Site temporarily unavailable

Error 503

{$errorMessage}

"; exit(); } /* start output buffering */ ob_start(); /* Create an instance of the modX class */ if (empty($options) || !is_array($options)) $options = array(); $modx= new modX('', $options); if (!is_object($modx) || !($modx instanceof modX)) { @ob_end_flush(); $errorMessage = 'MODx not installed. Install now?'; @include(MODX_CORE_PATH . 'error/unavailable.include.php'); header('HTTP/1.1 503 Service Unavailable'); echo "Error 503: Site temporarily unavailable

Error 503

{$errorMessage}

"; exit(); } /* Set the actual start time */ $modx->startTime= $tstart; /* Set additional logging options including level and target: */ $modx->setLogLevel(modX::LOG_LEVEL_ERROR); $modx->setLogTarget('FILE'); /* Set debugging mode (i.e. error_reporting): */ $modx->setDebug(E_ALL & ~E_NOTICE); /* Initialize the default 'web' context */ $modx->initialize('web'); /* execute the request handler */ if (!MODX_API_MODE) { $modx->handleRequest(); }