Advertisement
vanchelo

Ajax Connector

Mar 22nd, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php
  2.  
  3. $allowed = array(
  4.     'web/image/small',
  5.     'web/image/big',
  6.     'web/image/gallery/small',
  7.     'web/image/gallery/big',
  8. );
  9.  
  10. if (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], $allowed)) {
  11.   @session_cache_limiter('public');
  12.     define('MODX_REQP',false);
  13. }
  14. require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
  15. require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
  16. require_once MODX_CONNECTORS_PATH.'index.php';
  17.  
  18. if(!$path = $modx->getOption('site_gallery.core_path',null)){
  19.     $path = $modx->getOption('core_path').'components/site_gallery/';
  20. }
  21. $path .= 'processors/';  
  22.  
  23.  
  24. if (in_array($_REQUEST['action'], $allowed)) {
  25.     $version = $modx->getVersionData();
  26.     if (version_compare($version['full_version'],'2.1.1-pl') >= 0) {
  27.         if ($modx->user->hasSessionContext($modx->context->get('key'))) {
  28.             $_SERVER['HTTP_MODAUTH'] = $_SESSION["modx.{$modx->context->get('key')}.user.token"];
  29.         } else {
  30.             $_SESSION["modx.{$modx->context->get('key')}.user.token"] = 0;
  31.             $_SERVER['HTTP_MODAUTH'] = 0;
  32.         }
  33.     } else {
  34.         $_SERVER['HTTP_MODAUTH'] = $modx->site_id;
  35.     }
  36.     $_REQUEST['HTTP_MODAUTH'] = $_SERVER['HTTP_MODAUTH'];
  37. }
  38.  
  39. $modx->request->handleRequest(array(
  40.     'processors_path' => $path,
  41.     'location' => '',
  42. ));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement