ajax.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. $tStart= microtime(true);
  3. define('MODX_API_MODE', true);
  4. $modx_cache_disabled = false;
  5. require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.core.php';
  6. if (!defined('MODX_CORE_PATH')) define('MODX_CORE_PATH', dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/core/');
  7. /* include the modX class */
  8. if (!@include_once (MODX_CORE_PATH . "model/modx/modx.class.php")) {
  9. exit();
  10. }
  11. /* start output buffering */
  12. ob_start();
  13. /* Create an instance of the modX class */
  14. $modx= new modX();
  15. if (!is_object($modx) || !($modx instanceof modX)) {
  16. ob_get_level() && @ob_end_flush();
  17. exit();
  18. }
  19. $modx->startTime= $tStart;
  20. $modx->initialize('web');
  21. $corePath = $modx->getOption('collections.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/collections/');
  22. /** @var Collections $collections */
  23. $collections = $modx->getService(
  24. 'collections',
  25. 'Collections',
  26. $corePath . 'model/collections/',
  27. array(
  28. 'core_path' => $corePath
  29. )
  30. );
  31. $ajax = new \Collections\Endpoint\Ajax($collections);
  32. $ajax->run();