connector.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * Gallery Connector
  4. *
  5. * Copyright 2010-2012 by Shaun McCormick <shaun@modx.com>
  6. *
  7. * This file is part of Gallery.
  8. *
  9. * Gallery is free software; you can redistribute it and/or modify it under the
  10. * terms of the GNU General Public License as published by the Free Software
  11. * Foundation; either version 2 of the License, or (at your option) any later
  12. * version.
  13. *
  14. * Gallery is distributed in the hope that it will be useful, but WITHOUT ANY
  15. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  16. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
  20. * Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. * @package gallery
  23. */
  24. /**
  25. * Gallery Connector
  26. *
  27. * @var modX $modx
  28. * @package gallery
  29. */
  30. if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'web/phpthumb') {
  31. @session_cache_limiter('public');
  32. define('MODX_REQP',false);
  33. }
  34. require_once dirname(dirname(dirname(dirname(__FILE__)))).'/config.core.php';
  35. require_once MODX_CORE_PATH.'config/'.MODX_CONFIG_KEY.'.inc.php';
  36. require_once MODX_CONNECTORS_PATH.'index.php';
  37. $galleryCorePath = $modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/');
  38. require_once $galleryCorePath.'model/gallery/gallery.class.php';
  39. $modx->gallery = new Gallery($modx);
  40. $modx->lexicon->load('gallery:default');
  41. if ($_REQUEST['action'] == 'web/phpthumb') {
  42. $version = $modx->getVersionData();
  43. if (version_compare($version['full_version'],'2.1.1-pl') >= 0) {
  44. if ($modx->user->hasSessionContext($modx->context->get('key'))) {
  45. $_SERVER['HTTP_MODAUTH'] = $_SESSION["modx.{$modx->context->get('key')}.user.token"];
  46. } else {
  47. $_SERVER['HTTP_MODAUTH'] = 0;
  48. }
  49. } else {
  50. $_SERVER['HTTP_MODAUTH'] = $modx->site_id;
  51. }
  52. $_REQUEST['HTTP_MODAUTH'] = $_SERVER['HTTP_MODAUTH'];
  53. }
  54. /* handle request */
  55. $path = $modx->getOption('processorsPath',$modx->gallery->config,$galleryCorePath.'processors/');
  56. $modx->request->handleRequest(array(
  57. 'processors_path' => $path,
  58. 'location' => '',
  59. ));